aboutsummaryrefslogtreecommitdiff
path: root/imports/codemirror/mode/pascal
diff options
context:
space:
mode:
authorPushkar Joshi2012-03-06 17:04:40 -0800
committerPushkar Joshi2012-03-06 17:04:40 -0800
commit7a43958033906b2273de88bc2a26cda7a905d202 (patch)
treef71817e712c4b07a48257a4f0b206cf9033421df /imports/codemirror/mode/pascal
parent264e3d8e6d3624083d2fab9fe2560234553bb2ad (diff)
parent2e3943a8f751ec572066f168b58464c24b9f29e5 (diff)
downloadninja-7a43958033906b2273de88bc2a26cda7a905d202.tar.gz
Merge branch 'master' into brushtool
Diffstat (limited to 'imports/codemirror/mode/pascal')
-rw-r--r--[-rwxr-xr-x]imports/codemirror/mode/pascal/LICENSE0
-rw-r--r--[-rwxr-xr-x]imports/codemirror/mode/pascal/index.html0
-rw-r--r--[-rwxr-xr-x]imports/codemirror/mode/pascal/pascal.js48
3 files changed, 2 insertions, 46 deletions
diff --git a/imports/codemirror/mode/pascal/LICENSE b/imports/codemirror/mode/pascal/LICENSE
index 8e3747e7..8e3747e7 100755..100644
--- a/imports/codemirror/mode/pascal/LICENSE
+++ b/imports/codemirror/mode/pascal/LICENSE
diff --git a/imports/codemirror/mode/pascal/index.html b/imports/codemirror/mode/pascal/index.html
index 6af6b460..6af6b460 100755..100644
--- a/imports/codemirror/mode/pascal/index.html
+++ b/imports/codemirror/mode/pascal/index.html
diff --git a/imports/codemirror/mode/pascal/pascal.js b/imports/codemirror/mode/pascal/pascal.js
index 86c6f71c..9ac522f7 100755..100644
--- a/imports/codemirror/mode/pascal/pascal.js
+++ b/imports/codemirror/mode/pascal/pascal.js
@@ -7,11 +7,9 @@ CodeMirror.defineMode("pascal", function(config) {
7 var keywords = words("and array begin case const div do downto else end file for forward integer " + 7 var keywords = words("and array begin case const div do downto else end file for forward integer " +
8 "boolean char function goto if in label mod nil not of or packed procedure " + 8 "boolean char function goto if in label mod nil not of or packed procedure " +
9 "program record repeat set string then to type until var while with"); 9 "program record repeat set string then to type until var while with");
10 var blockKeywords = words("case do else for if switch while struct then of");
11 var atoms = {"null": true}; 10 var atoms = {"null": true};
12 11
13 var isOperatorChar = /[+\-*&%=<>!?|\/]/; 12 var isOperatorChar = /[+\-*&%=<>!?|\/]/;
14 var curPunc;
15 13
16 function tokenBase(stream, state) { 14 function tokenBase(stream, state) {
17 var ch = stream.next(); 15 var ch = stream.next();
@@ -28,7 +26,6 @@ CodeMirror.defineMode("pascal", function(config) {
28 return tokenComment(stream, state); 26 return tokenComment(stream, state);
29 } 27 }
30 if (/[\[\]{}\(\),;\:\.]/.test(ch)) { 28 if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
31 curPunc = ch;
32 return null 29 return null
33 } 30 }
34 if (/\d/.test(ch)) { 31 if (/\d/.test(ch)) {
@@ -47,10 +44,7 @@ CodeMirror.defineMode("pascal", function(config) {
47 } 44 }
48 stream.eatWhile(/[\w\$_]/); 45 stream.eatWhile(/[\w\$_]/);
49 var cur = stream.current(); 46 var cur = stream.current();
50 if (keywords.propertyIsEnumerable(cur)) { 47 if (keywords.propertyIsEnumerable(cur)) return "keyword";
51 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
52 return "keyword";
53 }
54 if (atoms.propertyIsEnumerable(cur)) return "atom"; 48 if (atoms.propertyIsEnumerable(cur)) return "atom";
55 return "word"; 49 return "word";
56 } 50 }
@@ -79,55 +73,17 @@ CodeMirror.defineMode("pascal", function(config) {
79 return "comment"; 73 return "comment";
80 } 74 }
81 75
82 function Context(indented, column, type, align, prev) {
83 this.indented = indented;
84 this.column = column;
85 this.type = type;
86 this.align = align;
87 this.prev = prev;
88 }
89 function pushContext(state, col, type) {
90 return state.context = new Context(state.indented, col, type, null, state.context);
91 }
92 function popContext(state) {
93 var t = state.context.type;
94 if (t == ")" || t == "]" )
95 state.indented = state.context.indented;
96 return state.context = state.context.prev;
97 }
98
99 // Interface 76 // Interface
100 77
101 return { 78 return {
102 startState: function(basecolumn) { 79 startState: function(basecolumn) {
103 return { 80 return {tokenize: null};
104 tokenize: null,
105 context: new Context((basecolumn || 0) - config.indentUnit, 0, "top", false),
106 indented: 0,
107 startOfLine: true
108 };
109 }, 81 },
110 82
111 token: function(stream, state) { 83 token: function(stream, state) {
112 var ctx = state.context;
113 if (stream.sol()) {
114 if (ctx.align == null) ctx.align = false;
115 state.indented = stream.indentation();
116 state.startOfLine = true;
117 }
118 if (stream.eatSpace()) return null; 84 if (stream.eatSpace()) return null;
119 curPunc = null;
120 var style = (state.tokenize || tokenBase)(stream, state); 85 var style = (state.tokenize || tokenBase)(stream, state);
121 if (style == "comment" || style == "meta") return style; 86 if (style == "comment" || style == "meta") return style;
122 if (ctx.align == null) ctx.align = true;
123
124 if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
125 else if (curPunc == "[") pushContext(state, stream.column(), "]");
126 else if (curPunc == "(") pushContext(state, stream.column(), ")");
127 else if (curPunc == ctx.type) popContext(state);
128 else if ( ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
129 pushContext(state, stream.column(), "statement");
130 state.startOfLine = false;
131 return style; 87 return style;
132 }, 88 },
133 89