##// END OF EJS Templates
codemirror: bumped to version 5.49.2
marcink -
r4105:10488616 default
parent child Browse files
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -0,0 +1,173 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
10 mod(CodeMirror);
11 })(function(CodeMirror) {
12 "use strict";
13
14 CodeMirror.defineMode("fcl", function(config) {
15 var indentUnit = config.indentUnit;
16
17 var keywords = {
18 "term": true,
19 "method": true, "accu": true,
20 "rule": true, "then": true, "is": true, "and": true, "or": true,
21 "if": true, "default": true
22 };
23
24 var start_blocks = {
25 "var_input": true,
26 "var_output": true,
27 "fuzzify": true,
28 "defuzzify": true,
29 "function_block": true,
30 "ruleblock": true
31 };
32
33 var end_blocks = {
34 "end_ruleblock": true,
35 "end_defuzzify": true,
36 "end_function_block": true,
37 "end_fuzzify": true,
38 "end_var": true
39 };
40
41 var atoms = {
42 "true": true, "false": true, "nan": true,
43 "real": true, "min": true, "max": true, "cog": true, "cogs": true
44 };
45
46 var isOperatorChar = /[+\-*&^%:=<>!|\/]/;
47
48 function tokenBase(stream, state) {
49 var ch = stream.next();
50
51 if (/[\d\.]/.test(ch)) {
52 if (ch == ".") {
53 stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/);
54 } else if (ch == "0") {
55 stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/);
56 } else {
57 stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/);
58 }
59 return "number";
60 }
61
62 if (ch == "/" || ch == "(") {
63 if (stream.eat("*")) {
64 state.tokenize = tokenComment;
65 return tokenComment(stream, state);
66 }
67 if (stream.eat("/")) {
68 stream.skipToEnd();
69 return "comment";
70 }
71 }
72 if (isOperatorChar.test(ch)) {
73 stream.eatWhile(isOperatorChar);
74 return "operator";
75 }
76 stream.eatWhile(/[\w\$_\xa1-\uffff]/);
77
78 var cur = stream.current().toLowerCase();
79 if (keywords.propertyIsEnumerable(cur) ||
80 start_blocks.propertyIsEnumerable(cur) ||
81 end_blocks.propertyIsEnumerable(cur)) {
82 return "keyword";
83 }
84 if (atoms.propertyIsEnumerable(cur)) return "atom";
85 return "variable";
86 }
87
88
89 function tokenComment(stream, state) {
90 var maybeEnd = false, ch;
91 while (ch = stream.next()) {
92 if ((ch == "/" || ch == ")") && maybeEnd) {
93 state.tokenize = tokenBase;
94 break;
95 }
96 maybeEnd = (ch == "*");
97 }
98 return "comment";
99 }
100
101 function Context(indented, column, type, align, prev) {
102 this.indented = indented;
103 this.column = column;
104 this.type = type;
105 this.align = align;
106 this.prev = prev;
107 }
108
109 function pushContext(state, col, type) {
110 return state.context = new Context(state.indented, col, type, null, state.context);
111 }
112
113 function popContext(state) {
114 if (!state.context.prev) return;
115 var t = state.context.type;
116 if (t == "end_block")
117 state.indented = state.context.indented;
118 return state.context = state.context.prev;
119 }
120
121 // Interface
122
123 return {
124 startState: function(basecolumn) {
125 return {
126 tokenize: null,
127 context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
128 indented: 0,
129 startOfLine: true
130 };
131 },
132
133 token: function(stream, state) {
134 var ctx = state.context;
135 if (stream.sol()) {
136 if (ctx.align == null) ctx.align = false;
137 state.indented = stream.indentation();
138 state.startOfLine = true;
139 }
140 if (stream.eatSpace()) return null;
141
142 var style = (state.tokenize || tokenBase)(stream, state);
143 if (style == "comment") return style;
144 if (ctx.align == null) ctx.align = true;
145
146 var cur = stream.current().toLowerCase();
147
148 if (start_blocks.propertyIsEnumerable(cur)) pushContext(state, stream.column(), "end_block");
149 else if (end_blocks.propertyIsEnumerable(cur)) popContext(state);
150
151 state.startOfLine = false;
152 return style;
153 },
154
155 indent: function(state, textAfter) {
156 if (state.tokenize != tokenBase && state.tokenize != null) return 0;
157 var ctx = state.context;
158
159 var closing = end_blocks.propertyIsEnumerable(textAfter);
160 if (ctx.align) return ctx.column + (closing ? 0 : 1);
161 else return ctx.indented + (closing ? 0 : indentUnit);
162 },
163
164 electricChars: "ryk",
165 fold: "brace",
166 blockCommentStart: "(*",
167 blockCommentEnd: "*)",
168 lineComment: "//"
169 };
170 });
171
172 CodeMirror.defineMIME("text/x-fcl", "fcl");
173 });
1 NO CONTENT: new file 100644
NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100755
NO CONTENT: new file 100755
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
@@ -1,418 +1,438 b''
1 /* BASICS */
1 /* BASICS */
2
2
3 .CodeMirror {
3 .CodeMirror {
4 /* Set height, width, borders, and global font properties here */
4 /* Set height, width, borders, and global font properties here */
5 font-family: monospace;
5 font-family: monospace;
6 height: 300px;
6 height: 300px;
7 color: black;
7 color: black;
8 direction: ltr;
8 border-radius: @border-radius;
9 border-radius: @border-radius;
9 border: @border-thickness solid @grey6;
10 border: @border-thickness solid @grey6;
10 margin: 0 0 @padding;
11 margin: 0 0 @padding;
11 }
12 }
12
13
13 /* PADDING */
14 /* PADDING */
14
15
15 .CodeMirror-lines {
16 .CodeMirror-lines {
16 padding: 4px 0; /* Vertical padding around content */
17 padding: 4px 0; /* Vertical padding around content */
17 }
18 }
18 .CodeMirror pre {
19 .CodeMirror pre.CodeMirror-line,
20 .CodeMirror pre.CodeMirror-line-like {
19 padding: 0 4px; /* Horizontal padding of content */
21 padding: 0 4px; /* Horizontal padding of content */
20 }
22 }
21
23
22 .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
24 .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
23 background-color: white; /* The little square between H and V scrollbars */
25 background-color: white; /* The little square between H and V scrollbars */
24 }
26 }
25
27
26 /* GUTTER */
28 /* GUTTER */
27
29
28 .CodeMirror-gutters {
30 .CodeMirror-gutters {
29 border-right: 1px solid #ddd;
31 border-right: 1px solid #ddd;
30 background-color: white;
32 background-color: white;
31 white-space: nowrap;
33 white-space: nowrap;
32 }
34 }
33 .CodeMirror-linenumbers {}
35 .CodeMirror-linenumbers {}
34 .CodeMirror-linenumber {
36 .CodeMirror-linenumber {
35 padding: 0 3px 0 5px;
37 padding: 0 3px 0 5px;
36 min-width: 20px;
38 min-width: 20px;
37 text-align: right;
39 text-align: right;
38 color: @grey4;
40 color: @grey4;
39 white-space: nowrap;
41 white-space: nowrap;
40 }
42 }
41
43
42 .CodeMirror-guttermarker { color: black; }
44 .CodeMirror-guttermarker { color: black; }
43 .CodeMirror-guttermarker-subtle { color: #999; }
45 .CodeMirror-guttermarker-subtle { color: #999; }
44
46
45 /* CURSOR */
47 /* CURSOR */
46
48
47 .CodeMirror div.CodeMirror-cursor {
49 .CodeMirror-cursor {
48 border-left: 1px solid black;
50 border-left: 1px solid black;
51 border-right: none;
52 width: 0;
49 }
53 }
50 /* Shown when moving in bi-directional text */
54 /* Shown when moving in bi-directional text */
51 .CodeMirror div.CodeMirror-secondarycursor {
55 .CodeMirror div.CodeMirror-secondarycursor {
52 border-left: 1px solid silver;
56 border-left: 1px solid silver;
53 }
57 }
54 .CodeMirror.cm-fat-cursor div.CodeMirror-cursor {
58 .cm-fat-cursor .CodeMirror-cursor {
55 width: auto;
59 width: auto;
56 border: 0;
60 border: 0 !important;
57 background: @grey6;
61 background: @grey6;
58 }
62 }
59 .CodeMirror.cm-fat-cursor div.CodeMirror-cursors {
63 .cm-fat-cursor div.CodeMirror-cursors {
60 z-index: 1;
64 z-index: 1;
61 }
65 }
62
66 .cm-fat-cursor-mark {
67 background-color: rgba(20, 255, 20, 0.5);
68 -webkit-animation: blink 1.06s steps(1) infinite;
69 -moz-animation: blink 1.06s steps(1) infinite;
70 animation: blink 1.06s steps(1) infinite;
71 }
63 .cm-animate-fat-cursor {
72 .cm-animate-fat-cursor {
64 width: auto;
73 width: auto;
65 border: 0;
74 border: 0;
66 -webkit-animation: blink 1.06s steps(1) infinite;
75 -webkit-animation: blink 1.06s steps(1) infinite;
67 -moz-animation: blink 1.06s steps(1) infinite;
76 -moz-animation: blink 1.06s steps(1) infinite;
68 animation: blink 1.06s steps(1) infinite;
77 animation: blink 1.06s steps(1) infinite;
78 background-color: #7e7;
69 }
79 }
70 @-moz-keyframes blink {
80 @-moz-keyframes blink {
71 0% { background: #7e7; }
81 0% { background: #7e7; }
72 50% { background: none; }
82 50% { background: none; }
73 100% { background: #7e7; }
83 100% { background: #7e7; }
74 }
84 }
75 @-webkit-keyframes blink {
85 @-webkit-keyframes blink {
76 0% { background: #7e7; }
86 0% { background: #7e7; }
77 50% { background: none; }
87 50% { background: none; }
78 100% { background: #7e7; }
88 100% { background: #7e7; }
79 }
89 }
80 @keyframes blink {
90 @keyframes blink {
81 0% { background: #7e7; }
91 0% { background: #7e7; }
82 50% { background: none; }
92 50% { background: none; }
83 100% { background: #7e7; }
93 100% { background: #7e7; }
84 }
94 }
85
95
86 /* Can style cursor different in overwrite (non-insert) mode */
96 /* Can style cursor different in overwrite (non-insert) mode */
87 div.CodeMirror-overwrite div.CodeMirror-cursor {}
97 .CodeMirror-overwrite .CodeMirror-cursor {}
88
98
89 .cm-tab { display: inline-block; text-decoration: inherit; }
99 .cm-tab { display: inline-block; text-decoration: inherit; }
90
100
101 .CodeMirror-rulers {
102 position: absolute;
103 left: 0; right: 0; top: -50px; bottom: 0;
104 overflow: hidden;
105 }
91 .CodeMirror-ruler {
106 .CodeMirror-ruler {
92 border-left: 1px solid #ccc;
107 border-left: 1px solid #ccc;
108 top: 0; bottom: 0;
93 position: absolute;
109 position: absolute;
94 }
110 }
95
111
96 /* DEFAULT THEME */
112 /* DEFAULT THEME */
97
113
98 .cm-s-default .cm-header {color: blue;}
114 .cm-s-default .cm-header {color: blue;}
99 .cm-s-default .cm-quote {color: #090;}
115 .cm-s-default .cm-quote {color: #090;}
100 .cm-negative {color: #d44;}
116 .cm-negative {color: #d44;}
101 .cm-positive {color: #292;}
117 .cm-positive {color: #292;}
102 .cm-header, .cm-strong {font-weight: bold;}
118 .cm-header, .cm-strong {font-weight: bold;}
103 .cm-em {font-style: italic;}
119 .cm-em {font-style: italic;}
104 .cm-link {text-decoration: underline;}
120 .cm-link {text-decoration: underline;}
105 .cm-strikethrough {text-decoration: line-through;}
121 .cm-strikethrough {text-decoration: line-through;}
106
122
107 .cm-s-default .cm-keyword {color: #708;}
123 .cm-s-default .cm-keyword {color: #708;}
108 .cm-s-default .cm-atom {color: #219;}
124 .cm-s-default .cm-atom {color: #219;}
109 .cm-s-default .cm-number {color: #164;}
125 .cm-s-default .cm-number {color: #164;}
110 .cm-s-default .cm-def {color: #00f;}
126 .cm-s-default .cm-def {color: #00f;}
111 .cm-s-default .cm-variable,
127 .cm-s-default .cm-variable,
112 .cm-s-default .cm-punctuation,
128 .cm-s-default .cm-punctuation,
113 .cm-s-default .cm-property,
129 .cm-s-default .cm-property,
114 .cm-s-default .cm-operator {}
130 .cm-s-default .cm-operator {}
115 .cm-s-default .cm-variable-2 {color: #05a;}
131 .cm-s-default .cm-variable-2 {color: #05a;}
116 .cm-s-default .cm-variable-3 {color: #085;}
132 .cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}
117 .cm-s-default .cm-comment {color: #a50;}
133 .cm-s-default .cm-comment {color: #a50;}
118 .cm-s-default .cm-string {color: #a11;}
134 .cm-s-default .cm-string {color: #a11;}
119 .cm-s-default .cm-string-2 {color: #f50;}
135 .cm-s-default .cm-string-2 {color: #f50;}
120 .cm-s-default .cm-meta {color: #555;}
136 .cm-s-default .cm-meta {color: #555;}
121 .cm-s-default .cm-qualifier {color: #555;}
137 .cm-s-default .cm-qualifier {color: #555;}
122 .cm-s-default .cm-builtin {color: #30a;}
138 .cm-s-default .cm-builtin {color: #30a;}
123 .cm-s-default .cm-bracket {color: #997;}
139 .cm-s-default .cm-bracket {color: #997;}
124 .cm-s-default .cm-tag {color: #170;}
140 .cm-s-default .cm-tag {color: #170;}
125 .cm-s-default .cm-attribute {color: #00c;}
141 .cm-s-default .cm-attribute {color: #00c;}
126 .cm-s-default .cm-hr {color: #999;}
142 .cm-s-default .cm-hr {color: #999;}
127 .cm-s-default .cm-link {color: #00c;}
143 .cm-s-default .cm-link {color: #00c;}
128
144
129 .cm-s-default .cm-error {color: #f00;}
145 .cm-s-default .cm-error {color: #f00;}
130 .cm-invalidchar {color: #f00;}
146 .cm-invalidchar {color: #f00;}
131
147
132 .CodeMirror-composing { border-bottom: 2px solid; }
148 .CodeMirror-composing { border-bottom: 2px solid; }
133
149
134 /* Default styles for common addons */
150 /* Default styles for common addons */
135
151
136 div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
152 div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}
137 div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
153 div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
138 .CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
154 .CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
139 .CodeMirror-activeline-background {background: #e8f2ff;}
155 .CodeMirror-activeline-background {background: #e8f2ff;}
140
156
141 /* STOP */
157 /* STOP */
142
158
143 /* The rest of this file contains styles related to the mechanics of
159 /* The rest of this file contains styles related to the mechanics of
144 the editor. You probably shouldn't touch them. */
160 the editor. You probably shouldn't touch them. */
145
161
146 .CodeMirror {
162 .CodeMirror {
147 position: relative;
163 position: relative;
148 overflow: hidden;
164 overflow: hidden;
149 background: white;
165 background: white;
150 }
166 }
151
167
152 .CodeMirror-scroll {
168 .CodeMirror-scroll {
153 overflow: scroll !important; /* Things will break if this is overridden */
169 overflow: scroll !important; /* Things will break if this is overridden */
154 /* 30px is the magic margin used to hide the element's real scrollbars */
170 /* 30px is the magic margin used to hide the element's real scrollbars */
155 /* See overflow: hidden in .CodeMirror */
171 /* See overflow: hidden in .CodeMirror */
156 margin-bottom: -30px; margin-right: -30px;
172 margin-bottom: -30px; margin-right: -30px;
157 padding-bottom: 30px;
173 padding-bottom: 30px;
158 height: 100%;
174 height: 100%;
159 outline: none; /* Prevent dragging from highlighting the element */
175 outline: none; /* Prevent dragging from highlighting the element */
160 position: relative;
176 position: relative;
161 }
177 }
162 .CodeMirror-sizer {
178 .CodeMirror-sizer {
163 position: relative;
179 position: relative;
164 border-right: 30px solid transparent;
180 border-right: 30px solid transparent;
165 }
181 }
166
182
167 /* The fake, visible scrollbars. Used to force redraw during scrolling
183 /* The fake, visible scrollbars. Used to force redraw during scrolling
168 before actual scrolling happens, thus preventing shaking and
184 before actual scrolling happens, thus preventing shaking and
169 flickering artifacts. */
185 flickering artifacts. */
170 .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
186 .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
171 position: absolute;
187 position: absolute;
172 z-index: 6;
188 z-index: 6;
173 display: none;
189 display: none;
174 }
190 }
175 .CodeMirror-vscrollbar {
191 .CodeMirror-vscrollbar {
176 right: 0; top: 0;
192 right: 0; top: 0;
177 overflow-x: hidden;
193 overflow-x: hidden;
178 overflow-y: scroll;
194 overflow-y: scroll;
179 }
195 }
180 .CodeMirror-hscrollbar {
196 .CodeMirror-hscrollbar {
181 bottom: 0; left: 0;
197 bottom: 0; left: 0;
182 overflow-y: hidden;
198 overflow-y: hidden;
183 overflow-x: scroll;
199 overflow-x: scroll;
184 }
200 }
185 .CodeMirror-scrollbar-filler {
201 .CodeMirror-scrollbar-filler {
186 right: 0; bottom: 0;
202 right: 0; bottom: 0;
187 }
203 }
188 .CodeMirror-gutter-filler {
204 .CodeMirror-gutter-filler {
189 left: 0; bottom: 0;
205 left: 0; bottom: 0;
190 }
206 }
191
207
192 .CodeMirror-gutters {
208 .CodeMirror-gutters {
193 position: absolute; left: 0; top: 0;
209 position: absolute; left: 0; top: 0;
210 min-height: 100%;
194 z-index: 3;
211 z-index: 3;
195 }
212 }
196 .CodeMirror-gutter {
213 .CodeMirror-gutter {
197 white-space: normal;
214 white-space: normal;
198 height: 100%;
215 height: 100%;
199 display: inline-block;
216 display: inline-block;
217 vertical-align: top;
200 margin-bottom: -30px;
218 margin-bottom: -30px;
201 /* Hack to make IE7 behave */
202 *zoom:1;
203 *display:inline;
204 }
219 }
205 .CodeMirror-gutter-wrapper {
220 .CodeMirror-gutter-wrapper {
206 position: absolute;
221 position: absolute;
207 z-index: 4;
222 z-index: 4;
223 background: none !important;
224 border: none !important;
208 height: 100%;
225 height: 100%;
209 }
226 }
210 .CodeMirror-gutter-background {
227 .CodeMirror-gutter-background {
211 position: absolute;
228 position: absolute;
212 top: 0; bottom: 0;
229 top: 0; bottom: 0;
213 z-index: 4;
230 z-index: 4;
214 }
231 }
215 .CodeMirror-gutter-elt {
232 .CodeMirror-gutter-elt {
216 position: absolute;
233 position: absolute;
217 cursor: default;
234 cursor: default;
218 z-index: 4;
235 z-index: 4;
219 }
236 }
220 .CodeMirror-gutter-wrapper {
237 .CodeMirror-gutter-wrapper {
221 -webkit-user-select: none;
238 -webkit-user-select: none;
222 -moz-user-select: none;
239 -moz-user-select: none;
223 user-select: none;
240 user-select: none;
224 }
241 }
225
242
226 .CodeMirror-lines {
243 .CodeMirror-lines {
227 cursor: text;
244 cursor: text;
228 min-height: 1px; /* prevents collapsing before first draw */
245 min-height: 1px; /* prevents collapsing before first draw */
229 }
246 }
230 .CodeMirror pre {
247 .CodeMirror pre.CodeMirror-line,
248 .CodeMirror pre.CodeMirror-line-like {
231 /* Reset some styles that the rest of the page might have set */
249 /* Reset some styles that the rest of the page might have set */
232 -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
250 -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
233 border-width: 0;
251 border-width: 0;
234 background: transparent;
252 background: transparent;
235 font-family: inherit;
253 font-family: inherit;
236 font-size: inherit;
254 font-size: inherit;
237 margin: 0;
255 margin: 0;
238 white-space: pre;
256 white-space: pre;
239 word-wrap: normal;
257 word-wrap: normal;
240 line-height: inherit;
258 line-height: inherit;
241 color: inherit;
259 color: inherit;
242 z-index: 2;
260 z-index: 2;
243 position: relative;
261 position: relative;
244 overflow: visible;
262 overflow: visible;
245 -webkit-tap-highlight-color: transparent;
263 -webkit-tap-highlight-color: transparent;
264 -webkit-font-variant-ligatures: contextual;
265 font-variant-ligatures: contextual;
246 }
266 }
247 .CodeMirror-wrap pre {
267 .CodeMirror-wrap pre.CodeMirror-line,
268 .CodeMirror-wrap pre.CodeMirror-line-like {
248 word-wrap: break-word;
269 word-wrap: break-word;
249 white-space: pre-wrap;
270 white-space: pre-wrap;
250 word-break: normal;
271 word-break: normal;
251 }
272 }
252
273
253 .CodeMirror-linebackground {
274 .CodeMirror-linebackground {
254 position: absolute;
275 position: absolute;
255 left: 0; right: 0; top: 0; bottom: 0;
276 left: 0; right: 0; top: 0; bottom: 0;
256 z-index: 0;
277 z-index: 0;
257 }
278 }
258
279
259 .CodeMirror-linewidget {
280 .CodeMirror-linewidget {
260 position: relative;
281 position: relative;
261 z-index: 2;
282 z-index: 2;
283 padding: 0.1px; /* Force widget margins to stay inside of the container */
262 overflow: auto;
284 overflow: auto;
263 }
285 }
264
286
265 .CodeMirror-widget {}
287 .CodeMirror-widget {}
266
288
289 .CodeMirror-rtl pre { direction: rtl; }
290
267 .CodeMirror-code {
291 .CodeMirror-code {
268 outline: none;
292 outline: none;
269 }
293 }
270
294
271 /* Force content-box sizing for the elements where we expect it */
295 /* Force content-box sizing for the elements where we expect it */
272 .CodeMirror-scroll,
296 .CodeMirror-scroll,
273 .CodeMirror-sizer,
297 .CodeMirror-sizer,
274 .CodeMirror-gutter,
298 .CodeMirror-gutter,
275 .CodeMirror-gutters,
299 .CodeMirror-gutters,
276 .CodeMirror-linenumber {
300 .CodeMirror-linenumber {
277 -moz-box-sizing: content-box;
301 -moz-box-sizing: content-box;
278 box-sizing: content-box;
302 box-sizing: content-box;
279 }
303 }
280
304
281 .CodeMirror-measure {
305 .CodeMirror-measure {
282 position: absolute;
306 position: absolute;
283 width: 100%;
307 width: 100%;
284 height: 0;
308 height: 0;
285 overflow: hidden;
309 overflow: hidden;
286 visibility: hidden;
310 visibility: hidden;
287 }
311 }
288
312
289
313 .CodeMirror-cursor {
290 .CodeMirror div.CodeMirror-cursor {
291 position: absolute;
314 position: absolute;
315 pointer-events: none;
292 border-right: none;
316 border-right: none;
293 width: 0;
317 width: 0;
294 }
318 }
295
296 .CodeMirror-measure pre { position: static; }
319 .CodeMirror-measure pre { position: static; }
297
320
298 div.CodeMirror-cursors {
321 div.CodeMirror-cursors {
299 visibility: hidden;
322 visibility: hidden;
300 position: relative;
323 position: relative;
301 z-index: 3;
324 z-index: 3;
302 }
325 }
303 div.CodeMirror-dragcursors {
326 div.CodeMirror-dragcursors {
304 visibility: visible;
327 visibility: visible;
305 }
328 }
306
329
307 .CodeMirror-focused div.CodeMirror-cursors {
330 .CodeMirror-focused div.CodeMirror-cursors {
308 visibility: visible;
331 visibility: visible;
309 }
332 }
310
333
311 .CodeMirror-selected { background: #d9d9d9; }
334 .CodeMirror-selected { background: #d9d9d9; }
312 .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
335 .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
313 .CodeMirror-crosshair { cursor: crosshair; }
336 .CodeMirror-crosshair { cursor: crosshair; }
314 .CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
337 .CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
315 .CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
338 .CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
316
339
317 .cm-searching {
340 .cm-searching {
318 background: #ffa;
341 background-color: #ffa;
319 background: rgba(255, 255, 0, .4);
342 background-color: rgba(255, 255, 0, .4);
320 }
343 }
321
344
322 /* IE7 hack to prevent it from returning funny offsetTops on the spans */
323 .CodeMirror span { *vertical-align: text-bottom; }
324
325 /* Used to force a border model for a node */
345 /* Used to force a border model for a node */
326 .cm-force-border { padding-right: .1px; }
346 .cm-force-border { padding-right: .1px; }
327
347
328 @media print {
348 @media print {
329 /* Hide the cursor when printing */
349 /* Hide the cursor when printing */
330 .CodeMirror div.CodeMirror-cursors {
350 .CodeMirror div.CodeMirror-cursors {
331 visibility: hidden;
351 visibility: hidden;
332 }
352 }
333 }
353 }
334
354
335 /* See issue #2901 */
355 /* See issue #2901 */
336 .cm-tab-wrap-hack:after { content: ''; }
356 .cm-tab-wrap-hack:after { content: ''; }
337
357
338 /* Help users use markselection to safely style text background */
358 /* Help users use markselection to safely style text background */
339 span.CodeMirror-selectedtext { background: none; }
359 span.CodeMirror-selectedtext { background: none; }
340
360
341 /* codemirror autocomplete widget */
361 /* codemirror autocomplete widget */
342 .CodeMirror-hints {
362 .CodeMirror-hints {
343 position: absolute;
363 position: absolute;
344 z-index: 10;
364 z-index: 10;
345 overflow: hidden;
365 overflow: hidden;
346 list-style: none;
366 list-style: none;
347
367
348 margin: 0;
368 margin: 0;
349 padding: 0;
369 padding: 0;
350
370
351 border-radius: @border-radius;
371 border-radius: @border-radius;
352 border: @border-thickness solid @rcblue;
372 border: @border-thickness solid @rcblue;
353
373
354 color: @rcblue;
374 color: @rcblue;
355 background-color: white;
375 background-color: white;
356 font-size: 95%;
376 font-size: 95%;
357
377
358 max-height: 20em;
378 max-height: 20em;
359 overflow-y: auto;
379 overflow-y: auto;
360 }
380 }
361
381
362 .CodeMirror-hint {
382 .CodeMirror-hint {
363 margin: 0;
383 margin: 0;
364 padding: 4px 8px;
384 padding: 4px 8px;
365 max-width: 40em;
385 max-width: 40em;
366 white-space: pre;
386 white-space: pre;
367 color: @rcblue;
387 color: @rcblue;
368 cursor: pointer;
388 cursor: pointer;
369 }
389 }
370
390
371 .CodeMirror-hint-active {
391 .CodeMirror-hint-active {
372 background: @rclightblue;
392 background: @rclightblue;
373 color: @rcblue;
393 color: @rcblue;
374 }
394 }
375
395
376 .CodeMirror-hint-entry {
396 .CodeMirror-hint-entry {
377 width: 38em;
397 width: 38em;
378 color: @rcblue;
398 color: @rcblue;
379 }
399 }
380
400
381 .CodeMirror-hint-entry .gravatar {
401 .CodeMirror-hint-entry .gravatar {
382 height: @gravatar-size;
402 height: @gravatar-size;
383 width: @gravatar-size;
403 width: @gravatar-size;
384 margin-right: 4px;
404 margin-right: 4px;
385 }
405 }
386
406
387 .CodeMirror-empty {
407 .CodeMirror-empty {
388 border: @border-thickness solid @grey5;
408 border: @border-thickness solid @grey5;
389 }
409 }
390
410
391 .CodeMirror-focused {
411 .CodeMirror-focused {
392 border: @border-thickness solid @grey5;
412 border: @border-thickness solid @grey5;
393 }
413 }
394
414
395 .CodeMirror-empty.CodeMirror-focused {
415 .CodeMirror-empty.CodeMirror-focused {
396 border: @border-thickness solid @grey5;
416 border: @border-thickness solid @grey5;
397 }
417 }
398
418
399 .CodeMirror pre.CodeMirror-placeholder {
419 .CodeMirror pre.CodeMirror-placeholder {
400 color: @grey4;
420 color: @grey4;
401 }
421 }
402
422
403 /** RhodeCode Customizations **/
423 /** RhodeCode Customizations **/
404
424
405 .CodeMirror.cm-s-rc-input {
425 .CodeMirror.cm-s-rc-input {
406 border: @border-thickness solid @grey4;
426 border: @border-thickness solid @grey4;
407 }
427 }
408
428
409 .CodeMirror-code pre {
429 .CodeMirror-code pre {
410 border-right: 30px solid transparent;
430 border-right: 30px solid transparent;
411 width: -webkit-fit-content;
431 width: -webkit-fit-content;
412 width: -moz-fit-content;
432 width: -moz-fit-content;
413 width: fit-content;
433 width: fit-content;
414 }
434 }
415 .CodeMirror-wrap .CodeMirror-code pre {
435 .CodeMirror-wrap .CodeMirror-code pre {
416 border-right: none;
436 border-right: none;
417 width: auto;
437 width: auto;
418 }
438 }
@@ -1,174 +1,174 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("apl", function() {
14 CodeMirror.defineMode("apl", function() {
15 var builtInOps = {
15 var builtInOps = {
16 ".": "innerProduct",
16 ".": "innerProduct",
17 "\\": "scan",
17 "\\": "scan",
18 "/": "reduce",
18 "/": "reduce",
19 "⌿": "reduce1Axis",
19 "⌿": "reduce1Axis",
20 "⍀": "scan1Axis",
20 "⍀": "scan1Axis",
21 "¨": "each",
21 "¨": "each",
22 "⍣": "power"
22 "⍣": "power"
23 };
23 };
24 var builtInFuncs = {
24 var builtInFuncs = {
25 "+": ["conjugate", "add"],
25 "+": ["conjugate", "add"],
26 "−": ["negate", "subtract"],
26 "−": ["negate", "subtract"],
27 "×": ["signOf", "multiply"],
27 "×": ["signOf", "multiply"],
28 "÷": ["reciprocal", "divide"],
28 "÷": ["reciprocal", "divide"],
29 "⌈": ["ceiling", "greaterOf"],
29 "⌈": ["ceiling", "greaterOf"],
30 "⌊": ["floor", "lesserOf"],
30 "⌊": ["floor", "lesserOf"],
31 "∣": ["absolute", "residue"],
31 "∣": ["absolute", "residue"],
32 "⍳": ["indexGenerate", "indexOf"],
32 "⍳": ["indexGenerate", "indexOf"],
33 "?": ["roll", "deal"],
33 "?": ["roll", "deal"],
34 "⋆": ["exponentiate", "toThePowerOf"],
34 "⋆": ["exponentiate", "toThePowerOf"],
35 "⍟": ["naturalLog", "logToTheBase"],
35 "⍟": ["naturalLog", "logToTheBase"],
36 "○": ["piTimes", "circularFuncs"],
36 "○": ["piTimes", "circularFuncs"],
37 "!": ["factorial", "binomial"],
37 "!": ["factorial", "binomial"],
38 "⌹": ["matrixInverse", "matrixDivide"],
38 "⌹": ["matrixInverse", "matrixDivide"],
39 "<": [null, "lessThan"],
39 "<": [null, "lessThan"],
40 "≤": [null, "lessThanOrEqual"],
40 "≤": [null, "lessThanOrEqual"],
41 "=": [null, "equals"],
41 "=": [null, "equals"],
42 ">": [null, "greaterThan"],
42 ">": [null, "greaterThan"],
43 "≥": [null, "greaterThanOrEqual"],
43 "≥": [null, "greaterThanOrEqual"],
44 "≠": [null, "notEqual"],
44 "≠": [null, "notEqual"],
45 "≡": ["depth", "match"],
45 "≡": ["depth", "match"],
46 "≢": [null, "notMatch"],
46 "≢": [null, "notMatch"],
47 "∈": ["enlist", "membership"],
47 "∈": ["enlist", "membership"],
48 "⍷": [null, "find"],
48 "⍷": [null, "find"],
49 "∪": ["unique", "union"],
49 "∪": ["unique", "union"],
50 "∩": [null, "intersection"],
50 "∩": [null, "intersection"],
51 "∼": ["not", "without"],
51 "∼": ["not", "without"],
52 "∨": [null, "or"],
52 "∨": [null, "or"],
53 "∧": [null, "and"],
53 "∧": [null, "and"],
54 "⍱": [null, "nor"],
54 "⍱": [null, "nor"],
55 "⍲": [null, "nand"],
55 "⍲": [null, "nand"],
56 "⍴": ["shapeOf", "reshape"],
56 "⍴": ["shapeOf", "reshape"],
57 ",": ["ravel", "catenate"],
57 ",": ["ravel", "catenate"],
58 "⍪": [null, "firstAxisCatenate"],
58 "⍪": [null, "firstAxisCatenate"],
59 "⌽": ["reverse", "rotate"],
59 "⌽": ["reverse", "rotate"],
60 "⊖": ["axis1Reverse", "axis1Rotate"],
60 "⊖": ["axis1Reverse", "axis1Rotate"],
61 "⍉": ["transpose", null],
61 "⍉": ["transpose", null],
62 "↑": ["first", "take"],
62 "↑": ["first", "take"],
63 "↓": [null, "drop"],
63 "↓": [null, "drop"],
64 "⊂": ["enclose", "partitionWithAxis"],
64 "⊂": ["enclose", "partitionWithAxis"],
65 "⊃": ["diclose", "pick"],
65 "⊃": ["diclose", "pick"],
66 "⌷": [null, "index"],
66 "⌷": [null, "index"],
67 "⍋": ["gradeUp", null],
67 "⍋": ["gradeUp", null],
68 "⍒": ["gradeDown", null],
68 "⍒": ["gradeDown", null],
69 "⊤": ["encode", null],
69 "⊤": ["encode", null],
70 "⊥": ["decode", null],
70 "⊥": ["decode", null],
71 "⍕": ["format", "formatByExample"],
71 "⍕": ["format", "formatByExample"],
72 "⍎": ["execute", null],
72 "⍎": ["execute", null],
73 "⊣": ["stop", "left"],
73 "⊣": ["stop", "left"],
74 "⊢": ["pass", "right"]
74 "⊢": ["pass", "right"]
75 };
75 };
76
76
77 var isOperator = /[\.\/⌿⍀¨⍣]/;
77 var isOperator = /[\.\/⌿⍀¨⍣]/;
78 var isNiladic = /⍬/;
78 var isNiladic = /⍬/;
79 var isFunction = /[\+−×÷⌈⌊∣⍳\?⋆⍟○!⌹<≤=>≥≠≡≢∈⍷∪∩∼∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢]/;
79 var isFunction = /[\+−×÷⌈⌊∣⍳\?⋆⍟○!⌹<≤=>≥≠≡≢∈⍷∪∩∼∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢]/;
80 var isArrow = /←/;
80 var isArrow = /←/;
81 var isComment = /[⍝#].*$/;
81 var isComment = /[⍝#].*$/;
82
82
83 var stringEater = function(type) {
83 var stringEater = function(type) {
84 var prev;
84 var prev;
85 prev = false;
85 prev = false;
86 return function(c) {
86 return function(c) {
87 prev = c;
87 prev = c;
88 if (c === type) {
88 if (c === type) {
89 return prev === "\\";
89 return prev === "\\";
90 }
90 }
91 return true;
91 return true;
92 };
92 };
93 };
93 };
94 return {
94 return {
95 startState: function() {
95 startState: function() {
96 return {
96 return {
97 prev: false,
97 prev: false,
98 func: false,
98 func: false,
99 op: false,
99 op: false,
100 string: false,
100 string: false,
101 escape: false
101 escape: false
102 };
102 };
103 },
103 },
104 token: function(stream, state) {
104 token: function(stream, state) {
105 var ch, funcName;
105 var ch, funcName;
106 if (stream.eatSpace()) {
106 if (stream.eatSpace()) {
107 return null;
107 return null;
108 }
108 }
109 ch = stream.next();
109 ch = stream.next();
110 if (ch === '"' || ch === "'") {
110 if (ch === '"' || ch === "'") {
111 stream.eatWhile(stringEater(ch));
111 stream.eatWhile(stringEater(ch));
112 stream.next();
112 stream.next();
113 state.prev = true;
113 state.prev = true;
114 return "string";
114 return "string";
115 }
115 }
116 if (/[\[{\(]/.test(ch)) {
116 if (/[\[{\(]/.test(ch)) {
117 state.prev = false;
117 state.prev = false;
118 return null;
118 return null;
119 }
119 }
120 if (/[\]}\)]/.test(ch)) {
120 if (/[\]}\)]/.test(ch)) {
121 state.prev = true;
121 state.prev = true;
122 return null;
122 return null;
123 }
123 }
124 if (isNiladic.test(ch)) {
124 if (isNiladic.test(ch)) {
125 state.prev = false;
125 state.prev = false;
126 return "niladic";
126 return "niladic";
127 }
127 }
128 if (/[¯\d]/.test(ch)) {
128 if (/[¯\d]/.test(ch)) {
129 if (state.func) {
129 if (state.func) {
130 state.func = false;
130 state.func = false;
131 state.prev = false;
131 state.prev = false;
132 } else {
132 } else {
133 state.prev = true;
133 state.prev = true;
134 }
134 }
135 stream.eatWhile(/[\w\.]/);
135 stream.eatWhile(/[\w\.]/);
136 return "number";
136 return "number";
137 }
137 }
138 if (isOperator.test(ch)) {
138 if (isOperator.test(ch)) {
139 return "operator apl-" + builtInOps[ch];
139 return "operator apl-" + builtInOps[ch];
140 }
140 }
141 if (isArrow.test(ch)) {
141 if (isArrow.test(ch)) {
142 return "apl-arrow";
142 return "apl-arrow";
143 }
143 }
144 if (isFunction.test(ch)) {
144 if (isFunction.test(ch)) {
145 funcName = "apl-";
145 funcName = "apl-";
146 if (builtInFuncs[ch] != null) {
146 if (builtInFuncs[ch] != null) {
147 if (state.prev) {
147 if (state.prev) {
148 funcName += builtInFuncs[ch][1];
148 funcName += builtInFuncs[ch][1];
149 } else {
149 } else {
150 funcName += builtInFuncs[ch][0];
150 funcName += builtInFuncs[ch][0];
151 }
151 }
152 }
152 }
153 state.func = true;
153 state.func = true;
154 state.prev = false;
154 state.prev = false;
155 return "function " + funcName;
155 return "function " + funcName;
156 }
156 }
157 if (isComment.test(ch)) {
157 if (isComment.test(ch)) {
158 stream.skipToEnd();
158 stream.skipToEnd();
159 return "comment";
159 return "comment";
160 }
160 }
161 if (ch === "∘" && stream.peek() === ".") {
161 if (ch === "∘" && stream.peek() === ".") {
162 stream.next();
162 stream.next();
163 return "function jot-dot";
163 return "function jot-dot";
164 }
164 }
165 stream.eatWhile(/[\w\$_]/);
165 stream.eatWhile(/[\w\$_]/);
166 state.prev = true;
166 state.prev = true;
167 return "keyword";
167 return "keyword";
168 }
168 }
169 };
169 };
170 });
170 });
171
171
172 CodeMirror.defineMIME("text/apl", "apl");
172 CodeMirror.defineMIME("text/apl", "apl");
173
173
174 });
174 });
@@ -1,73 +1,74 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 function errorIfNotEmpty(stream) {
14 function errorIfNotEmpty(stream) {
15 var nonWS = stream.match(/^\s*\S/);
15 var nonWS = stream.match(/^\s*\S/);
16 stream.skipToEnd();
16 stream.skipToEnd();
17 return nonWS ? "error" : null;
17 return nonWS ? "error" : null;
18 }
18 }
19
19
20 CodeMirror.defineMode("asciiarmor", function() {
20 CodeMirror.defineMode("asciiarmor", function() {
21 return {
21 return {
22 token: function(stream, state) {
22 token: function(stream, state) {
23 var m;
23 var m;
24 if (state.state == "top") {
24 if (state.state == "top") {
25 if (stream.sol() && (m = stream.match(/^-----BEGIN (.*)?-----\s*$/))) {
25 if (stream.sol() && (m = stream.match(/^-----BEGIN (.*)?-----\s*$/))) {
26 state.state = "headers";
26 state.state = "headers";
27 state.type = m[1];
27 state.type = m[1];
28 return "tag";
28 return "tag";
29 }
29 }
30 return errorIfNotEmpty(stream);
30 return errorIfNotEmpty(stream);
31 } else if (state.state == "headers") {
31 } else if (state.state == "headers") {
32 if (stream.sol() && stream.match(/^\w+:/)) {
32 if (stream.sol() && stream.match(/^\w+:/)) {
33 state.state = "header";
33 state.state = "header";
34 return "atom";
34 return "atom";
35 } else {
35 } else {
36 var result = errorIfNotEmpty(stream);
36 var result = errorIfNotEmpty(stream);
37 if (result) state.state = "body";
37 if (result) state.state = "body";
38 return result;
38 return result;
39 }
39 }
40 } else if (state.state == "header") {
40 } else if (state.state == "header") {
41 stream.skipToEnd();
41 stream.skipToEnd();
42 state.state = "headers";
42 state.state = "headers";
43 return "string";
43 return "string";
44 } else if (state.state == "body") {
44 } else if (state.state == "body") {
45 if (stream.sol() && (m = stream.match(/^-----END (.*)?-----\s*$/))) {
45 if (stream.sol() && (m = stream.match(/^-----END (.*)?-----\s*$/))) {
46 if (m[1] != state.type) return "error";
46 if (m[1] != state.type) return "error";
47 state.state = "end";
47 state.state = "end";
48 return "tag";
48 return "tag";
49 } else {
49 } else {
50 if (stream.eatWhile(/[A-Za-z0-9+\/=]/)) {
50 if (stream.eatWhile(/[A-Za-z0-9+\/=]/)) {
51 return null;
51 return null;
52 } else {
52 } else {
53 stream.next();
53 stream.next();
54 return "error";
54 return "error";
55 }
55 }
56 }
56 }
57 } else if (state.state == "end") {
57 } else if (state.state == "end") {
58 return errorIfNotEmpty(stream);
58 return errorIfNotEmpty(stream);
59 }
59 }
60 },
60 },
61 blankLine: function(state) {
61 blankLine: function(state) {
62 if (state.state == "headers") state.state = "body";
62 if (state.state == "headers") state.state = "body";
63 },
63 },
64 startState: function() {
64 startState: function() {
65 return {state: "top", type: null};
65 return {state: "top", type: null};
66 }
66 }
67 };
67 };
68 });
68 });
69
69
70 CodeMirror.defineMIME("application/pgp", "asciiarmor");
70 CodeMirror.defineMIME("application/pgp", "asciiarmor");
71 CodeMirror.defineMIME("application/pgp-encrypted", "asciiarmor");
71 CodeMirror.defineMIME("application/pgp-keys", "asciiarmor");
72 CodeMirror.defineMIME("application/pgp-keys", "asciiarmor");
72 CodeMirror.defineMIME("application/pgp-signature", "asciiarmor");
73 CodeMirror.defineMIME("application/pgp-signature", "asciiarmor");
73 });
74 });
@@ -1,204 +1,204 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("asn.1", function(config, parserConfig) {
14 CodeMirror.defineMode("asn.1", function(config, parserConfig) {
15 var indentUnit = config.indentUnit,
15 var indentUnit = config.indentUnit,
16 keywords = parserConfig.keywords || {},
16 keywords = parserConfig.keywords || {},
17 cmipVerbs = parserConfig.cmipVerbs || {},
17 cmipVerbs = parserConfig.cmipVerbs || {},
18 compareTypes = parserConfig.compareTypes || {},
18 compareTypes = parserConfig.compareTypes || {},
19 status = parserConfig.status || {},
19 status = parserConfig.status || {},
20 tags = parserConfig.tags || {},
20 tags = parserConfig.tags || {},
21 storage = parserConfig.storage || {},
21 storage = parserConfig.storage || {},
22 modifier = parserConfig.modifier || {},
22 modifier = parserConfig.modifier || {},
23 accessTypes = parserConfig.accessTypes|| {},
23 accessTypes = parserConfig.accessTypes|| {},
24 multiLineStrings = parserConfig.multiLineStrings,
24 multiLineStrings = parserConfig.multiLineStrings,
25 indentStatements = parserConfig.indentStatements !== false;
25 indentStatements = parserConfig.indentStatements !== false;
26 var isOperatorChar = /[\|\^]/;
26 var isOperatorChar = /[\|\^]/;
27 var curPunc;
27 var curPunc;
28
28
29 function tokenBase(stream, state) {
29 function tokenBase(stream, state) {
30 var ch = stream.next();
30 var ch = stream.next();
31 if (ch == '"' || ch == "'") {
31 if (ch == '"' || ch == "'") {
32 state.tokenize = tokenString(ch);
32 state.tokenize = tokenString(ch);
33 return state.tokenize(stream, state);
33 return state.tokenize(stream, state);
34 }
34 }
35 if (/[\[\]\(\){}:=,;]/.test(ch)) {
35 if (/[\[\]\(\){}:=,;]/.test(ch)) {
36 curPunc = ch;
36 curPunc = ch;
37 return "punctuation";
37 return "punctuation";
38 }
38 }
39 if (ch == "-"){
39 if (ch == "-"){
40 if (stream.eat("-")) {
40 if (stream.eat("-")) {
41 stream.skipToEnd();
41 stream.skipToEnd();
42 return "comment";
42 return "comment";
43 }
43 }
44 }
44 }
45 if (/\d/.test(ch)) {
45 if (/\d/.test(ch)) {
46 stream.eatWhile(/[\w\.]/);
46 stream.eatWhile(/[\w\.]/);
47 return "number";
47 return "number";
48 }
48 }
49 if (isOperatorChar.test(ch)) {
49 if (isOperatorChar.test(ch)) {
50 stream.eatWhile(isOperatorChar);
50 stream.eatWhile(isOperatorChar);
51 return "operator";
51 return "operator";
52 }
52 }
53
53
54 stream.eatWhile(/[\w\-]/);
54 stream.eatWhile(/[\w\-]/);
55 var cur = stream.current();
55 var cur = stream.current();
56 if (keywords.propertyIsEnumerable(cur)) return "keyword";
56 if (keywords.propertyIsEnumerable(cur)) return "keyword";
57 if (cmipVerbs.propertyIsEnumerable(cur)) return "variable cmipVerbs";
57 if (cmipVerbs.propertyIsEnumerable(cur)) return "variable cmipVerbs";
58 if (compareTypes.propertyIsEnumerable(cur)) return "atom compareTypes";
58 if (compareTypes.propertyIsEnumerable(cur)) return "atom compareTypes";
59 if (status.propertyIsEnumerable(cur)) return "comment status";
59 if (status.propertyIsEnumerable(cur)) return "comment status";
60 if (tags.propertyIsEnumerable(cur)) return "variable-3 tags";
60 if (tags.propertyIsEnumerable(cur)) return "variable-3 tags";
61 if (storage.propertyIsEnumerable(cur)) return "builtin storage";
61 if (storage.propertyIsEnumerable(cur)) return "builtin storage";
62 if (modifier.propertyIsEnumerable(cur)) return "string-2 modifier";
62 if (modifier.propertyIsEnumerable(cur)) return "string-2 modifier";
63 if (accessTypes.propertyIsEnumerable(cur)) return "atom accessTypes";
63 if (accessTypes.propertyIsEnumerable(cur)) return "atom accessTypes";
64
64
65 return "variable";
65 return "variable";
66 }
66 }
67
67
68 function tokenString(quote) {
68 function tokenString(quote) {
69 return function(stream, state) {
69 return function(stream, state) {
70 var escaped = false, next, end = false;
70 var escaped = false, next, end = false;
71 while ((next = stream.next()) != null) {
71 while ((next = stream.next()) != null) {
72 if (next == quote && !escaped){
72 if (next == quote && !escaped){
73 var afterNext = stream.peek();
73 var afterNext = stream.peek();
74 //look if the character if the quote is like the B in '10100010'B
74 //look if the character if the quote is like the B in '10100010'B
75 if (afterNext){
75 if (afterNext){
76 afterNext = afterNext.toLowerCase();
76 afterNext = afterNext.toLowerCase();
77 if(afterNext == "b" || afterNext == "h" || afterNext == "o")
77 if(afterNext == "b" || afterNext == "h" || afterNext == "o")
78 stream.next();
78 stream.next();
79 }
79 }
80 end = true; break;
80 end = true; break;
81 }
81 }
82 escaped = !escaped && next == "\\";
82 escaped = !escaped && next == "\\";
83 }
83 }
84 if (end || !(escaped || multiLineStrings))
84 if (end || !(escaped || multiLineStrings))
85 state.tokenize = null;
85 state.tokenize = null;
86 return "string";
86 return "string";
87 };
87 };
88 }
88 }
89
89
90 function Context(indented, column, type, align, prev) {
90 function Context(indented, column, type, align, prev) {
91 this.indented = indented;
91 this.indented = indented;
92 this.column = column;
92 this.column = column;
93 this.type = type;
93 this.type = type;
94 this.align = align;
94 this.align = align;
95 this.prev = prev;
95 this.prev = prev;
96 }
96 }
97 function pushContext(state, col, type) {
97 function pushContext(state, col, type) {
98 var indent = state.indented;
98 var indent = state.indented;
99 if (state.context && state.context.type == "statement")
99 if (state.context && state.context.type == "statement")
100 indent = state.context.indented;
100 indent = state.context.indented;
101 return state.context = new Context(indent, col, type, null, state.context);
101 return state.context = new Context(indent, col, type, null, state.context);
102 }
102 }
103 function popContext(state) {
103 function popContext(state) {
104 var t = state.context.type;
104 var t = state.context.type;
105 if (t == ")" || t == "]" || t == "}")
105 if (t == ")" || t == "]" || t == "}")
106 state.indented = state.context.indented;
106 state.indented = state.context.indented;
107 return state.context = state.context.prev;
107 return state.context = state.context.prev;
108 }
108 }
109
109
110 //Interface
110 //Interface
111 return {
111 return {
112 startState: function(basecolumn) {
112 startState: function(basecolumn) {
113 return {
113 return {
114 tokenize: null,
114 tokenize: null,
115 context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
115 context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
116 indented: 0,
116 indented: 0,
117 startOfLine: true
117 startOfLine: true
118 };
118 };
119 },
119 },
120
120
121 token: function(stream, state) {
121 token: function(stream, state) {
122 var ctx = state.context;
122 var ctx = state.context;
123 if (stream.sol()) {
123 if (stream.sol()) {
124 if (ctx.align == null) ctx.align = false;
124 if (ctx.align == null) ctx.align = false;
125 state.indented = stream.indentation();
125 state.indented = stream.indentation();
126 state.startOfLine = true;
126 state.startOfLine = true;
127 }
127 }
128 if (stream.eatSpace()) return null;
128 if (stream.eatSpace()) return null;
129 curPunc = null;
129 curPunc = null;
130 var style = (state.tokenize || tokenBase)(stream, state);
130 var style = (state.tokenize || tokenBase)(stream, state);
131 if (style == "comment") return style;
131 if (style == "comment") return style;
132 if (ctx.align == null) ctx.align = true;
132 if (ctx.align == null) ctx.align = true;
133
133
134 if ((curPunc == ";" || curPunc == ":" || curPunc == ",")
134 if ((curPunc == ";" || curPunc == ":" || curPunc == ",")
135 && ctx.type == "statement"){
135 && ctx.type == "statement"){
136 popContext(state);
136 popContext(state);
137 }
137 }
138 else if (curPunc == "{") pushContext(state, stream.column(), "}");
138 else if (curPunc == "{") pushContext(state, stream.column(), "}");
139 else if (curPunc == "[") pushContext(state, stream.column(), "]");
139 else if (curPunc == "[") pushContext(state, stream.column(), "]");
140 else if (curPunc == "(") pushContext(state, stream.column(), ")");
140 else if (curPunc == "(") pushContext(state, stream.column(), ")");
141 else if (curPunc == "}") {
141 else if (curPunc == "}") {
142 while (ctx.type == "statement") ctx = popContext(state);
142 while (ctx.type == "statement") ctx = popContext(state);
143 if (ctx.type == "}") ctx = popContext(state);
143 if (ctx.type == "}") ctx = popContext(state);
144 while (ctx.type == "statement") ctx = popContext(state);
144 while (ctx.type == "statement") ctx = popContext(state);
145 }
145 }
146 else if (curPunc == ctx.type) popContext(state);
146 else if (curPunc == ctx.type) popContext(state);
147 else if (indentStatements && (((ctx.type == "}" || ctx.type == "top")
147 else if (indentStatements && (((ctx.type == "}" || ctx.type == "top")
148 && curPunc != ';') || (ctx.type == "statement"
148 && curPunc != ';') || (ctx.type == "statement"
149 && curPunc == "newstatement")))
149 && curPunc == "newstatement")))
150 pushContext(state, stream.column(), "statement");
150 pushContext(state, stream.column(), "statement");
151
151
152 state.startOfLine = false;
152 state.startOfLine = false;
153 return style;
153 return style;
154 },
154 },
155
155
156 electricChars: "{}",
156 electricChars: "{}",
157 lineComment: "--",
157 lineComment: "--",
158 fold: "brace"
158 fold: "brace"
159 };
159 };
160 });
160 });
161
161
162 function words(str) {
162 function words(str) {
163 var obj = {}, words = str.split(" ");
163 var obj = {}, words = str.split(" ");
164 for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
164 for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
165 return obj;
165 return obj;
166 }
166 }
167
167
168 CodeMirror.defineMIME("text/x-ttcn-asn", {
168 CodeMirror.defineMIME("text/x-ttcn-asn", {
169 name: "asn.1",
169 name: "asn.1",
170 keywords: words("DEFINITIONS OBJECTS IF DERIVED INFORMATION ACTION" +
170 keywords: words("DEFINITIONS OBJECTS IF DERIVED INFORMATION ACTION" +
171 " REPLY ANY NAMED CHARACTERIZED BEHAVIOUR REGISTERED" +
171 " REPLY ANY NAMED CHARACTERIZED BEHAVIOUR REGISTERED" +
172 " WITH AS IDENTIFIED CONSTRAINED BY PRESENT BEGIN" +
172 " WITH AS IDENTIFIED CONSTRAINED BY PRESENT BEGIN" +
173 " IMPORTS FROM UNITS SYNTAX MIN-ACCESS MAX-ACCESS" +
173 " IMPORTS FROM UNITS SYNTAX MIN-ACCESS MAX-ACCESS" +
174 " MINACCESS MAXACCESS REVISION STATUS DESCRIPTION" +
174 " MINACCESS MAXACCESS REVISION STATUS DESCRIPTION" +
175 " SEQUENCE SET COMPONENTS OF CHOICE DistinguishedName" +
175 " SEQUENCE SET COMPONENTS OF CHOICE DistinguishedName" +
176 " ENUMERATED SIZE MODULE END INDEX AUGMENTS EXTENSIBILITY" +
176 " ENUMERATED SIZE MODULE END INDEX AUGMENTS EXTENSIBILITY" +
177 " IMPLIED EXPORTS"),
177 " IMPLIED EXPORTS"),
178 cmipVerbs: words("ACTIONS ADD GET NOTIFICATIONS REPLACE REMOVE"),
178 cmipVerbs: words("ACTIONS ADD GET NOTIFICATIONS REPLACE REMOVE"),
179 compareTypes: words("OPTIONAL DEFAULT MANAGED MODULE-TYPE MODULE_IDENTITY" +
179 compareTypes: words("OPTIONAL DEFAULT MANAGED MODULE-TYPE MODULE_IDENTITY" +
180 " MODULE-COMPLIANCE OBJECT-TYPE OBJECT-IDENTITY" +
180 " MODULE-COMPLIANCE OBJECT-TYPE OBJECT-IDENTITY" +
181 " OBJECT-COMPLIANCE MODE CONFIRMED CONDITIONAL" +
181 " OBJECT-COMPLIANCE MODE CONFIRMED CONDITIONAL" +
182 " SUBORDINATE SUPERIOR CLASS TRUE FALSE NULL" +
182 " SUBORDINATE SUPERIOR CLASS TRUE FALSE NULL" +
183 " TEXTUAL-CONVENTION"),
183 " TEXTUAL-CONVENTION"),
184 status: words("current deprecated mandatory obsolete"),
184 status: words("current deprecated mandatory obsolete"),
185 tags: words("APPLICATION AUTOMATIC EXPLICIT IMPLICIT PRIVATE TAGS" +
185 tags: words("APPLICATION AUTOMATIC EXPLICIT IMPLICIT PRIVATE TAGS" +
186 " UNIVERSAL"),
186 " UNIVERSAL"),
187 storage: words("BOOLEAN INTEGER OBJECT IDENTIFIER BIT OCTET STRING" +
187 storage: words("BOOLEAN INTEGER OBJECT IDENTIFIER BIT OCTET STRING" +
188 " UTCTime InterfaceIndex IANAifType CMIP-Attribute" +
188 " UTCTime InterfaceIndex IANAifType CMIP-Attribute" +
189 " REAL PACKAGE PACKAGES IpAddress PhysAddress" +
189 " REAL PACKAGE PACKAGES IpAddress PhysAddress" +
190 " NetworkAddress BITS BMPString TimeStamp TimeTicks" +
190 " NetworkAddress BITS BMPString TimeStamp TimeTicks" +
191 " TruthValue RowStatus DisplayString GeneralString" +
191 " TruthValue RowStatus DisplayString GeneralString" +
192 " GraphicString IA5String NumericString" +
192 " GraphicString IA5String NumericString" +
193 " PrintableString SnmpAdminAtring TeletexString" +
193 " PrintableString SnmpAdminAtring TeletexString" +
194 " UTF8String VideotexString VisibleString StringStore" +
194 " UTF8String VideotexString VisibleString StringStore" +
195 " ISO646String T61String UniversalString Unsigned32" +
195 " ISO646String T61String UniversalString Unsigned32" +
196 " Integer32 Gauge Gauge32 Counter Counter32 Counter64"),
196 " Integer32 Gauge Gauge32 Counter Counter32 Counter64"),
197 modifier: words("ATTRIBUTE ATTRIBUTES MANDATORY-GROUP MANDATORY-GROUPS" +
197 modifier: words("ATTRIBUTE ATTRIBUTES MANDATORY-GROUP MANDATORY-GROUPS" +
198 " GROUP GROUPS ELEMENTS EQUALITY ORDERING SUBSTRINGS" +
198 " GROUP GROUPS ELEMENTS EQUALITY ORDERING SUBSTRINGS" +
199 " DEFINED"),
199 " DEFINED"),
200 accessTypes: words("not-accessible accessible-for-notify read-only" +
200 accessTypes: words("not-accessible accessible-for-notify read-only" +
201 " read-create read-write"),
201 " read-create read-write"),
202 multiLineStrings: true
202 multiLineStrings: true
203 });
203 });
204 });
204 });
@@ -1,196 +1,220 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 /*
4 /*
5 * =====================================================================================
5 * =====================================================================================
6 *
6 *
7 * Filename: mode/asterisk/asterisk.js
7 * Filename: mode/asterisk/asterisk.js
8 *
8 *
9 * Description: CodeMirror mode for Asterisk dialplan
9 * Description: CodeMirror mode for Asterisk dialplan
10 *
10 *
11 * Created: 05/17/2012 09:20:25 PM
11 * Created: 05/17/2012 09:20:25 PM
12 * Revision: none
12 * Revision: 08/05/2019 AstLinux Project: Support block-comments
13 *
13 *
14 * Author: Stas Kobzar (stas@modulis.ca),
14 * Author: Stas Kobzar (stas@modulis.ca),
15 * Company: Modulis.ca Inc.
15 * Company: Modulis.ca Inc.
16 *
16 *
17 * =====================================================================================
17 * =====================================================================================
18 */
18 */
19
19
20 (function(mod) {
20 (function(mod) {
21 if (typeof exports == "object" && typeof module == "object") // CommonJS
21 if (typeof exports == "object" && typeof module == "object") // CommonJS
22 mod(require("../../lib/codemirror"));
22 mod(require("../../lib/codemirror"));
23 else if (typeof define == "function" && define.amd) // AMD
23 else if (typeof define == "function" && define.amd) // AMD
24 define(["../../lib/codemirror"], mod);
24 define(["../../lib/codemirror"], mod);
25 else // Plain browser env
25 else // Plain browser env
26 mod(CodeMirror);
26 mod(CodeMirror);
27 })(function(CodeMirror) {
27 })(function(CodeMirror) {
28 "use strict";
28 "use strict";
29
29
30 CodeMirror.defineMode("asterisk", function() {
30 CodeMirror.defineMode("asterisk", function() {
31 var atoms = ["exten", "same", "include","ignorepat","switch"],
31 var atoms = ["exten", "same", "include","ignorepat","switch"],
32 dpcmd = ["#include","#exec"],
32 dpcmd = ["#include","#exec"],
33 apps = [
33 apps = [
34 "addqueuemember","adsiprog","aelsub","agentlogin","agentmonitoroutgoing","agi",
34 "addqueuemember","adsiprog","aelsub","agentlogin","agentmonitoroutgoing","agi",
35 "alarmreceiver","amd","answer","authenticate","background","backgrounddetect",
35 "alarmreceiver","amd","answer","authenticate","background","backgrounddetect",
36 "bridge","busy","callcompletioncancel","callcompletionrequest","celgenuserevent",
36 "bridge","busy","callcompletioncancel","callcompletionrequest","celgenuserevent",
37 "changemonitor","chanisavail","channelredirect","chanspy","clearhash","confbridge",
37 "changemonitor","chanisavail","channelredirect","chanspy","clearhash","confbridge",
38 "congestion","continuewhile","controlplayback","dahdiacceptr2call","dahdibarge",
38 "congestion","continuewhile","controlplayback","dahdiacceptr2call","dahdibarge",
39 "dahdiras","dahdiscan","dahdisendcallreroutingfacility","dahdisendkeypadfacility",
39 "dahdiras","dahdiscan","dahdisendcallreroutingfacility","dahdisendkeypadfacility",
40 "datetime","dbdel","dbdeltree","deadagi","dial","dictate","directory","disa",
40 "datetime","dbdel","dbdeltree","deadagi","dial","dictate","directory","disa",
41 "dumpchan","eagi","echo","endwhile","exec","execif","execiftime","exitwhile","extenspy",
41 "dumpchan","eagi","echo","endwhile","exec","execif","execiftime","exitwhile","extenspy",
42 "externalivr","festival","flash","followme","forkcdr","getcpeid","gosub","gosubif",
42 "externalivr","festival","flash","followme","forkcdr","getcpeid","gosub","gosubif",
43 "goto","gotoif","gotoiftime","hangup","iax2provision","ices","importvar","incomplete",
43 "goto","gotoif","gotoiftime","hangup","iax2provision","ices","importvar","incomplete",
44 "ivrdemo","jabberjoin","jabberleave","jabbersend","jabbersendgroup","jabberstatus",
44 "ivrdemo","jabberjoin","jabberleave","jabbersend","jabbersendgroup","jabberstatus",
45 "jack","log","macro","macroexclusive","macroexit","macroif","mailboxexists","meetme",
45 "jack","log","macro","macroexclusive","macroexit","macroif","mailboxexists","meetme",
46 "meetmeadmin","meetmechanneladmin","meetmecount","milliwatt","minivmaccmess","minivmdelete",
46 "meetmeadmin","meetmechanneladmin","meetmecount","milliwatt","minivmaccmess","minivmdelete",
47 "minivmgreet","minivmmwi","minivmnotify","minivmrecord","mixmonitor","monitor","morsecode",
47 "minivmgreet","minivmmwi","minivmnotify","minivmrecord","mixmonitor","monitor","morsecode",
48 "mp3player","mset","musiconhold","nbscat","nocdr","noop","odbc","odbc","odbcfinish",
48 "mp3player","mset","musiconhold","nbscat","nocdr","noop","odbc","odbc","odbcfinish",
49 "originate","ospauth","ospfinish","osplookup","ospnext","page","park","parkandannounce",
49 "originate","ospauth","ospfinish","osplookup","ospnext","page","park","parkandannounce",
50 "parkedcall","pausemonitor","pausequeuemember","pickup","pickupchan","playback","playtones",
50 "parkedcall","pausemonitor","pausequeuemember","pickup","pickupchan","playback","playtones",
51 "privacymanager","proceeding","progress","queue","queuelog","raiseexception","read","readexten",
51 "privacymanager","proceeding","progress","queue","queuelog","raiseexception","read","readexten",
52 "readfile","receivefax","receivefax","receivefax","record","removequeuemember",
52 "readfile","receivefax","receivefax","receivefax","record","removequeuemember",
53 "resetcdr","retrydial","return","ringing","sayalpha","saycountedadj","saycountednoun",
53 "resetcdr","retrydial","return","ringing","sayalpha","saycountedadj","saycountednoun",
54 "saycountpl","saydigits","saynumber","sayphonetic","sayunixtime","senddtmf","sendfax",
54 "saycountpl","saydigits","saynumber","sayphonetic","sayunixtime","senddtmf","sendfax",
55 "sendfax","sendfax","sendimage","sendtext","sendurl","set","setamaflags",
55 "sendfax","sendfax","sendimage","sendtext","sendurl","set","setamaflags",
56 "setcallerpres","setmusiconhold","sipaddheader","sipdtmfmode","sipremoveheader","skel",
56 "setcallerpres","setmusiconhold","sipaddheader","sipdtmfmode","sipremoveheader","skel",
57 "slastation","slatrunk","sms","softhangup","speechactivategrammar","speechbackground",
57 "slastation","slatrunk","sms","softhangup","speechactivategrammar","speechbackground",
58 "speechcreate","speechdeactivategrammar","speechdestroy","speechloadgrammar","speechprocessingsound",
58 "speechcreate","speechdeactivategrammar","speechdestroy","speechloadgrammar","speechprocessingsound",
59 "speechstart","speechunloadgrammar","stackpop","startmusiconhold","stopmixmonitor","stopmonitor",
59 "speechstart","speechunloadgrammar","stackpop","startmusiconhold","stopmixmonitor","stopmonitor",
60 "stopmusiconhold","stopplaytones","system","testclient","testserver","transfer","tryexec",
60 "stopmusiconhold","stopplaytones","system","testclient","testserver","transfer","tryexec",
61 "trysystem","unpausemonitor","unpausequeuemember","userevent","verbose","vmauthenticate",
61 "trysystem","unpausemonitor","unpausequeuemember","userevent","verbose","vmauthenticate",
62 "vmsayname","voicemail","voicemailmain","wait","waitexten","waitfornoise","waitforring",
62 "vmsayname","voicemail","voicemailmain","wait","waitexten","waitfornoise","waitforring",
63 "waitforsilence","waitmusiconhold","waituntil","while","zapateller"
63 "waitforsilence","waitmusiconhold","waituntil","while","zapateller"
64 ];
64 ];
65
65
66 function basicToken(stream,state){
66 function basicToken(stream,state){
67 var cur = '';
67 var cur = '';
68 var ch = stream.next();
68 var ch = stream.next();
69 // comment
69 // comment
70 if (state.blockComment) {
71 if (ch == "-" && stream.match("-;", true)) {
72 state.blockComment = false;
73 } else if (stream.skipTo("--;")) {
74 stream.next();
75 stream.next();
76 stream.next();
77 state.blockComment = false;
78 } else {
79 stream.skipToEnd();
80 }
81 return "comment";
82 }
70 if(ch == ";") {
83 if(ch == ";") {
84 if (stream.match("--", true)) {
85 if (!stream.match("-", false)) { // Except ;--- is not a block comment
86 state.blockComment = true;
87 return "comment";
88 }
89 }
71 stream.skipToEnd();
90 stream.skipToEnd();
72 return "comment";
91 return "comment";
73 }
92 }
74 // context
93 // context
75 if(ch == '[') {
94 if(ch == '[') {
76 stream.skipTo(']');
95 stream.skipTo(']');
77 stream.eat(']');
96 stream.eat(']');
78 return "header";
97 return "header";
79 }
98 }
80 // string
99 // string
81 if(ch == '"') {
100 if(ch == '"') {
82 stream.skipTo('"');
101 stream.skipTo('"');
83 return "string";
102 return "string";
84 }
103 }
85 if(ch == "'") {
104 if(ch == "'") {
86 stream.skipTo("'");
105 stream.skipTo("'");
87 return "string-2";
106 return "string-2";
88 }
107 }
89 // dialplan commands
108 // dialplan commands
90 if(ch == '#') {
109 if(ch == '#') {
91 stream.eatWhile(/\w/);
110 stream.eatWhile(/\w/);
92 cur = stream.current();
111 cur = stream.current();
93 if(dpcmd.indexOf(cur) !== -1) {
112 if(dpcmd.indexOf(cur) !== -1) {
94 stream.skipToEnd();
113 stream.skipToEnd();
95 return "strong";
114 return "strong";
96 }
115 }
97 }
116 }
98 // application args
117 // application args
99 if(ch == '$'){
118 if(ch == '$'){
100 var ch1 = stream.peek();
119 var ch1 = stream.peek();
101 if(ch1 == '{'){
120 if(ch1 == '{'){
102 stream.skipTo('}');
121 stream.skipTo('}');
103 stream.eat('}');
122 stream.eat('}');
104 return "variable-3";
123 return "variable-3";
105 }
124 }
106 }
125 }
107 // extension
126 // extension
108 stream.eatWhile(/\w/);
127 stream.eatWhile(/\w/);
109 cur = stream.current();
128 cur = stream.current();
110 if(atoms.indexOf(cur) !== -1) {
129 if(atoms.indexOf(cur) !== -1) {
111 state.extenStart = true;
130 state.extenStart = true;
112 switch(cur) {
131 switch(cur) {
113 case 'same': state.extenSame = true; break;
132 case 'same': state.extenSame = true; break;
114 case 'include':
133 case 'include':
115 case 'switch':
134 case 'switch':
116 case 'ignorepat':
135 case 'ignorepat':
117 state.extenInclude = true;break;
136 state.extenInclude = true;break;
118 default:break;
137 default:break;
119 }
138 }
120 return "atom";
139 return "atom";
121 }
140 }
122 }
141 }
123
142
124 return {
143 return {
125 startState: function() {
144 startState: function() {
126 return {
145 return {
146 blockComment: false,
127 extenStart: false,
147 extenStart: false,
128 extenSame: false,
148 extenSame: false,
129 extenInclude: false,
149 extenInclude: false,
130 extenExten: false,
150 extenExten: false,
131 extenPriority: false,
151 extenPriority: false,
132 extenApplication: false
152 extenApplication: false
133 };
153 };
134 },
154 },
135 token: function(stream, state) {
155 token: function(stream, state) {
136
156
137 var cur = '';
157 var cur = '';
138 if(stream.eatSpace()) return null;
158 if(stream.eatSpace()) return null;
139 // extension started
159 // extension started
140 if(state.extenStart){
160 if(state.extenStart){
141 stream.eatWhile(/[^\s]/);
161 stream.eatWhile(/[^\s]/);
142 cur = stream.current();
162 cur = stream.current();
143 if(/^=>?$/.test(cur)){
163 if(/^=>?$/.test(cur)){
144 state.extenExten = true;
164 state.extenExten = true;
145 state.extenStart = false;
165 state.extenStart = false;
146 return "strong";
166 return "strong";
147 } else {
167 } else {
148 state.extenStart = false;
168 state.extenStart = false;
149 stream.skipToEnd();
169 stream.skipToEnd();
150 return "error";
170 return "error";
151 }
171 }
152 } else if(state.extenExten) {
172 } else if(state.extenExten) {
153 // set exten and priority
173 // set exten and priority
154 state.extenExten = false;
174 state.extenExten = false;
155 state.extenPriority = true;
175 state.extenPriority = true;
156 stream.eatWhile(/[^,]/);
176 stream.eatWhile(/[^,]/);
157 if(state.extenInclude) {
177 if(state.extenInclude) {
158 stream.skipToEnd();
178 stream.skipToEnd();
159 state.extenPriority = false;
179 state.extenPriority = false;
160 state.extenInclude = false;
180 state.extenInclude = false;
161 }
181 }
162 if(state.extenSame) {
182 if(state.extenSame) {
163 state.extenPriority = false;
183 state.extenPriority = false;
164 state.extenSame = false;
184 state.extenSame = false;
165 state.extenApplication = true;
185 state.extenApplication = true;
166 }
186 }
167 return "tag";
187 return "tag";
168 } else if(state.extenPriority) {
188 } else if(state.extenPriority) {
169 state.extenPriority = false;
189 state.extenPriority = false;
170 state.extenApplication = true;
190 state.extenApplication = true;
171 stream.next(); // get comma
191 stream.next(); // get comma
172 if(state.extenSame) return null;
192 if(state.extenSame) return null;
173 stream.eatWhile(/[^,]/);
193 stream.eatWhile(/[^,]/);
174 return "number";
194 return "number";
175 } else if(state.extenApplication) {
195 } else if(state.extenApplication) {
176 stream.eatWhile(/,/);
196 stream.eatWhile(/,/);
177 cur = stream.current();
197 cur = stream.current();
178 if(cur === ',') return null;
198 if(cur === ',') return null;
179 stream.eatWhile(/\w/);
199 stream.eatWhile(/\w/);
180 cur = stream.current().toLowerCase();
200 cur = stream.current().toLowerCase();
181 state.extenApplication = false;
201 state.extenApplication = false;
182 if(apps.indexOf(cur) !== -1){
202 if(apps.indexOf(cur) !== -1){
183 return "def strong";
203 return "def strong";
184 }
204 }
185 } else{
205 } else{
186 return basicToken(stream,state);
206 return basicToken(stream,state);
187 }
207 }
188
208
189 return null;
209 return null;
190 }
210 },
211
212 blockCommentStart: ";--",
213 blockCommentEnd: "--;",
214 lineComment: ";"
191 };
215 };
192 });
216 });
193
217
194 CodeMirror.defineMIME("text/x-asterisk", "asterisk");
218 CodeMirror.defineMIME("text/x-asterisk", "asterisk");
195
219
196 });
220 });
@@ -1,85 +1,85 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 // Brainfuck mode created by Michael Kaminsky https://github.com/mkaminsky11
4 // Brainfuck mode created by Michael Kaminsky https://github.com/mkaminsky11
5
5
6 (function(mod) {
6 (function(mod) {
7 if (typeof exports == "object" && typeof module == "object")
7 if (typeof exports == "object" && typeof module == "object")
8 mod(require("../../lib/codemirror"))
8 mod(require("../../lib/codemirror"))
9 else if (typeof define == "function" && define.amd)
9 else if (typeof define == "function" && define.amd)
10 define(["../../lib/codemirror"], mod)
10 define(["../../lib/codemirror"], mod)
11 else
11 else
12 mod(CodeMirror)
12 mod(CodeMirror)
13 })(function(CodeMirror) {
13 })(function(CodeMirror) {
14 "use strict"
14 "use strict"
15 var reserve = "><+-.,[]".split("");
15 var reserve = "><+-.,[]".split("");
16 /*
16 /*
17 comments can be either:
17 comments can be either:
18 placed behind lines
18 placed behind lines
19
19
20 +++ this is a comment
20 +++ this is a comment
21
21
22 where reserved characters cannot be used
22 where reserved characters cannot be used
23 or in a loop
23 or in a loop
24 [
24 [
25 this is ok to use [ ] and stuff
25 this is ok to use [ ] and stuff
26 ]
26 ]
27 or preceded by #
27 or preceded by #
28 */
28 */
29 CodeMirror.defineMode("brainfuck", function() {
29 CodeMirror.defineMode("brainfuck", function() {
30 return {
30 return {
31 startState: function() {
31 startState: function() {
32 return {
32 return {
33 commentLine: false,
33 commentLine: false,
34 left: 0,
34 left: 0,
35 right: 0,
35 right: 0,
36 commentLoop: false
36 commentLoop: false
37 }
37 }
38 },
38 },
39 token: function(stream, state) {
39 token: function(stream, state) {
40 if (stream.eatSpace()) return null
40 if (stream.eatSpace()) return null
41 if(stream.sol()){
41 if(stream.sol()){
42 state.commentLine = false;
42 state.commentLine = false;
43 }
43 }
44 var ch = stream.next().toString();
44 var ch = stream.next().toString();
45 if(reserve.indexOf(ch) !== -1){
45 if(reserve.indexOf(ch) !== -1){
46 if(state.commentLine === true){
46 if(state.commentLine === true){
47 if(stream.eol()){
47 if(stream.eol()){
48 state.commentLine = false;
48 state.commentLine = false;
49 }
49 }
50 return "comment";
50 return "comment";
51 }
51 }
52 if(ch === "]" || ch === "["){
52 if(ch === "]" || ch === "["){
53 if(ch === "["){
53 if(ch === "["){
54 state.left++;
54 state.left++;
55 }
55 }
56 else{
56 else{
57 state.right++;
57 state.right++;
58 }
58 }
59 return "bracket";
59 return "bracket";
60 }
60 }
61 else if(ch === "+" || ch === "-"){
61 else if(ch === "+" || ch === "-"){
62 return "keyword";
62 return "keyword";
63 }
63 }
64 else if(ch === "<" || ch === ">"){
64 else if(ch === "<" || ch === ">"){
65 return "atom";
65 return "atom";
66 }
66 }
67 else if(ch === "." || ch === ","){
67 else if(ch === "." || ch === ","){
68 return "def";
68 return "def";
69 }
69 }
70 }
70 }
71 else{
71 else{
72 state.commentLine = true;
72 state.commentLine = true;
73 if(stream.eol()){
73 if(stream.eol()){
74 state.commentLine = false;
74 state.commentLine = false;
75 }
75 }
76 return "comment";
76 return "comment";
77 }
77 }
78 if(stream.eol()){
78 if(stream.eol()){
79 state.commentLine = false;
79 state.commentLine = false;
80 }
80 }
81 }
81 }
82 };
82 };
83 });
83 });
84 CodeMirror.defineMIME("text/x-brainfuck","brainfuck")
84 CodeMirror.defineMIME("text/x-brainfuck","brainfuck")
85 });
85 });
@@ -1,772 +1,935 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 function Context(indented, column, type, info, align, prev) {
15 this.indented = indented;
16 this.column = column;
17 this.type = type;
18 this.info = info;
19 this.align = align;
20 this.prev = prev;
21 }
22 function pushContext(state, col, type, info) {
23 var indent = state.indented;
24 if (state.context && state.context.type == "statement" && type != "statement")
25 indent = state.context.indented;
26 return state.context = new Context(indent, col, type, info, null, state.context);
27 }
28 function popContext(state) {
29 var t = state.context.type;
30 if (t == ")" || t == "]" || t == "}")
31 state.indented = state.context.indented;
32 return state.context = state.context.prev;
33 }
34
35 function typeBefore(stream, state, pos) {
36 if (state.prevToken == "variable" || state.prevToken == "type") return true;
37 if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, pos))) return true;
38 if (state.typeAtEndOfLine && stream.column() == stream.indentation()) return true;
39 }
40
41 function isTopScope(context) {
42 for (;;) {
43 if (!context || context.type == "top") return true;
44 if (context.type == "}" && context.prev.info != "namespace") return false;
45 context = context.prev;
46 }
47 }
48
14 CodeMirror.defineMode("clike", function(config, parserConfig) {
49 CodeMirror.defineMode("clike", function(config, parserConfig) {
15 var indentUnit = config.indentUnit,
50 var indentUnit = config.indentUnit,
16 statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
51 statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
17 dontAlignCalls = parserConfig.dontAlignCalls,
52 dontAlignCalls = parserConfig.dontAlignCalls,
18 keywords = parserConfig.keywords || {},
53 keywords = parserConfig.keywords || {},
19 types = parserConfig.types || {},
54 types = parserConfig.types || {},
20 builtin = parserConfig.builtin || {},
55 builtin = parserConfig.builtin || {},
21 blockKeywords = parserConfig.blockKeywords || {},
56 blockKeywords = parserConfig.blockKeywords || {},
22 defKeywords = parserConfig.defKeywords || {},
57 defKeywords = parserConfig.defKeywords || {},
23 atoms = parserConfig.atoms || {},
58 atoms = parserConfig.atoms || {},
24 hooks = parserConfig.hooks || {},
59 hooks = parserConfig.hooks || {},
25 multiLineStrings = parserConfig.multiLineStrings,
60 multiLineStrings = parserConfig.multiLineStrings,
26 indentStatements = parserConfig.indentStatements !== false,
61 indentStatements = parserConfig.indentStatements !== false,
27 indentSwitch = parserConfig.indentSwitch !== false,
62 indentSwitch = parserConfig.indentSwitch !== false,
28 namespaceSeparator = parserConfig.namespaceSeparator,
63 namespaceSeparator = parserConfig.namespaceSeparator,
29 isPunctuationChar = parserConfig.isPunctuationChar || /[\[\]{}\(\),;\:\.]/,
64 isPunctuationChar = parserConfig.isPunctuationChar || /[\[\]{}\(\),;\:\.]/,
30 numberStart = parserConfig.numberStart || /[\d\.]/,
65 numberStart = parserConfig.numberStart || /[\d\.]/,
31 number = parserConfig.number || /^(?:0x[a-f\d]+|0b[01]+|(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)(u|ll?|l|f)?/i,
66 number = parserConfig.number || /^(?:0x[a-f\d]+|0b[01]+|(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)(u|ll?|l|f)?/i,
32 isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/,
67 isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/,
33 endStatement = parserConfig.endStatement || /^[;:,]$/;
68 isIdentifierChar = parserConfig.isIdentifierChar || /[\w\$_\xa1-\uffff]/,
69 // An optional function that takes a {string} token and returns true if it
70 // should be treated as a builtin.
71 isReservedIdentifier = parserConfig.isReservedIdentifier || false;
34
72
35 var curPunc, isDefKeyword;
73 var curPunc, isDefKeyword;
36
74
37 function tokenBase(stream, state) {
75 function tokenBase(stream, state) {
38 var ch = stream.next();
76 var ch = stream.next();
39 if (hooks[ch]) {
77 if (hooks[ch]) {
40 var result = hooks[ch](stream, state);
78 var result = hooks[ch](stream, state);
41 if (result !== false) return result;
79 if (result !== false) return result;
42 }
80 }
43 if (ch == '"' || ch == "'") {
81 if (ch == '"' || ch == "'") {
44 state.tokenize = tokenString(ch);
82 state.tokenize = tokenString(ch);
45 return state.tokenize(stream, state);
83 return state.tokenize(stream, state);
46 }
84 }
47 if (isPunctuationChar.test(ch)) {
85 if (isPunctuationChar.test(ch)) {
48 curPunc = ch;
86 curPunc = ch;
49 return null;
87 return null;
50 }
88 }
51 if (numberStart.test(ch)) {
89 if (numberStart.test(ch)) {
52 stream.backUp(1)
90 stream.backUp(1)
53 if (stream.match(number)) return "number"
91 if (stream.match(number)) return "number"
54 stream.next()
92 stream.next()
55 }
93 }
56 if (ch == "/") {
94 if (ch == "/") {
57 if (stream.eat("*")) {
95 if (stream.eat("*")) {
58 state.tokenize = tokenComment;
96 state.tokenize = tokenComment;
59 return tokenComment(stream, state);
97 return tokenComment(stream, state);
60 }
98 }
61 if (stream.eat("/")) {
99 if (stream.eat("/")) {
62 stream.skipToEnd();
100 stream.skipToEnd();
63 return "comment";
101 return "comment";
64 }
102 }
65 }
103 }
66 if (isOperatorChar.test(ch)) {
104 if (isOperatorChar.test(ch)) {
67 stream.eatWhile(isOperatorChar);
105 while (!stream.match(/^\/[\/*]/, false) && stream.eat(isOperatorChar)) {}
68 return "operator";
106 return "operator";
69 }
107 }
70 stream.eatWhile(/[\w\$_\xa1-\uffff]/);
108 stream.eatWhile(isIdentifierChar);
71 if (namespaceSeparator) while (stream.match(namespaceSeparator))
109 if (namespaceSeparator) while (stream.match(namespaceSeparator))
72 stream.eatWhile(/[\w\$_\xa1-\uffff]/);
110 stream.eatWhile(isIdentifierChar);
73
111
74 var cur = stream.current();
112 var cur = stream.current();
75 if (contains(keywords, cur)) {
113 if (contains(keywords, cur)) {
76 if (contains(blockKeywords, cur)) curPunc = "newstatement";
114 if (contains(blockKeywords, cur)) curPunc = "newstatement";
77 if (contains(defKeywords, cur)) isDefKeyword = true;
115 if (contains(defKeywords, cur)) isDefKeyword = true;
78 return "keyword";
116 return "keyword";
79 }
117 }
80 if (contains(types, cur)) return "variable-3";
118 if (contains(types, cur)) return "type";
81 if (contains(builtin, cur)) {
119 if (contains(builtin, cur)
120 || (isReservedIdentifier && isReservedIdentifier(cur))) {
82 if (contains(blockKeywords, cur)) curPunc = "newstatement";
121 if (contains(blockKeywords, cur)) curPunc = "newstatement";
83 return "builtin";
122 return "builtin";
84 }
123 }
85 if (contains(atoms, cur)) return "atom";
124 if (contains(atoms, cur)) return "atom";
86 return "variable";
125 return "variable";
87 }
126 }
88
127
89 function tokenString(quote) {
128 function tokenString(quote) {
90 return function(stream, state) {
129 return function(stream, state) {
91 var escaped = false, next, end = false;
130 var escaped = false, next, end = false;
92 while ((next = stream.next()) != null) {
131 while ((next = stream.next()) != null) {
93 if (next == quote && !escaped) {end = true; break;}
132 if (next == quote && !escaped) {end = true; break;}
94 escaped = !escaped && next == "\\";
133 escaped = !escaped && next == "\\";
95 }
134 }
96 if (end || !(escaped || multiLineStrings))
135 if (end || !(escaped || multiLineStrings))
97 state.tokenize = null;
136 state.tokenize = null;
98 return "string";
137 return "string";
99 };
138 };
100 }
139 }
101
140
102 function tokenComment(stream, state) {
141 function tokenComment(stream, state) {
103 var maybeEnd = false, ch;
142 var maybeEnd = false, ch;
104 while (ch = stream.next()) {
143 while (ch = stream.next()) {
105 if (ch == "/" && maybeEnd) {
144 if (ch == "/" && maybeEnd) {
106 state.tokenize = null;
145 state.tokenize = null;
107 break;
146 break;
108 }
147 }
109 maybeEnd = (ch == "*");
148 maybeEnd = (ch == "*");
110 }
149 }
111 return "comment";
150 return "comment";
112 }
151 }
113
152
114 function Context(indented, column, type, align, prev) {
153 function maybeEOL(stream, state) {
115 this.indented = indented;
154 if (parserConfig.typeFirstDefinitions && stream.eol() && isTopScope(state.context))
116 this.column = column;
155 state.typeAtEndOfLine = typeBefore(stream, state, stream.pos)
117 this.type = type;
118 this.align = align;
119 this.prev = prev;
120 }
121 function isStatement(type) {
122 return type == "statement" || type == "switchstatement" || type == "namespace";
123 }
124 function pushContext(state, col, type) {
125 var indent = state.indented;
126 if (state.context && isStatement(state.context.type) && !isStatement(type))
127 indent = state.context.indented;
128 return state.context = new Context(indent, col, type, null, state.context);
129 }
130 function popContext(state) {
131 var t = state.context.type;
132 if (t == ")" || t == "]" || t == "}")
133 state.indented = state.context.indented;
134 return state.context = state.context.prev;
135 }
136
137 function typeBefore(stream, state) {
138 if (state.prevToken == "variable" || state.prevToken == "variable-3") return true;
139 if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, stream.start))) return true;
140 }
141
142 function isTopScope(context) {
143 for (;;) {
144 if (!context || context.type == "top") return true;
145 if (context.type == "}" && context.prev.type != "namespace") return false;
146 context = context.prev;
147 }
148 }
156 }
149
157
150 // Interface
158 // Interface
151
159
152 return {
160 return {
153 startState: function(basecolumn) {
161 startState: function(basecolumn) {
154 return {
162 return {
155 tokenize: null,
163 tokenize: null,
156 context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
164 context: new Context((basecolumn || 0) - indentUnit, 0, "top", null, false),
157 indented: 0,
165 indented: 0,
158 startOfLine: true,
166 startOfLine: true,
159 prevToken: null
167 prevToken: null
160 };
168 };
161 },
169 },
162
170
163 token: function(stream, state) {
171 token: function(stream, state) {
164 var ctx = state.context;
172 var ctx = state.context;
165 if (stream.sol()) {
173 if (stream.sol()) {
166 if (ctx.align == null) ctx.align = false;
174 if (ctx.align == null) ctx.align = false;
167 state.indented = stream.indentation();
175 state.indented = stream.indentation();
168 state.startOfLine = true;
176 state.startOfLine = true;
169 }
177 }
170 if (stream.eatSpace()) return null;
178 if (stream.eatSpace()) { maybeEOL(stream, state); return null; }
171 curPunc = isDefKeyword = null;
179 curPunc = isDefKeyword = null;
172 var style = (state.tokenize || tokenBase)(stream, state);
180 var style = (state.tokenize || tokenBase)(stream, state);
173 if (style == "comment" || style == "meta") return style;
181 if (style == "comment" || style == "meta") return style;
174 if (ctx.align == null) ctx.align = true;
182 if (ctx.align == null) ctx.align = true;
175
183
176 if (endStatement.test(curPunc)) while (isStatement(state.context.type)) popContext(state);
184 if (curPunc == ";" || curPunc == ":" || (curPunc == "," && stream.match(/^\s*(?:\/\/.*)?$/, false)))
185 while (state.context.type == "statement") popContext(state);
177 else if (curPunc == "{") pushContext(state, stream.column(), "}");
186 else if (curPunc == "{") pushContext(state, stream.column(), "}");
178 else if (curPunc == "[") pushContext(state, stream.column(), "]");
187 else if (curPunc == "[") pushContext(state, stream.column(), "]");
179 else if (curPunc == "(") pushContext(state, stream.column(), ")");
188 else if (curPunc == "(") pushContext(state, stream.column(), ")");
180 else if (curPunc == "}") {
189 else if (curPunc == "}") {
181 while (isStatement(ctx.type)) ctx = popContext(state);
190 while (ctx.type == "statement") ctx = popContext(state);
182 if (ctx.type == "}") ctx = popContext(state);
191 if (ctx.type == "}") ctx = popContext(state);
183 while (isStatement(ctx.type)) ctx = popContext(state);
192 while (ctx.type == "statement") ctx = popContext(state);
184 }
193 }
185 else if (curPunc == ctx.type) popContext(state);
194 else if (curPunc == ctx.type) popContext(state);
186 else if (indentStatements &&
195 else if (indentStatements &&
187 (((ctx.type == "}" || ctx.type == "top") && curPunc != ";") ||
196 (((ctx.type == "}" || ctx.type == "top") && curPunc != ";") ||
188 (isStatement(ctx.type) && curPunc == "newstatement"))) {
197 (ctx.type == "statement" && curPunc == "newstatement"))) {
189 var type = "statement";
198 pushContext(state, stream.column(), "statement", stream.current());
190 if (curPunc == "newstatement" && indentSwitch && stream.current() == "switch")
191 type = "switchstatement";
192 else if (style == "keyword" && stream.current() == "namespace")
193 type = "namespace";
194 pushContext(state, stream.column(), type);
195 }
199 }
196
200
197 if (style == "variable" &&
201 if (style == "variable" &&
198 ((state.prevToken == "def" ||
202 ((state.prevToken == "def" ||
199 (parserConfig.typeFirstDefinitions && typeBefore(stream, state) &&
203 (parserConfig.typeFirstDefinitions && typeBefore(stream, state, stream.start) &&
200 isTopScope(state.context) && stream.match(/^\s*\(/, false)))))
204 isTopScope(state.context) && stream.match(/^\s*\(/, false)))))
201 style = "def";
205 style = "def";
202
206
203 if (hooks.token) {
207 if (hooks.token) {
204 var result = hooks.token(stream, state, style);
208 var result = hooks.token(stream, state, style);
205 if (result !== undefined) style = result;
209 if (result !== undefined) style = result;
206 }
210 }
207
211
208 if (style == "def" && parserConfig.styleDefs === false) style = "variable";
212 if (style == "def" && parserConfig.styleDefs === false) style = "variable";
209
213
210 state.startOfLine = false;
214 state.startOfLine = false;
211 state.prevToken = isDefKeyword ? "def" : style || curPunc;
215 state.prevToken = isDefKeyword ? "def" : style || curPunc;
216 maybeEOL(stream, state);
212 return style;
217 return style;
213 },
218 },
214
219
215 indent: function(state, textAfter) {
220 indent: function(state, textAfter) {
216 if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
221 if (state.tokenize != tokenBase && state.tokenize != null || state.typeAtEndOfLine) return CodeMirror.Pass;
217 var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
222 var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
218 if (isStatement(ctx.type) && firstChar == "}") ctx = ctx.prev;
223 var closing = firstChar == ctx.type;
224 if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
225 if (parserConfig.dontIndentStatements)
226 while (ctx.type == "statement" && parserConfig.dontIndentStatements.test(ctx.info))
227 ctx = ctx.prev
219 if (hooks.indent) {
228 if (hooks.indent) {
220 var hook = hooks.indent(state, ctx, textAfter);
229 var hook = hooks.indent(state, ctx, textAfter, indentUnit);
221 if (typeof hook == "number") return hook
230 if (typeof hook == "number") return hook
222 }
231 }
223 var closing = firstChar == ctx.type;
232 var switchBlock = ctx.prev && ctx.prev.info == "switch";
224 var switchBlock = ctx.prev && ctx.prev.type == "switchstatement";
225 if (parserConfig.allmanIndentation && /[{(]/.test(firstChar)) {
233 if (parserConfig.allmanIndentation && /[{(]/.test(firstChar)) {
226 while (ctx.type != "top" && ctx.type != "}") ctx = ctx.prev
234 while (ctx.type != "top" && ctx.type != "}") ctx = ctx.prev
227 return ctx.indented
235 return ctx.indented
228 }
236 }
229 if (isStatement(ctx.type))
237 if (ctx.type == "statement")
230 return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
238 return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
231 if (ctx.align && (!dontAlignCalls || ctx.type != ")"))
239 if (ctx.align && (!dontAlignCalls || ctx.type != ")"))
232 return ctx.column + (closing ? 0 : 1);
240 return ctx.column + (closing ? 0 : 1);
233 if (ctx.type == ")" && !closing)
241 if (ctx.type == ")" && !closing)
234 return ctx.indented + statementIndentUnit;
242 return ctx.indented + statementIndentUnit;
235
243
236 return ctx.indented + (closing ? 0 : indentUnit) +
244 return ctx.indented + (closing ? 0 : indentUnit) +
237 (!closing && switchBlock && !/^(?:case|default)\b/.test(textAfter) ? indentUnit : 0);
245 (!closing && switchBlock && !/^(?:case|default)\b/.test(textAfter) ? indentUnit : 0);
238 },
246 },
239
247
240 electricInput: indentSwitch ? /^\s*(?:case .*?:|default:|\{\}?|\})$/ : /^\s*[{}]$/,
248 electricInput: indentSwitch ? /^\s*(?:case .*?:|default:|\{\}?|\})$/ : /^\s*[{}]$/,
241 blockCommentStart: "/*",
249 blockCommentStart: "/*",
242 blockCommentEnd: "*/",
250 blockCommentEnd: "*/",
251 blockCommentContinue: " * ",
243 lineComment: "//",
252 lineComment: "//",
244 fold: "brace"
253 fold: "brace"
245 };
254 };
246 });
255 });
247
256
248 function words(str) {
257 function words(str) {
249 var obj = {}, words = str.split(" ");
258 var obj = {}, words = str.split(" ");
250 for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
259 for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
251 return obj;
260 return obj;
252 }
261 }
253 function contains(words, word) {
262 function contains(words, word) {
254 if (typeof words === "function") {
263 if (typeof words === "function") {
255 return words(word);
264 return words(word);
256 } else {
265 } else {
257 return words.propertyIsEnumerable(word);
266 return words.propertyIsEnumerable(word);
258 }
267 }
259 }
268 }
260 var cKeywords = "auto if break case register continue return default do sizeof " +
269 var cKeywords = "auto if break case register continue return default do sizeof " +
261 "static else struct switch extern typedef union for goto while enum const volatile";
270 "static else struct switch extern typedef union for goto while enum const " +
262 var cTypes = "int long char short double float unsigned signed void size_t ptrdiff_t";
271 "volatile inline restrict asm fortran";
272
273 // Keywords from https://en.cppreference.com/w/cpp/keyword includes C++20.
274 var cppKeywords = "alignas alignof and and_eq audit axiom bitand bitor catch " +
275 "class compl concept constexpr const_cast decltype delete dynamic_cast " +
276 "explicit export final friend import module mutable namespace new noexcept " +
277 "not not_eq operator or or_eq override private protected public " +
278 "reinterpret_cast requires static_assert static_cast template this " +
279 "thread_local throw try typeid typename using virtual xor xor_eq";
280
281 var objCKeywords = "bycopy byref in inout oneway out self super atomic nonatomic retain copy " +
282 "readwrite readonly strong weak assign typeof nullable nonnull null_resettable _cmd " +
283 "@interface @implementation @end @protocol @encode @property @synthesize @dynamic @class " +
284 "@public @package @private @protected @required @optional @try @catch @finally @import " +
285 "@selector @encode @defs @synchronized @autoreleasepool @compatibility_alias @available";
286
287 var objCBuiltins = "FOUNDATION_EXPORT FOUNDATION_EXTERN NS_INLINE NS_FORMAT_FUNCTION " +
288 " NS_RETURNS_RETAINEDNS_ERROR_ENUM NS_RETURNS_NOT_RETAINED NS_RETURNS_INNER_POINTER " +
289 "NS_DESIGNATED_INITIALIZER NS_ENUM NS_OPTIONS NS_REQUIRES_NIL_TERMINATION " +
290 "NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END NS_SWIFT_NAME NS_REFINED_FOR_SWIFT"
291
292 // Do not use this. Use the cTypes function below. This is global just to avoid
293 // excessive calls when cTypes is being called multiple times during a parse.
294 var basicCTypes = words("int long char short double float unsigned signed " +
295 "void bool");
296
297 // Do not use this. Use the objCTypes function below. This is global just to avoid
298 // excessive calls when objCTypes is being called multiple times during a parse.
299 var basicObjCTypes = words("SEL instancetype id Class Protocol BOOL");
300
301 // Returns true if identifier is a "C" type.
302 // C type is defined as those that are reserved by the compiler (basicTypes),
303 // and those that end in _t (Reserved by POSIX for types)
304 // http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html
305 function cTypes(identifier) {
306 return contains(basicCTypes, identifier) || /.+_t$/.test(identifier);
307 }
308
309 // Returns true if identifier is a "Objective C" type.
310 function objCTypes(identifier) {
311 return cTypes(identifier) || contains(basicObjCTypes, identifier);
312 }
313
314 var cBlockKeywords = "case do else for if switch while struct enum union";
315 var cDefKeywords = "struct enum union";
263
316
264 function cppHook(stream, state) {
317 function cppHook(stream, state) {
265 if (!state.startOfLine) return false
318 if (!state.startOfLine) return false
266 for (var ch, next = null; ch = stream.peek();) {
319 for (var ch, next = null; ch = stream.peek();) {
267 if (ch == "\\" && stream.match(/^.$/)) {
320 if (ch == "\\" && stream.match(/^.$/)) {
268 next = cppHook
321 next = cppHook
269 break
322 break
270 } else if (ch == "/" && stream.match(/^\/[\/\*]/, false)) {
323 } else if (ch == "/" && stream.match(/^\/[\/\*]/, false)) {
271 break
324 break
272 }
325 }
273 stream.next()
326 stream.next()
274 }
327 }
275 state.tokenize = next
328 state.tokenize = next
276 return "meta"
329 return "meta"
277 }
330 }
278
331
279 function pointerHook(_stream, state) {
332 function pointerHook(_stream, state) {
280 if (state.prevToken == "variable-3") return "variable-3";
333 if (state.prevToken == "type") return "type";
281 return false;
334 return false;
282 }
335 }
283
336
337 // For C and C++ (and ObjC): identifiers starting with __
338 // or _ followed by a capital letter are reserved for the compiler.
339 function cIsReservedIdentifier(token) {
340 if (!token || token.length < 2) return false;
341 if (token[0] != '_') return false;
342 return (token[1] == '_') || (token[1] !== token[1].toLowerCase());
343 }
344
284 function cpp14Literal(stream) {
345 function cpp14Literal(stream) {
285 stream.eatWhile(/[\w\.']/);
346 stream.eatWhile(/[\w\.']/);
286 return "number";
347 return "number";
287 }
348 }
288
349
289 function cpp11StringHook(stream, state) {
350 function cpp11StringHook(stream, state) {
290 stream.backUp(1);
351 stream.backUp(1);
291 // Raw strings.
352 // Raw strings.
292 if (stream.match(/(R|u8R|uR|UR|LR)/)) {
353 if (stream.match(/(R|u8R|uR|UR|LR)/)) {
293 var match = stream.match(/"([^\s\\()]{0,16})\(/);
354 var match = stream.match(/"([^\s\\()]{0,16})\(/);
294 if (!match) {
355 if (!match) {
295 return false;
356 return false;
296 }
357 }
297 state.cpp11RawStringDelim = match[1];
358 state.cpp11RawStringDelim = match[1];
298 state.tokenize = tokenRawString;
359 state.tokenize = tokenRawString;
299 return tokenRawString(stream, state);
360 return tokenRawString(stream, state);
300 }
361 }
301 // Unicode strings/chars.
362 // Unicode strings/chars.
302 if (stream.match(/(u8|u|U|L)/)) {
363 if (stream.match(/(u8|u|U|L)/)) {
303 if (stream.match(/["']/, /* eat */ false)) {
364 if (stream.match(/["']/, /* eat */ false)) {
304 return "string";
365 return "string";
305 }
366 }
306 return false;
367 return false;
307 }
368 }
308 // Ignore this hook.
369 // Ignore this hook.
309 stream.next();
370 stream.next();
310 return false;
371 return false;
311 }
372 }
312
373
313 function cppLooksLikeConstructor(word) {
374 function cppLooksLikeConstructor(word) {
314 var lastTwo = /(\w+)::(\w+)$/.exec(word);
375 var lastTwo = /(\w+)::~?(\w+)$/.exec(word);
315 return lastTwo && lastTwo[1] == lastTwo[2];
376 return lastTwo && lastTwo[1] == lastTwo[2];
316 }
377 }
317
378
318 // C#-style strings where "" escapes a quote.
379 // C#-style strings where "" escapes a quote.
319 function tokenAtString(stream, state) {
380 function tokenAtString(stream, state) {
320 var next;
381 var next;
321 while ((next = stream.next()) != null) {
382 while ((next = stream.next()) != null) {
322 if (next == '"' && !stream.eat('"')) {
383 if (next == '"' && !stream.eat('"')) {
323 state.tokenize = null;
384 state.tokenize = null;
324 break;
385 break;
325 }
386 }
326 }
387 }
327 return "string";
388 return "string";
328 }
389 }
329
390
330 // C++11 raw string literal is <prefix>"<delim>( anything )<delim>", where
391 // C++11 raw string literal is <prefix>"<delim>( anything )<delim>", where
331 // <delim> can be a string up to 16 characters long.
392 // <delim> can be a string up to 16 characters long.
332 function tokenRawString(stream, state) {
393 function tokenRawString(stream, state) {
333 // Escape characters that have special regex meanings.
394 // Escape characters that have special regex meanings.
334 var delim = state.cpp11RawStringDelim.replace(/[^\w\s]/g, '\\$&');
395 var delim = state.cpp11RawStringDelim.replace(/[^\w\s]/g, '\\$&');
335 var match = stream.match(new RegExp(".*?\\)" + delim + '"'));
396 var match = stream.match(new RegExp(".*?\\)" + delim + '"'));
336 if (match)
397 if (match)
337 state.tokenize = null;
398 state.tokenize = null;
338 else
399 else
339 stream.skipToEnd();
400 stream.skipToEnd();
340 return "string";
401 return "string";
341 }
402 }
342
403
343 function def(mimes, mode) {
404 function def(mimes, mode) {
344 if (typeof mimes == "string") mimes = [mimes];
405 if (typeof mimes == "string") mimes = [mimes];
345 var words = [];
406 var words = [];
346 function add(obj) {
407 function add(obj) {
347 if (obj) for (var prop in obj) if (obj.hasOwnProperty(prop))
408 if (obj) for (var prop in obj) if (obj.hasOwnProperty(prop))
348 words.push(prop);
409 words.push(prop);
349 }
410 }
350 add(mode.keywords);
411 add(mode.keywords);
351 add(mode.types);
412 add(mode.types);
352 add(mode.builtin);
413 add(mode.builtin);
353 add(mode.atoms);
414 add(mode.atoms);
354 if (words.length) {
415 if (words.length) {
355 mode.helperType = mimes[0];
416 mode.helperType = mimes[0];
356 CodeMirror.registerHelper("hintWords", mimes[0], words);
417 CodeMirror.registerHelper("hintWords", mimes[0], words);
357 }
418 }
358
419
359 for (var i = 0; i < mimes.length; ++i)
420 for (var i = 0; i < mimes.length; ++i)
360 CodeMirror.defineMIME(mimes[i], mode);
421 CodeMirror.defineMIME(mimes[i], mode);
361 }
422 }
362
423
363 def(["text/x-csrc", "text/x-c", "text/x-chdr"], {
424 def(["text/x-csrc", "text/x-c", "text/x-chdr"], {
364 name: "clike",
425 name: "clike",
365 keywords: words(cKeywords),
426 keywords: words(cKeywords),
366 types: words(cTypes + " bool _Complex _Bool float_t double_t intptr_t intmax_t " +
427 types: cTypes,
367 "int8_t int16_t int32_t int64_t uintptr_t uintmax_t uint8_t uint16_t " +
428 blockKeywords: words(cBlockKeywords),
368 "uint32_t uint64_t"),
429 defKeywords: words(cDefKeywords),
369 blockKeywords: words("case do else for if switch while struct"),
370 defKeywords: words("struct"),
371 typeFirstDefinitions: true,
430 typeFirstDefinitions: true,
372 atoms: words("null true false"),
431 atoms: words("NULL true false"),
373 hooks: {"#": cppHook, "*": pointerHook},
432 isReservedIdentifier: cIsReservedIdentifier,
433 hooks: {
434 "#": cppHook,
435 "*": pointerHook,
436 },
374 modeProps: {fold: ["brace", "include"]}
437 modeProps: {fold: ["brace", "include"]}
375 });
438 });
376
439
377 def(["text/x-c++src", "text/x-c++hdr"], {
440 def(["text/x-c++src", "text/x-c++hdr"], {
378 name: "clike",
441 name: "clike",
379 keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try explicit new " +
442 keywords: words(cKeywords + " " + cppKeywords),
380 "static_cast typeid catch operator template typename class friend private " +
443 types: cTypes,
381 "this using const_cast inline public throw virtual delete mutable protected " +
444 blockKeywords: words(cBlockKeywords + " class try catch"),
382 "alignas alignof constexpr decltype nullptr noexcept thread_local final " +
445 defKeywords: words(cDefKeywords + " class namespace"),
383 "static_assert override"),
384 types: words(cTypes + " bool wchar_t"),
385 blockKeywords: words("catch class do else finally for if struct switch try while"),
386 defKeywords: words("class namespace struct enum union"),
387 typeFirstDefinitions: true,
446 typeFirstDefinitions: true,
388 atoms: words("true false null"),
447 atoms: words("true false NULL nullptr"),
448 dontIndentStatements: /^template$/,
449 isIdentifierChar: /[\w\$_~\xa1-\uffff]/,
450 isReservedIdentifier: cIsReservedIdentifier,
389 hooks: {
451 hooks: {
390 "#": cppHook,
452 "#": cppHook,
391 "*": pointerHook,
453 "*": pointerHook,
392 "u": cpp11StringHook,
454 "u": cpp11StringHook,
393 "U": cpp11StringHook,
455 "U": cpp11StringHook,
394 "L": cpp11StringHook,
456 "L": cpp11StringHook,
395 "R": cpp11StringHook,
457 "R": cpp11StringHook,
396 "0": cpp14Literal,
458 "0": cpp14Literal,
397 "1": cpp14Literal,
459 "1": cpp14Literal,
398 "2": cpp14Literal,
460 "2": cpp14Literal,
399 "3": cpp14Literal,
461 "3": cpp14Literal,
400 "4": cpp14Literal,
462 "4": cpp14Literal,
401 "5": cpp14Literal,
463 "5": cpp14Literal,
402 "6": cpp14Literal,
464 "6": cpp14Literal,
403 "7": cpp14Literal,
465 "7": cpp14Literal,
404 "8": cpp14Literal,
466 "8": cpp14Literal,
405 "9": cpp14Literal,
467 "9": cpp14Literal,
406 token: function(stream, state, style) {
468 token: function(stream, state, style) {
407 if (style == "variable" && stream.peek() == "(" &&
469 if (style == "variable" && stream.peek() == "(" &&
408 (state.prevToken == ";" || state.prevToken == null ||
470 (state.prevToken == ";" || state.prevToken == null ||
409 state.prevToken == "}") &&
471 state.prevToken == "}") &&
410 cppLooksLikeConstructor(stream.current()))
472 cppLooksLikeConstructor(stream.current()))
411 return "def";
473 return "def";
412 }
474 }
413 },
475 },
414 namespaceSeparator: "::",
476 namespaceSeparator: "::",
415 modeProps: {fold: ["brace", "include"]}
477 modeProps: {fold: ["brace", "include"]}
416 });
478 });
417
479
418 def("text/x-java", {
480 def("text/x-java", {
419 name: "clike",
481 name: "clike",
420 keywords: words("abstract assert break case catch class const continue default " +
482 keywords: words("abstract assert break case catch class const continue default " +
421 "do else enum extends final finally float for goto if implements import " +
483 "do else enum extends final finally for goto if implements import " +
422 "instanceof interface native new package private protected public " +
484 "instanceof interface native new package private protected public " +
423 "return static strictfp super switch synchronized this throw throws transient " +
485 "return static strictfp super switch synchronized this throw throws transient " +
424 "try volatile while"),
486 "try volatile while @interface"),
425 types: words("byte short int long float double boolean char void Boolean Byte Character Double Float " +
487 types: words("byte short int long float double boolean char void Boolean Byte Character Double Float " +
426 "Integer Long Number Object Short String StringBuffer StringBuilder Void"),
488 "Integer Long Number Object Short String StringBuffer StringBuilder Void"),
427 blockKeywords: words("catch class do else finally for if switch try while"),
489 blockKeywords: words("catch class do else finally for if switch try while"),
428 defKeywords: words("class interface package enum"),
490 defKeywords: words("class interface enum @interface"),
429 typeFirstDefinitions: true,
491 typeFirstDefinitions: true,
430 atoms: words("true false null"),
492 atoms: words("true false null"),
431 endStatement: /^[;:]$/,
493 number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+\.?\d*|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i,
432 hooks: {
494 hooks: {
433 "@": function(stream) {
495 "@": function(stream) {
496 // Don't match the @interface keyword.
497 if (stream.match('interface', false)) return false;
498
434 stream.eatWhile(/[\w\$_]/);
499 stream.eatWhile(/[\w\$_]/);
435 return "meta";
500 return "meta";
436 }
501 }
437 },
502 },
438 modeProps: {fold: ["brace", "import"]}
503 modeProps: {fold: ["brace", "import"]}
439 });
504 });
440
505
441 def("text/x-csharp", {
506 def("text/x-csharp", {
442 name: "clike",
507 name: "clike",
443 keywords: words("abstract as async await base break case catch checked class const continue" +
508 keywords: words("abstract as async await base break case catch checked class const continue" +
444 " default delegate do else enum event explicit extern finally fixed for" +
509 " default delegate do else enum event explicit extern finally fixed for" +
445 " foreach goto if implicit in interface internal is lock namespace new" +
510 " foreach goto if implicit in interface internal is lock namespace new" +
446 " operator out override params private protected public readonly ref return sealed" +
511 " operator out override params private protected public readonly ref return sealed" +
447 " sizeof stackalloc static struct switch this throw try typeof unchecked" +
512 " sizeof stackalloc static struct switch this throw try typeof unchecked" +
448 " unsafe using virtual void volatile while add alias ascending descending dynamic from get" +
513 " unsafe using virtual void volatile while add alias ascending descending dynamic from get" +
449 " global group into join let orderby partial remove select set value var yield"),
514 " global group into join let orderby partial remove select set value var yield"),
450 types: words("Action Boolean Byte Char DateTime DateTimeOffset Decimal Double Func" +
515 types: words("Action Boolean Byte Char DateTime DateTimeOffset Decimal Double Func" +
451 " Guid Int16 Int32 Int64 Object SByte Single String Task TimeSpan UInt16 UInt32" +
516 " Guid Int16 Int32 Int64 Object SByte Single String Task TimeSpan UInt16 UInt32" +
452 " UInt64 bool byte char decimal double short int long object" +
517 " UInt64 bool byte char decimal double short int long object" +
453 " sbyte float string ushort uint ulong"),
518 " sbyte float string ushort uint ulong"),
454 blockKeywords: words("catch class do else finally for foreach if struct switch try while"),
519 blockKeywords: words("catch class do else finally for foreach if struct switch try while"),
455 defKeywords: words("class interface namespace struct var"),
520 defKeywords: words("class interface namespace struct var"),
456 typeFirstDefinitions: true,
521 typeFirstDefinitions: true,
457 atoms: words("true false null"),
522 atoms: words("true false null"),
458 hooks: {
523 hooks: {
459 "@": function(stream, state) {
524 "@": function(stream, state) {
460 if (stream.eat('"')) {
525 if (stream.eat('"')) {
461 state.tokenize = tokenAtString;
526 state.tokenize = tokenAtString;
462 return tokenAtString(stream, state);
527 return tokenAtString(stream, state);
463 }
528 }
464 stream.eatWhile(/[\w\$_]/);
529 stream.eatWhile(/[\w\$_]/);
465 return "meta";
530 return "meta";
466 }
531 }
467 }
532 }
468 });
533 });
469
534
470 function tokenTripleString(stream, state) {
535 function tokenTripleString(stream, state) {
471 var escaped = false;
536 var escaped = false;
472 while (!stream.eol()) {
537 while (!stream.eol()) {
473 if (!escaped && stream.match('"""')) {
538 if (!escaped && stream.match('"""')) {
474 state.tokenize = null;
539 state.tokenize = null;
475 break;
540 break;
476 }
541 }
477 escaped = stream.next() == "\\" && !escaped;
542 escaped = stream.next() == "\\" && !escaped;
478 }
543 }
479 return "string";
544 return "string";
480 }
545 }
481
546
547 function tokenNestedComment(depth) {
548 return function (stream, state) {
549 var ch
550 while (ch = stream.next()) {
551 if (ch == "*" && stream.eat("/")) {
552 if (depth == 1) {
553 state.tokenize = null
554 break
555 } else {
556 state.tokenize = tokenNestedComment(depth - 1)
557 return state.tokenize(stream, state)
558 }
559 } else if (ch == "/" && stream.eat("*")) {
560 state.tokenize = tokenNestedComment(depth + 1)
561 return state.tokenize(stream, state)
562 }
563 }
564 return "comment"
565 }
566 }
567
482 def("text/x-scala", {
568 def("text/x-scala", {
483 name: "clike",
569 name: "clike",
484 keywords: words(
570 keywords: words(
485
486 /* scala */
571 /* scala */
487 "abstract case catch class def do else extends final finally for forSome if " +
572 "abstract case catch class def do else extends final finally for forSome if " +
488 "implicit import lazy match new null object override package private protected return " +
573 "implicit import lazy match new null object override package private protected return " +
489 "sealed super this throw trait try type val var while with yield _ : = => <- <: " +
574 "sealed super this throw trait try type val var while with yield _ " +
490 "<% >: # @ " +
491
575
492 /* package scala */
576 /* package scala */
493 "assert assume require print println printf readLine readBoolean readByte readShort " +
577 "assert assume require print println printf readLine readBoolean readByte readShort " +
494 "readChar readInt readLong readFloat readDouble " +
578 "readChar readInt readLong readFloat readDouble"
495
496 ":: #:: "
497 ),
579 ),
498 types: words(
580 types: words(
499 "AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
581 "AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
500 "Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " +
582 "Enumeration Equiv Error Exception Fractional Function IndexedSeq Int Integral Iterable " +
501 "Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
583 "Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
502 "Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
584 "Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
503 "StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector " +
585 "StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector " +
504
586
505 /* package java.lang */
587 /* package java.lang */
506 "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
588 "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
507 "Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
589 "Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
508 "Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
590 "Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
509 "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
591 "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
510 ),
592 ),
511 multiLineStrings: true,
593 multiLineStrings: true,
512 blockKeywords: words("catch class do else finally for forSome if match switch try while"),
594 blockKeywords: words("catch class enum do else finally for forSome if match switch try while"),
513 defKeywords: words("class def object package trait type val var"),
595 defKeywords: words("class enum def object package trait type val var"),
514 atoms: words("true false null"),
596 atoms: words("true false null"),
515 indentStatements: false,
597 indentStatements: false,
516 indentSwitch: false,
598 indentSwitch: false,
599 isOperatorChar: /[+\-*&%=<>!?|\/#:@]/,
517 hooks: {
600 hooks: {
518 "@": function(stream) {
601 "@": function(stream) {
519 stream.eatWhile(/[\w\$_]/);
602 stream.eatWhile(/[\w\$_]/);
520 return "meta";
603 return "meta";
521 },
604 },
522 '"': function(stream, state) {
605 '"': function(stream, state) {
523 if (!stream.match('""')) return false;
606 if (!stream.match('""')) return false;
524 state.tokenize = tokenTripleString;
607 state.tokenize = tokenTripleString;
525 return state.tokenize(stream, state);
608 return state.tokenize(stream, state);
526 },
609 },
527 "'": function(stream) {
610 "'": function(stream) {
528 stream.eatWhile(/[\w\$_\xa1-\uffff]/);
611 stream.eatWhile(/[\w\$_\xa1-\uffff]/);
529 return "atom";
612 return "atom";
613 },
614 "=": function(stream, state) {
615 var cx = state.context
616 if (cx.type == "}" && cx.align && stream.eat(">")) {
617 state.context = new Context(cx.indented, cx.column, cx.type, cx.info, null, cx.prev)
618 return "operator"
619 } else {
620 return false
530 }
621 }
531 },
622 },
532 modeProps: {closeBrackets: {triples: '"'}}
623
624 "/": function(stream, state) {
625 if (!stream.eat("*")) return false
626 state.tokenize = tokenNestedComment(1)
627 return state.tokenize(stream, state)
628 }
629 },
630 modeProps: {closeBrackets: {pairs: '()[]{}""', triples: '"'}}
533 });
631 });
534
632
535 function tokenKotlinString(tripleString){
633 function tokenKotlinString(tripleString){
536 return function (stream, state) {
634 return function (stream, state) {
537 var escaped = false, next, end = false;
635 var escaped = false, next, end = false;
538 while (!stream.eol()) {
636 while (!stream.eol()) {
539 if (!tripleString && !escaped && stream.match('"') ) {end = true; break;}
637 if (!tripleString && !escaped && stream.match('"') ) {end = true; break;}
540 if (tripleString && stream.match('"""')) {end = true; break;}
638 if (tripleString && stream.match('"""')) {end = true; break;}
541 next = stream.next();
639 next = stream.next();
542 if(!escaped && next == "$" && stream.match('{'))
640 if(!escaped && next == "$" && stream.match('{'))
543 stream.skipTo("}");
641 stream.skipTo("}");
544 escaped = !escaped && next == "\\" && !tripleString;
642 escaped = !escaped && next == "\\" && !tripleString;
545 }
643 }
546 if (end || !tripleString)
644 if (end || !tripleString)
547 state.tokenize = null;
645 state.tokenize = null;
548 return "string";
646 return "string";
549 }
647 }
550 }
648 }
551
649
552 def("text/x-kotlin", {
650 def("text/x-kotlin", {
553 name: "clike",
651 name: "clike",
554 keywords: words(
652 keywords: words(
555 /*keywords*/
653 /*keywords*/
556 "package as typealias class interface this super val " +
654 "package as typealias class interface this super val operator " +
557 "var fun for is in This throw return " +
655 "var fun for is in This throw return annotation " +
558 "break continue object if else while do try when !in !is as? " +
656 "break continue object if else while do try when !in !is as? " +
559
657
560 /*soft keywords*/
658 /*soft keywords*/
561 "file import where by get set abstract enum open inner override private public internal " +
659 "file import where by get set abstract enum open inner override private public internal " +
562 "protected catch finally out final vararg reified dynamic companion constructor init " +
660 "protected catch finally out final vararg reified dynamic companion constructor init " +
563 "sealed field property receiver param sparam lateinit data inline noinline tailrec " +
661 "sealed field property receiver param sparam lateinit data inline noinline tailrec " +
564 "external annotation crossinline const operator infix"
662 "external annotation crossinline const operator infix suspend actual expect setparam"
565 ),
663 ),
566 types: words(
664 types: words(
567 /* package java.lang */
665 /* package java.lang */
568 "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
666 "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
569 "Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
667 "Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
570 "Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
668 "Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
571 "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
669 "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void Annotation Any BooleanArray " +
670 "ByteArray Char CharArray DeprecationLevel DoubleArray Enum FloatArray Function Int IntArray Lazy " +
671 "LazyThreadSafetyMode LongArray Nothing ShortArray Unit"
572 ),
672 ),
573 intendSwitch: false,
673 intendSwitch: false,
574 indentStatements: false,
674 indentStatements: false,
575 multiLineStrings: true,
675 multiLineStrings: true,
676 number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+(\.\d+)?|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i,
576 blockKeywords: words("catch class do else finally for if where try while enum"),
677 blockKeywords: words("catch class do else finally for if where try while enum"),
577 defKeywords: words("class val var object package interface fun"),
678 defKeywords: words("class val var object interface fun"),
578 atoms: words("true false null this"),
679 atoms: words("true false null this"),
579 hooks: {
680 hooks: {
681 "@": function(stream) {
682 stream.eatWhile(/[\w\$_]/);
683 return "meta";
684 },
685 '*': function(_stream, state) {
686 return state.prevToken == '.' ? 'variable' : 'operator';
687 },
580 '"': function(stream, state) {
688 '"': function(stream, state) {
581 state.tokenize = tokenKotlinString(stream.match('""'));
689 state.tokenize = tokenKotlinString(stream.match('""'));
582 return state.tokenize(stream, state);
690 return state.tokenize(stream, state);
691 },
692 "/": function(stream, state) {
693 if (!stream.eat("*")) return false;
694 state.tokenize = tokenNestedComment(1);
695 return state.tokenize(stream, state)
696 },
697 indent: function(state, ctx, textAfter, indentUnit) {
698 var firstChar = textAfter && textAfter.charAt(0);
699 if ((state.prevToken == "}" || state.prevToken == ")") && textAfter == "")
700 return state.indented;
701 if ((state.prevToken == "operator" && textAfter != "}" && state.context.type != "}") ||
702 state.prevToken == "variable" && firstChar == "." ||
703 (state.prevToken == "}" || state.prevToken == ")") && firstChar == ".")
704 return indentUnit * 2 + ctx.indented;
705 if (ctx.align && ctx.type == "}")
706 return ctx.indented + (state.context.type == (textAfter || "").charAt(0) ? 0 : indentUnit);
583 }
707 }
584 },
708 },
585 modeProps: {closeBrackets: {triples: '"'}}
709 modeProps: {closeBrackets: {triples: '"'}}
586 });
710 });
587
711
588 def(["x-shader/x-vertex", "x-shader/x-fragment"], {
712 def(["x-shader/x-vertex", "x-shader/x-fragment"], {
589 name: "clike",
713 name: "clike",
590 keywords: words("sampler1D sampler2D sampler3D samplerCube " +
714 keywords: words("sampler1D sampler2D sampler3D samplerCube " +
591 "sampler1DShadow sampler2DShadow " +
715 "sampler1DShadow sampler2DShadow " +
592 "const attribute uniform varying " +
716 "const attribute uniform varying " +
593 "break continue discard return " +
717 "break continue discard return " +
594 "for while do if else struct " +
718 "for while do if else struct " +
595 "in out inout"),
719 "in out inout"),
596 types: words("float int bool void " +
720 types: words("float int bool void " +
597 "vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " +
721 "vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " +
598 "mat2 mat3 mat4"),
722 "mat2 mat3 mat4"),
599 blockKeywords: words("for while do if else struct"),
723 blockKeywords: words("for while do if else struct"),
600 builtin: words("radians degrees sin cos tan asin acos atan " +
724 builtin: words("radians degrees sin cos tan asin acos atan " +
601 "pow exp log exp2 sqrt inversesqrt " +
725 "pow exp log exp2 sqrt inversesqrt " +
602 "abs sign floor ceil fract mod min max clamp mix step smoothstep " +
726 "abs sign floor ceil fract mod min max clamp mix step smoothstep " +
603 "length distance dot cross normalize ftransform faceforward " +
727 "length distance dot cross normalize ftransform faceforward " +
604 "reflect refract matrixCompMult " +
728 "reflect refract matrixCompMult " +
605 "lessThan lessThanEqual greaterThan greaterThanEqual " +
729 "lessThan lessThanEqual greaterThan greaterThanEqual " +
606 "equal notEqual any all not " +
730 "equal notEqual any all not " +
607 "texture1D texture1DProj texture1DLod texture1DProjLod " +
731 "texture1D texture1DProj texture1DLod texture1DProjLod " +
608 "texture2D texture2DProj texture2DLod texture2DProjLod " +
732 "texture2D texture2DProj texture2DLod texture2DProjLod " +
609 "texture3D texture3DProj texture3DLod texture3DProjLod " +
733 "texture3D texture3DProj texture3DLod texture3DProjLod " +
610 "textureCube textureCubeLod " +
734 "textureCube textureCubeLod " +
611 "shadow1D shadow2D shadow1DProj shadow2DProj " +
735 "shadow1D shadow2D shadow1DProj shadow2DProj " +
612 "shadow1DLod shadow2DLod shadow1DProjLod shadow2DProjLod " +
736 "shadow1DLod shadow2DLod shadow1DProjLod shadow2DProjLod " +
613 "dFdx dFdy fwidth " +
737 "dFdx dFdy fwidth " +
614 "noise1 noise2 noise3 noise4"),
738 "noise1 noise2 noise3 noise4"),
615 atoms: words("true false " +
739 atoms: words("true false " +
616 "gl_FragColor gl_SecondaryColor gl_Normal gl_Vertex " +
740 "gl_FragColor gl_SecondaryColor gl_Normal gl_Vertex " +
617 "gl_MultiTexCoord0 gl_MultiTexCoord1 gl_MultiTexCoord2 gl_MultiTexCoord3 " +
741 "gl_MultiTexCoord0 gl_MultiTexCoord1 gl_MultiTexCoord2 gl_MultiTexCoord3 " +
618 "gl_MultiTexCoord4 gl_MultiTexCoord5 gl_MultiTexCoord6 gl_MultiTexCoord7 " +
742 "gl_MultiTexCoord4 gl_MultiTexCoord5 gl_MultiTexCoord6 gl_MultiTexCoord7 " +
619 "gl_FogCoord gl_PointCoord " +
743 "gl_FogCoord gl_PointCoord " +
620 "gl_Position gl_PointSize gl_ClipVertex " +
744 "gl_Position gl_PointSize gl_ClipVertex " +
621 "gl_FrontColor gl_BackColor gl_FrontSecondaryColor gl_BackSecondaryColor " +
745 "gl_FrontColor gl_BackColor gl_FrontSecondaryColor gl_BackSecondaryColor " +
622 "gl_TexCoord gl_FogFragCoord " +
746 "gl_TexCoord gl_FogFragCoord " +
623 "gl_FragCoord gl_FrontFacing " +
747 "gl_FragCoord gl_FrontFacing " +
624 "gl_FragData gl_FragDepth " +
748 "gl_FragData gl_FragDepth " +
625 "gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMatrix " +
749 "gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMatrix " +
626 "gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " +
750 "gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " +
627 "gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse " +
751 "gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse " +
628 "gl_TexureMatrixTranspose gl_ModelViewMatrixInverseTranspose " +
752 "gl_TexureMatrixTranspose gl_ModelViewMatrixInverseTranspose " +
629 "gl_ProjectionMatrixInverseTranspose " +
753 "gl_ProjectionMatrixInverseTranspose " +
630 "gl_ModelViewProjectionMatrixInverseTranspose " +
754 "gl_ModelViewProjectionMatrixInverseTranspose " +
631 "gl_TextureMatrixInverseTranspose " +
755 "gl_TextureMatrixInverseTranspose " +
632 "gl_NormalScale gl_DepthRange gl_ClipPlane " +
756 "gl_NormalScale gl_DepthRange gl_ClipPlane " +
633 "gl_Point gl_FrontMaterial gl_BackMaterial gl_LightSource gl_LightModel " +
757 "gl_Point gl_FrontMaterial gl_BackMaterial gl_LightSource gl_LightModel " +
634 "gl_FrontLightModelProduct gl_BackLightModelProduct " +
758 "gl_FrontLightModelProduct gl_BackLightModelProduct " +
635 "gl_TextureColor gl_EyePlaneS gl_EyePlaneT gl_EyePlaneR gl_EyePlaneQ " +
759 "gl_TextureColor gl_EyePlaneS gl_EyePlaneT gl_EyePlaneR gl_EyePlaneQ " +
636 "gl_FogParameters " +
760 "gl_FogParameters " +
637 "gl_MaxLights gl_MaxClipPlanes gl_MaxTextureUnits gl_MaxTextureCoords " +
761 "gl_MaxLights gl_MaxClipPlanes gl_MaxTextureUnits gl_MaxTextureCoords " +
638 "gl_MaxVertexAttribs gl_MaxVertexUniformComponents gl_MaxVaryingFloats " +
762 "gl_MaxVertexAttribs gl_MaxVertexUniformComponents gl_MaxVaryingFloats " +
639 "gl_MaxVertexTextureImageUnits gl_MaxTextureImageUnits " +
763 "gl_MaxVertexTextureImageUnits gl_MaxTextureImageUnits " +
640 "gl_MaxFragmentUniformComponents gl_MaxCombineTextureImageUnits " +
764 "gl_MaxFragmentUniformComponents gl_MaxCombineTextureImageUnits " +
641 "gl_MaxDrawBuffers"),
765 "gl_MaxDrawBuffers"),
642 indentSwitch: false,
766 indentSwitch: false,
643 hooks: {"#": cppHook},
767 hooks: {"#": cppHook},
644 modeProps: {fold: ["brace", "include"]}
768 modeProps: {fold: ["brace", "include"]}
645 });
769 });
646
770
647 def("text/x-nesc", {
771 def("text/x-nesc", {
648 name: "clike",
772 name: "clike",
649 keywords: words(cKeywords + "as atomic async call command component components configuration event generic " +
773 keywords: words(cKeywords + " as atomic async call command component components configuration event generic " +
650 "implementation includes interface module new norace nx_struct nx_union post provides " +
774 "implementation includes interface module new norace nx_struct nx_union post provides " +
651 "signal task uses abstract extends"),
775 "signal task uses abstract extends"),
652 types: words(cTypes),
776 types: cTypes,
653 blockKeywords: words("case do else for if switch while struct"),
777 blockKeywords: words(cBlockKeywords),
654 atoms: words("null true false"),
778 atoms: words("null true false"),
655 hooks: {"#": cppHook},
779 hooks: {"#": cppHook},
656 modeProps: {fold: ["brace", "include"]}
780 modeProps: {fold: ["brace", "include"]}
657 });
781 });
658
782
659 def("text/x-objectivec", {
783 def("text/x-objectivec", {
660 name: "clike",
784 name: "clike",
661 keywords: words(cKeywords + "inline restrict _Bool _Complex _Imaginery BOOL Class bycopy byref id IMP in " +
785 keywords: words(cKeywords + " " + objCKeywords),
662 "inout nil oneway out Protocol SEL self super atomic nonatomic retain copy readwrite readonly"),
786 types: objCTypes,
663 types: words(cTypes),
787 builtin: words(objCBuiltins),
664 atoms: words("YES NO NULL NILL ON OFF true false"),
788 blockKeywords: words(cBlockKeywords + " @synthesize @try @catch @finally @autoreleasepool @synchronized"),
789 defKeywords: words(cDefKeywords + " @interface @implementation @protocol @class"),
790 dontIndentStatements: /^@.*$/,
791 typeFirstDefinitions: true,
792 atoms: words("YES NO NULL Nil nil true false nullptr"),
793 isReservedIdentifier: cIsReservedIdentifier,
665 hooks: {
794 hooks: {
666 "@": function(stream) {
795 "#": cppHook,
667 stream.eatWhile(/[\w\$]/);
796 "*": pointerHook,
668 return "keyword";
669 },
797 },
798 modeProps: {fold: ["brace", "include"]}
799 });
800
801 def("text/x-objectivec++", {
802 name: "clike",
803 keywords: words(cKeywords + " " + objCKeywords + " " + cppKeywords),
804 types: objCTypes,
805 builtin: words(objCBuiltins),
806 blockKeywords: words(cBlockKeywords + " @synthesize @try @catch @finally @autoreleasepool @synchronized class try catch"),
807 defKeywords: words(cDefKeywords + " @interface @implementation @protocol @class class namespace"),
808 dontIndentStatements: /^@.*$|^template$/,
809 typeFirstDefinitions: true,
810 atoms: words("YES NO NULL Nil nil true false nullptr"),
811 isReservedIdentifier: cIsReservedIdentifier,
812 hooks: {
670 "#": cppHook,
813 "#": cppHook,
671 indent: function(_state, ctx, textAfter) {
814 "*": pointerHook,
672 if (ctx.type == "statement" && /^@\w/.test(textAfter)) return ctx.indented
815 "u": cpp11StringHook,
816 "U": cpp11StringHook,
817 "L": cpp11StringHook,
818 "R": cpp11StringHook,
819 "0": cpp14Literal,
820 "1": cpp14Literal,
821 "2": cpp14Literal,
822 "3": cpp14Literal,
823 "4": cpp14Literal,
824 "5": cpp14Literal,
825 "6": cpp14Literal,
826 "7": cpp14Literal,
827 "8": cpp14Literal,
828 "9": cpp14Literal,
829 token: function(stream, state, style) {
830 if (style == "variable" && stream.peek() == "(" &&
831 (state.prevToken == ";" || state.prevToken == null ||
832 state.prevToken == "}") &&
833 cppLooksLikeConstructor(stream.current()))
834 return "def";
673 }
835 }
674 },
836 },
675 modeProps: {fold: "brace"}
837 namespaceSeparator: "::",
838 modeProps: {fold: ["brace", "include"]}
676 });
839 });
677
840
678 def("text/x-squirrel", {
841 def("text/x-squirrel", {
679 name: "clike",
842 name: "clike",
680 keywords: words("base break clone continue const default delete enum extends function in class" +
843 keywords: words("base break clone continue const default delete enum extends function in class" +
681 " foreach local resume return this throw typeof yield constructor instanceof static"),
844 " foreach local resume return this throw typeof yield constructor instanceof static"),
682 types: words(cTypes),
845 types: cTypes,
683 blockKeywords: words("case catch class else for foreach if switch try while"),
846 blockKeywords: words("case catch class else for foreach if switch try while"),
684 defKeywords: words("function local class"),
847 defKeywords: words("function local class"),
685 typeFirstDefinitions: true,
848 typeFirstDefinitions: true,
686 atoms: words("true false null"),
849 atoms: words("true false null"),
687 hooks: {"#": cppHook},
850 hooks: {"#": cppHook},
688 modeProps: {fold: ["brace", "include"]}
851 modeProps: {fold: ["brace", "include"]}
689 });
852 });
690
853
691 // Ceylon Strings need to deal with interpolation
854 // Ceylon Strings need to deal with interpolation
692 var stringTokenizer = null;
855 var stringTokenizer = null;
693 function tokenCeylonString(type) {
856 function tokenCeylonString(type) {
694 return function(stream, state) {
857 return function(stream, state) {
695 var escaped = false, next, end = false;
858 var escaped = false, next, end = false;
696 while (!stream.eol()) {
859 while (!stream.eol()) {
697 if (!escaped && stream.match('"') &&
860 if (!escaped && stream.match('"') &&
698 (type == "single" || stream.match('""'))) {
861 (type == "single" || stream.match('""'))) {
699 end = true;
862 end = true;
700 break;
863 break;
701 }
864 }
702 if (!escaped && stream.match('``')) {
865 if (!escaped && stream.match('``')) {
703 stringTokenizer = tokenCeylonString(type);
866 stringTokenizer = tokenCeylonString(type);
704 end = true;
867 end = true;
705 break;
868 break;
706 }
869 }
707 next = stream.next();
870 next = stream.next();
708 escaped = type == "single" && !escaped && next == "\\";
871 escaped = type == "single" && !escaped && next == "\\";
709 }
872 }
710 if (end)
873 if (end)
711 state.tokenize = null;
874 state.tokenize = null;
712 return "string";
875 return "string";
713 }
876 }
714 }
877 }
715
878
716 def("text/x-ceylon", {
879 def("text/x-ceylon", {
717 name: "clike",
880 name: "clike",
718 keywords: words("abstracts alias assembly assert assign break case catch class continue dynamic else" +
881 keywords: words("abstracts alias assembly assert assign break case catch class continue dynamic else" +
719 " exists extends finally for function given if import in interface is let module new" +
882 " exists extends finally for function given if import in interface is let module new" +
720 " nonempty object of out outer package return satisfies super switch then this throw" +
883 " nonempty object of out outer package return satisfies super switch then this throw" +
721 " try value void while"),
884 " try value void while"),
722 types: function(word) {
885 types: function(word) {
723 // In Ceylon all identifiers that start with an uppercase are types
886 // In Ceylon all identifiers that start with an uppercase are types
724 var first = word.charAt(0);
887 var first = word.charAt(0);
725 return (first === first.toUpperCase() && first !== first.toLowerCase());
888 return (first === first.toUpperCase() && first !== first.toLowerCase());
726 },
889 },
727 blockKeywords: words("case catch class dynamic else finally for function if interface module new object switch try while"),
890 blockKeywords: words("case catch class dynamic else finally for function if interface module new object switch try while"),
728 defKeywords: words("class dynamic function interface module object package value"),
891 defKeywords: words("class dynamic function interface module object package value"),
729 builtin: words("abstract actual aliased annotation by default deprecated doc final formal late license" +
892 builtin: words("abstract actual aliased annotation by default deprecated doc final formal late license" +
730 " native optional sealed see serializable shared suppressWarnings tagged throws variable"),
893 " native optional sealed see serializable shared suppressWarnings tagged throws variable"),
731 isPunctuationChar: /[\[\]{}\(\),;\:\.`]/,
894 isPunctuationChar: /[\[\]{}\(\),;\:\.`]/,
732 isOperatorChar: /[+\-*&%=<>!?|^~:\/]/,
895 isOperatorChar: /[+\-*&%=<>!?|^~:\/]/,
733 numberStart: /[\d#$]/,
896 numberStart: /[\d#$]/,
734 number: /^(?:#[\da-fA-F_]+|\$[01_]+|[\d_]+[kMGTPmunpf]?|[\d_]+\.[\d_]+(?:[eE][-+]?\d+|[kMGTPmunpf]|)|)/i,
897 number: /^(?:#[\da-fA-F_]+|\$[01_]+|[\d_]+[kMGTPmunpf]?|[\d_]+\.[\d_]+(?:[eE][-+]?\d+|[kMGTPmunpf]|)|)/i,
735 multiLineStrings: true,
898 multiLineStrings: true,
736 typeFirstDefinitions: true,
899 typeFirstDefinitions: true,
737 atoms: words("true false null larger smaller equal empty finished"),
900 atoms: words("true false null larger smaller equal empty finished"),
738 indentSwitch: false,
901 indentSwitch: false,
739 styleDefs: false,
902 styleDefs: false,
740 hooks: {
903 hooks: {
741 "@": function(stream) {
904 "@": function(stream) {
742 stream.eatWhile(/[\w\$_]/);
905 stream.eatWhile(/[\w\$_]/);
743 return "meta";
906 return "meta";
744 },
907 },
745 '"': function(stream, state) {
908 '"': function(stream, state) {
746 state.tokenize = tokenCeylonString(stream.match('""') ? "triple" : "single");
909 state.tokenize = tokenCeylonString(stream.match('""') ? "triple" : "single");
747 return state.tokenize(stream, state);
910 return state.tokenize(stream, state);
748 },
911 },
749 '`': function(stream, state) {
912 '`': function(stream, state) {
750 if (!stringTokenizer || !stream.match('`')) return false;
913 if (!stringTokenizer || !stream.match('`')) return false;
751 state.tokenize = stringTokenizer;
914 state.tokenize = stringTokenizer;
752 stringTokenizer = null;
915 stringTokenizer = null;
753 return state.tokenize(stream, state);
916 return state.tokenize(stream, state);
754 },
917 },
755 "'": function(stream) {
918 "'": function(stream) {
756 stream.eatWhile(/[\w\$_\xa1-\uffff]/);
919 stream.eatWhile(/[\w\$_\xa1-\uffff]/);
757 return "atom";
920 return "atom";
758 },
921 },
759 token: function(_stream, state, style) {
922 token: function(_stream, state, style) {
760 if ((style == "variable" || style == "variable-3") &&
923 if ((style == "variable" || style == "type") &&
761 state.prevToken == ".") {
924 state.prevToken == ".") {
762 return "variable-2";
925 return "variable-2";
763 }
926 }
764 }
927 }
765 },
928 },
766 modeProps: {
929 modeProps: {
767 fold: ["brace", "import"],
930 fold: ["brace", "import"],
768 closeBrackets: {triples: '"'}
931 closeBrackets: {triples: '"'}
769 }
932 }
770 });
933 });
771
934
772 });
935 });
@@ -1,249 +1,292 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
4 /**
5 * Author: Hans Engel
6 * Branched from CodeMirror's Scheme mode (by Koh Zi Han, based on implementation by Koh Zi Chun)
7 */
8
3
9 (function(mod) {
4 (function(mod) {
10 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports === "object" && typeof module === "object") // CommonJS
11 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
12 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define === "function" && define.amd) // AMD
13 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
14 else // Plain browser env
9 else // Plain browser env
15 mod(CodeMirror);
10 mod(CodeMirror);
16 })(function(CodeMirror) {
11 })(function(CodeMirror) {
17 "use strict";
12 "use strict";
18
13
19 CodeMirror.defineMode("clojure", function (options) {
14 CodeMirror.defineMode("clojure", function (options) {
20 var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", CHARACTER = "string-2",
15 var atoms = ["false", "nil", "true"];
21 ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword", VAR = "variable";
16 var specialForms = [".", "catch", "def", "do", "if", "monitor-enter",
22 var INDENT_WORD_SKIP = options.indentUnit || 2;
17 "monitor-exit", "new", "quote", "recur", "set!", "throw", "try", "var"];
23 var NORMAL_INDENT_UNIT = options.indentUnit || 2;
18 var coreSymbols = ["*", "*'", "*1", "*2", "*3", "*agent*",
19 "*allow-unresolved-vars*", "*assert*", "*clojure-version*",
20 "*command-line-args*", "*compile-files*", "*compile-path*",
21 "*compiler-options*", "*data-readers*", "*default-data-reader-fn*", "*e",
22 "*err*", "*file*", "*flush-on-newline*", "*fn-loader*", "*in*",
23 "*math-context*", "*ns*", "*out*", "*print-dup*", "*print-length*",
24 "*print-level*", "*print-meta*", "*print-namespace-maps*",
25 "*print-readably*", "*read-eval*", "*reader-resolver*", "*source-path*",
26 "*suppress-read*", "*unchecked-math*", "*use-context-classloader*",
27 "*verbose-defrecords*", "*warn-on-reflection*", "+", "+'", "-", "-'",
28 "->", "->>", "->ArrayChunk", "->Eduction", "->Vec", "->VecNode",
29 "->VecSeq", "-cache-protocol-fn", "-reset-methods", "..", "/", "<", "<=",
30 "=", "==", ">", ">=", "EMPTY-NODE", "Inst", "StackTraceElement->vec",
31 "Throwable->map", "accessor", "aclone", "add-classpath", "add-watch",
32 "agent", "agent-error", "agent-errors", "aget", "alength", "alias",
33 "all-ns", "alter", "alter-meta!", "alter-var-root", "amap", "ancestors",
34 "and", "any?", "apply", "areduce", "array-map", "as->", "aset",
35 "aset-boolean", "aset-byte", "aset-char", "aset-double", "aset-float",
36 "aset-int", "aset-long", "aset-short", "assert", "assoc", "assoc!",
37 "assoc-in", "associative?", "atom", "await", "await-for", "await1",
38 "bases", "bean", "bigdec", "bigint", "biginteger", "binding", "bit-and",
39 "bit-and-not", "bit-clear", "bit-flip", "bit-not", "bit-or", "bit-set",
40 "bit-shift-left", "bit-shift-right", "bit-test", "bit-xor", "boolean",
41 "boolean-array", "boolean?", "booleans", "bound-fn", "bound-fn*",
42 "bound?", "bounded-count", "butlast", "byte", "byte-array", "bytes",
43 "bytes?", "case", "cast", "cat", "char", "char-array",
44 "char-escape-string", "char-name-string", "char?", "chars", "chunk",
45 "chunk-append", "chunk-buffer", "chunk-cons", "chunk-first", "chunk-next",
46 "chunk-rest", "chunked-seq?", "class", "class?", "clear-agent-errors",
47 "clojure-version", "coll?", "comment", "commute", "comp", "comparator",
48 "compare", "compare-and-set!", "compile", "complement", "completing",
49 "concat", "cond", "cond->", "cond->>", "condp", "conj", "conj!", "cons",
50 "constantly", "construct-proxy", "contains?", "count", "counted?",
51 "create-ns", "create-struct", "cycle", "dec", "dec'", "decimal?",
52 "declare", "dedupe", "default-data-readers", "definline", "definterface",
53 "defmacro", "defmethod", "defmulti", "defn", "defn-", "defonce",
54 "defprotocol", "defrecord", "defstruct", "deftype", "delay", "delay?",
55 "deliver", "denominator", "deref", "derive", "descendants", "destructure",
56 "disj", "disj!", "dissoc", "dissoc!", "distinct", "distinct?", "doall",
57 "dorun", "doseq", "dosync", "dotimes", "doto", "double", "double-array",
58 "double?", "doubles", "drop", "drop-last", "drop-while", "eduction",
59 "empty", "empty?", "ensure", "ensure-reduced", "enumeration-seq",
60 "error-handler", "error-mode", "eval", "even?", "every-pred", "every?",
61 "ex-data", "ex-info", "extend", "extend-protocol", "extend-type",
62 "extenders", "extends?", "false?", "ffirst", "file-seq", "filter",
63 "filterv", "find", "find-keyword", "find-ns", "find-protocol-impl",
64 "find-protocol-method", "find-var", "first", "flatten", "float",
65 "float-array", "float?", "floats", "flush", "fn", "fn?", "fnext", "fnil",
66 "for", "force", "format", "frequencies", "future", "future-call",
67 "future-cancel", "future-cancelled?", "future-done?", "future?",
68 "gen-class", "gen-interface", "gensym", "get", "get-in", "get-method",
69 "get-proxy-class", "get-thread-bindings", "get-validator", "group-by",
70 "halt-when", "hash", "hash-combine", "hash-map", "hash-ordered-coll",
71 "hash-set", "hash-unordered-coll", "ident?", "identical?", "identity",
72 "if-let", "if-not", "if-some", "ifn?", "import", "in-ns", "inc", "inc'",
73 "indexed?", "init-proxy", "inst-ms", "inst-ms*", "inst?", "instance?",
74 "int", "int-array", "int?", "integer?", "interleave", "intern",
75 "interpose", "into", "into-array", "ints", "io!", "isa?", "iterate",
76 "iterator-seq", "juxt", "keep", "keep-indexed", "key", "keys", "keyword",
77 "keyword?", "last", "lazy-cat", "lazy-seq", "let", "letfn", "line-seq",
78 "list", "list*", "list?", "load", "load-file", "load-reader",
79 "load-string", "loaded-libs", "locking", "long", "long-array", "longs",
80 "loop", "macroexpand", "macroexpand-1", "make-array", "make-hierarchy",
81 "map", "map-entry?", "map-indexed", "map?", "mapcat", "mapv", "max",
82 "max-key", "memfn", "memoize", "merge", "merge-with", "meta",
83 "method-sig", "methods", "min", "min-key", "mix-collection-hash", "mod",
84 "munge", "name", "namespace", "namespace-munge", "nat-int?", "neg-int?",
85 "neg?", "newline", "next", "nfirst", "nil?", "nnext", "not", "not-any?",
86 "not-empty", "not-every?", "not=", "ns", "ns-aliases", "ns-imports",
87 "ns-interns", "ns-map", "ns-name", "ns-publics", "ns-refers",
88 "ns-resolve", "ns-unalias", "ns-unmap", "nth", "nthnext", "nthrest",
89 "num", "number?", "numerator", "object-array", "odd?", "or", "parents",
90 "partial", "partition", "partition-all", "partition-by", "pcalls", "peek",
91 "persistent!", "pmap", "pop", "pop!", "pop-thread-bindings", "pos-int?",
92 "pos?", "pr", "pr-str", "prefer-method", "prefers",
93 "primitives-classnames", "print", "print-ctor", "print-dup",
94 "print-method", "print-simple", "print-str", "printf", "println",
95 "println-str", "prn", "prn-str", "promise", "proxy",
96 "proxy-call-with-super", "proxy-mappings", "proxy-name", "proxy-super",
97 "push-thread-bindings", "pvalues", "qualified-ident?",
98 "qualified-keyword?", "qualified-symbol?", "quot", "rand", "rand-int",
99 "rand-nth", "random-sample", "range", "ratio?", "rational?",
100 "rationalize", "re-find", "re-groups", "re-matcher", "re-matches",
101 "re-pattern", "re-seq", "read", "read-line", "read-string",
102 "reader-conditional", "reader-conditional?", "realized?", "record?",
103 "reduce", "reduce-kv", "reduced", "reduced?", "reductions", "ref",
104 "ref-history-count", "ref-max-history", "ref-min-history", "ref-set",
105 "refer", "refer-clojure", "reify", "release-pending-sends", "rem",
106 "remove", "remove-all-methods", "remove-method", "remove-ns",
107 "remove-watch", "repeat", "repeatedly", "replace", "replicate", "require",
108 "reset!", "reset-meta!", "reset-vals!", "resolve", "rest",
109 "restart-agent", "resultset-seq", "reverse", "reversible?", "rseq",
110 "rsubseq", "run!", "satisfies?", "second", "select-keys", "send",
111 "send-off", "send-via", "seq", "seq?", "seqable?", "seque", "sequence",
112 "sequential?", "set", "set-agent-send-executor!",
113 "set-agent-send-off-executor!", "set-error-handler!", "set-error-mode!",
114 "set-validator!", "set?", "short", "short-array", "shorts", "shuffle",
115 "shutdown-agents", "simple-ident?", "simple-keyword?", "simple-symbol?",
116 "slurp", "some", "some->", "some->>", "some-fn", "some?", "sort",
117 "sort-by", "sorted-map", "sorted-map-by", "sorted-set", "sorted-set-by",
118 "sorted?", "special-symbol?", "spit", "split-at", "split-with", "str",
119 "string?", "struct", "struct-map", "subs", "subseq", "subvec", "supers",
120 "swap!", "swap-vals!", "symbol", "symbol?", "sync", "tagged-literal",
121 "tagged-literal?", "take", "take-last", "take-nth", "take-while", "test",
122 "the-ns", "thread-bound?", "time", "to-array", "to-array-2d",
123 "trampoline", "transduce", "transient", "tree-seq", "true?", "type",
124 "unchecked-add", "unchecked-add-int", "unchecked-byte", "unchecked-char",
125 "unchecked-dec", "unchecked-dec-int", "unchecked-divide-int",
126 "unchecked-double", "unchecked-float", "unchecked-inc",
127 "unchecked-inc-int", "unchecked-int", "unchecked-long",
128 "unchecked-multiply", "unchecked-multiply-int", "unchecked-negate",
129 "unchecked-negate-int", "unchecked-remainder-int", "unchecked-short",
130 "unchecked-subtract", "unchecked-subtract-int", "underive", "unquote",
131 "unquote-splicing", "unreduced", "unsigned-bit-shift-right", "update",
132 "update-in", "update-proxy", "uri?", "use", "uuid?", "val", "vals",
133 "var-get", "var-set", "var?", "vary-meta", "vec", "vector", "vector-of",
134 "vector?", "volatile!", "volatile?", "vreset!", "vswap!", "when",
135 "when-first", "when-let", "when-not", "when-some", "while",
136 "with-bindings", "with-bindings*", "with-in-str", "with-loading-context",
137 "with-local-vars", "with-meta", "with-open", "with-out-str",
138 "with-precision", "with-redefs", "with-redefs-fn", "xml-seq", "zero?",
139 "zipmap"];
140 var haveBodyParameter = [
141 "->", "->>", "as->", "binding", "bound-fn", "case", "catch", "comment",
142 "cond", "cond->", "cond->>", "condp", "def", "definterface", "defmethod",
143 "defn", "defmacro", "defprotocol", "defrecord", "defstruct", "deftype",
144 "do", "doseq", "dotimes", "doto", "extend", "extend-protocol",
145 "extend-type", "fn", "for", "future", "if", "if-let", "if-not", "if-some",
146 "let", "letfn", "locking", "loop", "ns", "proxy", "reify", "struct-map",
147 "some->", "some->>", "try", "when", "when-first", "when-let", "when-not",
148 "when-some", "while", "with-bindings", "with-bindings*", "with-in-str",
149 "with-loading-context", "with-local-vars", "with-meta", "with-open",
150 "with-out-str", "with-precision", "with-redefs", "with-redefs-fn"];
24
151
25 function makeKeywords(str) {
152 CodeMirror.registerHelper("hintWords", "clojure",
26 var obj = {}, words = str.split(" ");
153 [].concat(atoms, specialForms, coreSymbols));
154
155 var atom = createLookupMap(atoms);
156 var specialForm = createLookupMap(specialForms);
157 var coreSymbol = createLookupMap(coreSymbols);
158 var hasBodyParameter = createLookupMap(haveBodyParameter);
159 var delimiter = /^(?:[\\\[\]\s"(),;@^`{}~]|$)/;
160 var numberLiteral = /^(?:[+\-]?\d+(?:(?:N|(?:[eE][+\-]?\d+))|(?:\.?\d*(?:M|(?:[eE][+\-]?\d+))?)|\/\d+|[xX][0-9a-fA-F]+|r[0-9a-zA-Z]+)?(?=[\\\[\]\s"#'(),;@^`{}~]|$))/;
161 var characterLiteral = /^(?:\\(?:backspace|formfeed|newline|return|space|tab|o[0-7]{3}|u[0-9A-Fa-f]{4}|x[0-9A-Fa-f]{4}|.)?(?=[\\\[\]\s"(),;@^`{}~]|$))/;
162
163 // simple-namespace := /^[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*/
164 // simple-symbol := /^(?:\/|[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)/
165 // qualified-symbol := (<simple-namespace>(<.><simple-namespace>)*</>)?<simple-symbol>
166 var qualifiedSymbol = /^(?:(?:[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*(?:\.[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)*\/)?(?:\/|[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)*(?=[\\\[\]\s"(),;@^`{}~]|$))/;
167
168 function base(stream, state) {
169 if (stream.eatSpace() || stream.eat(",")) return ["space", null];
170 if (stream.match(numberLiteral)) return [null, "number"];
171 if (stream.match(characterLiteral)) return [null, "string-2"];
172 if (stream.eat(/^"/)) return (state.tokenize = inString)(stream, state);
173 if (stream.eat(/^[(\[{]/)) return ["open", "bracket"];
174 if (stream.eat(/^[)\]}]/)) return ["close", "bracket"];
175 if (stream.eat(/^;/)) {stream.skipToEnd(); return ["space", "comment"];}
176 if (stream.eat(/^[#'@^`~]/)) return [null, "meta"];
177
178 var matches = stream.match(qualifiedSymbol);
179 var symbol = matches && matches[0];
180
181 if (!symbol) {
182 // advance stream by at least one character so we don't get stuck.
183 stream.next();
184 stream.eatWhile(function (c) {return !is(c, delimiter);});
185 return [null, "error"];
186 }
187
188 if (symbol === "comment" && state.lastToken === "(")
189 return (state.tokenize = inComment)(stream, state);
190 if (is(symbol, atom) || symbol.charAt(0) === ":") return ["symbol", "atom"];
191 if (is(symbol, specialForm) || is(symbol, coreSymbol)) return ["symbol", "keyword"];
192 if (state.lastToken === "(") return ["symbol", "builtin"]; // other operator
193
194 return ["symbol", "variable"];
195 }
196
197 function inString(stream, state) {
198 var escaped = false, next;
199
200 while (next = stream.next()) {
201 if (next === "\"" && !escaped) {state.tokenize = base; break;}
202 escaped = !escaped && next === "\\";
203 }
204
205 return [null, "string"];
206 }
207
208 function inComment(stream, state) {
209 var parenthesisCount = 1;
210 var next;
211
212 while (next = stream.next()) {
213 if (next === ")") parenthesisCount--;
214 if (next === "(") parenthesisCount++;
215 if (parenthesisCount === 0) {
216 stream.backUp(1);
217 state.tokenize = base;
218 break;
219 }
220 }
221
222 return ["space", "comment"];
223 }
224
225 function createLookupMap(words) {
226 var obj = {};
227
27 for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
228 for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
229
28 return obj;
230 return obj;
29 }
231 }
30
232
31 var atoms = makeKeywords("true false nil");
233 function is(value, test) {
32
234 if (test instanceof RegExp) return test.test(value);
33 var keywords = makeKeywords(
235 if (test instanceof Object) return test.propertyIsEnumerable(value);
34 "defn defn- def def- defonce defmulti defmethod defmacro defstruct deftype defprotocol defrecord defproject deftest slice defalias defhinted defmacro- defn-memo defnk defnk defonce- defunbound defunbound- defvar defvar- let letfn do case cond condp for loop recur when when-not when-let when-first if if-let if-not . .. -> ->> doto and or dosync doseq dotimes dorun doall load import unimport ns in-ns refer try catch finally throw with-open with-local-vars binding gen-class gen-and-load-class gen-and-save-class handler-case handle");
35
36 var builtins = makeKeywords(
37 "* *' *1 *2 *3 *agent* *allow-unresolved-vars* *assert* *clojure-version* *command-line-args* *compile-files* *compile-path* *compiler-options* *data-readers* *e *err* *file* *flush-on-newline* *fn-loader* *in* *math-context* *ns* *out* *print-dup* *print-length* *print-level* *print-meta* *print-readably* *read-eval* *source-path* *unchecked-math* *use-context-classloader* *verbose-defrecords* *warn-on-reflection* + +' - -' -> ->> ->ArrayChunk ->Vec ->VecNode ->VecSeq -cache-protocol-fn -reset-methods .. / < <= = == > >= EMPTY-NODE accessor aclone add-classpath add-watch agent agent-error agent-errors aget alength alias all-ns alter alter-meta! alter-var-root amap ancestors and apply areduce array-map aset aset-boolean aset-byte aset-char aset-double aset-float aset-int aset-long aset-short assert assoc assoc! assoc-in associative? atom await await-for await1 bases bean bigdec bigint biginteger binding bit-and bit-and-not bit-clear bit-flip bit-not bit-or bit-set bit-shift-left bit-shift-right bit-test bit-xor boolean boolean-array booleans bound-fn bound-fn* bound? butlast byte byte-array bytes case cast char char-array char-escape-string char-name-string char? chars chunk chunk-append chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? class class? clear-agent-errors clojure-version coll? comment commute comp comparator compare compare-and-set! compile complement concat cond condp conj conj! cons constantly construct-proxy contains? count counted? create-ns create-struct cycle dec dec' decimal? declare default-data-readers definline definterface defmacro defmethod defmulti defn defn- defonce defprotocol defrecord defstruct deftype delay delay? deliver denominator deref derive descendants destructure disj disj! dissoc dissoc! distinct distinct? doall dorun doseq dosync dotimes doto double double-array doubles drop drop-last drop-while empty empty? ensure enumeration-seq error-handler error-mode eval even? every-pred every? ex-data ex-info extend extend-protocol extend-type extenders extends? false? ffirst file-seq filter filterv find find-keyword find-ns find-protocol-impl find-protocol-method find-var first flatten float float-array float? floats flush fn fn? fnext fnil for force format frequencies future future-call future-cancel future-cancelled? future-done? future? gen-class gen-interface gensym get get-in get-method get-proxy-class get-thread-bindings get-validator group-by hash hash-combine hash-map hash-set identical? identity if-let if-not ifn? import in-ns inc inc' init-proxy instance? int int-array integer? interleave intern interpose into into-array ints io! isa? iterate iterator-seq juxt keep keep-indexed key keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list list* list? load load-file load-reader load-string loaded-libs locking long long-array longs loop macroexpand macroexpand-1 make-array make-hierarchy map map-indexed map? mapcat mapv max max-key memfn memoize merge merge-with meta method-sig methods min min-key mod munge name namespace namespace-munge neg? newline next nfirst nil? nnext not not-any? not-empty not-every? not= ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ns-refers ns-resolve ns-unalias ns-unmap nth nthnext nthrest num number? numerator object-array odd? or parents partial partition partition-all partition-by pcalls peek persistent! pmap pop pop! pop-thread-bindings pos? pr pr-str prefer-method prefers primitives-classnames print print-ctor print-dup print-method print-simple print-str printf println println-str prn prn-str promise proxy proxy-call-with-super proxy-mappings proxy-name proxy-super push-thread-bindings pvalues quot rand rand-int rand-nth range ratio? rational? rationalize re-find re-groups re-matcher re-matches re-pattern re-seq read read-line read-string realized? reduce reduce-kv reductions ref ref-history-count ref-max-history ref-min-history ref-set refer refer-clojure reify release-pending-sends rem remove remove-all-methods remove-method remove-ns remove-watch repeat repeatedly replace replicate require reset! reset-meta! resolve rest restart-agent resultset-seq reverse reversible? rseq rsubseq satisfies? second select-keys send send-off seq seq? seque sequence sequential? set set-error-handler! set-error-mode! set-validator! set? short short-array shorts shuffle shutdown-agents slurp some some-fn sort sort-by sorted-map sorted-map-by sorted-set sorted-set-by sorted? special-symbol? spit split-at split-with str string? struct struct-map subs subseq subvec supers swap! symbol symbol? sync take take-last take-nth take-while test the-ns thread-bound? time to-array to-array-2d trampoline transient tree-seq true? type unchecked-add unchecked-add-int unchecked-byte unchecked-char unchecked-dec unchecked-dec-int unchecked-divide-int unchecked-double unchecked-float unchecked-inc unchecked-inc-int unchecked-int unchecked-long unchecked-multiply unchecked-multiply-int unchecked-negate unchecked-negate-int unchecked-remainder-int unchecked-short unchecked-subtract unchecked-subtract-int underive unquote unquote-splicing update-in update-proxy use val vals var-get var-set var? vary-meta vec vector vector-of vector? when when-first when-let when-not while with-bindings with-bindings* with-in-str with-loading-context with-local-vars with-meta with-open with-out-str with-precision with-redefs with-redefs-fn xml-seq zero? zipmap *default-data-reader-fn* as-> cond-> cond->> reduced reduced? send-via set-agent-send-executor! set-agent-send-off-executor! some-> some->>");
38
39 var indentKeys = makeKeywords(
40 // Built-ins
41 "ns fn def defn defmethod bound-fn if if-not case condp when while when-not when-first do future comment doto locking proxy with-open with-precision reify deftype defrecord defprotocol extend extend-protocol extend-type try catch " +
42
43 // Binding forms
44 "let letfn binding loop for doseq dotimes when-let if-let " +
45
46 // Data structures
47 "defstruct struct-map assoc " +
48
49 // clojure.test
50 "testing deftest " +
51
52 // contrib
53 "handler-case handle dotrace deftrace");
54
55 var tests = {
56 digit: /\d/,
57 digit_or_colon: /[\d:]/,
58 hex: /[0-9a-f]/i,
59 sign: /[+-]/,
60 exponent: /e/i,
61 keyword_char: /[^\s\(\[\;\)\]]/,
62 symbol: /[\w*+!\-\._?:<>\/\xa1-\uffff]/,
63 block_indent: /^(?:def|with)[^\/]+$|\/(?:def|with)/
64 };
65
66 function stateStack(indent, type, prev) { // represents a state stack object
67 this.indent = indent;
68 this.type = type;
69 this.prev = prev;
70 }
71
72 function pushStack(state, indent, type) {
73 state.indentStack = new stateStack(indent, type, state.indentStack);
74 }
75
76 function popStack(state) {
77 state.indentStack = state.indentStack.prev;
78 }
79
80 function isNumber(ch, stream){
81 // hex
82 if ( ch === '0' && stream.eat(/x/i) ) {
83 stream.eatWhile(tests.hex);
84 return true;
85 }
86
87 // leading sign
88 if ( ( ch == '+' || ch == '-' ) && ( tests.digit.test(stream.peek()) ) ) {
89 stream.eat(tests.sign);
90 ch = stream.next();
91 }
92
93 if ( tests.digit.test(ch) ) {
94 stream.eat(ch);
95 stream.eatWhile(tests.digit);
96
97 if ( '.' == stream.peek() ) {
98 stream.eat('.');
99 stream.eatWhile(tests.digit);
100 } else if ('/' == stream.peek() ) {
101 stream.eat('/');
102 stream.eatWhile(tests.digit);
103 }
104
105 if ( stream.eat(tests.exponent) ) {
106 stream.eat(tests.sign);
107 stream.eatWhile(tests.digit);
108 }
109
110 return true;
111 }
112
113 return false;
114 }
115
116 // Eat character that starts after backslash \
117 function eatCharacter(stream) {
118 var first = stream.next();
119 // Read special literals: backspace, newline, space, return.
120 // Just read all lowercase letters.
121 if (first && first.match(/[a-z]/) && stream.match(/[a-z]+/, true)) {
122 return;
123 }
124 // Read unicode character: \u1000 \uA0a1
125 if (first === "u") {
126 stream.match(/[0-9a-z]{4}/i, true);
127 }
128 }
236 }
129
237
130 return {
238 return {
131 startState: function () {
239 startState: function () {
132 return {
240 return {
133 indentStack: null,
241 ctx: {prev: null, start: 0, indentTo: 0},
134 indentation: 0,
242 lastToken: null,
135 mode: false
243 tokenize: base
136 };
244 };
137 },
245 },
138
246
139 token: function (stream, state) {
247 token: function (stream, state) {
140 if (state.indentStack == null && stream.sol()) {
248 if (stream.sol() && (typeof state.ctx.indentTo !== "number"))
141 // update indentation, but only if indentStack is empty
249 state.ctx.indentTo = state.ctx.start + 1;
142 state.indentation = stream.indentation();
250
251 var typeStylePair = state.tokenize(stream, state);
252 var type = typeStylePair[0];
253 var style = typeStylePair[1];
254 var current = stream.current();
255
256 if (type !== "space") {
257 if (state.lastToken === "(" && state.ctx.indentTo === null) {
258 if (type === "symbol" && is(current, hasBodyParameter))
259 state.ctx.indentTo = state.ctx.start + options.indentUnit;
260 else state.ctx.indentTo = "next";
261 } else if (state.ctx.indentTo === "next") {
262 state.ctx.indentTo = stream.column();
143 }
263 }
144
264
145 // skip spaces
265 state.lastToken = current;
146 if (state.mode != "string" && stream.eatSpace()) {
147 return null;
148 }
149 var returnType = null;
150
151 switch(state.mode){
152 case "string": // multi-line string parsing mode
153 var next, escaped = false;
154 while ((next = stream.next()) != null) {
155 if (next == "\"" && !escaped) {
156
157 state.mode = false;
158 break;
159 }
160 escaped = !escaped && next == "\\";
161 }
162 returnType = STRING; // continue on in string mode
163 break;
164 default: // default parsing mode
165 var ch = stream.next();
166
167 if (ch == "\"") {
168 state.mode = "string";
169 returnType = STRING;
170 } else if (ch == "\\") {
171 eatCharacter(stream);
172 returnType = CHARACTER;
173 } else if (ch == "'" && !( tests.digit_or_colon.test(stream.peek()) )) {
174 returnType = ATOM;
175 } else if (ch == ";") { // comment
176 stream.skipToEnd(); // rest of the line is a comment
177 returnType = COMMENT;
178 } else if (isNumber(ch,stream)){
179 returnType = NUMBER;
180 } else if (ch == "(" || ch == "[" || ch == "{" ) {
181 var keyWord = '', indentTemp = stream.column(), letter;
182 /**
183 Either
184 (indent-word ..
185 (non-indent-word ..
186 (;something else, bracket, etc.
187 */
188
189 if (ch == "(") while ((letter = stream.eat(tests.keyword_char)) != null) {
190 keyWord += letter;
191 }
266 }
192
267
193 if (keyWord.length > 0 && (indentKeys.propertyIsEnumerable(keyWord) ||
268 if (type === "open")
194 tests.block_indent.test(keyWord))) { // indent-word
269 state.ctx = {prev: state.ctx, start: stream.column(), indentTo: null};
195 pushStack(state, indentTemp + INDENT_WORD_SKIP, ch);
270 else if (type === "close") state.ctx = state.ctx.prev || state.ctx;
196 } else { // non-indent word
197 // we continue eating the spaces
198 stream.eatSpace();
199 if (stream.eol() || stream.peek() == ";") {
200 // nothing significant after
201 // we restart indentation the user defined spaces after
202 pushStack(state, indentTemp + NORMAL_INDENT_UNIT, ch);
203 } else {
204 pushStack(state, indentTemp + stream.current().length, ch); // else we match
205 }
206 }
207 stream.backUp(stream.current().length - 1); // undo all the eating
208
271
209 returnType = BRACKET;
272 return style;
210 } else if (ch == ")" || ch == "]" || ch == "}") {
211 returnType = BRACKET;
212 if (state.indentStack != null && state.indentStack.type == (ch == ")" ? "(" : (ch == "]" ? "[" :"{"))) {
213 popStack(state);
214 }
215 } else if ( ch == ":" ) {
216 stream.eatWhile(tests.symbol);
217 return ATOM;
218 } else {
219 stream.eatWhile(tests.symbol);
220
221 if (keywords && keywords.propertyIsEnumerable(stream.current())) {
222 returnType = KEYWORD;
223 } else if (builtins && builtins.propertyIsEnumerable(stream.current())) {
224 returnType = BUILTIN;
225 } else if (atoms && atoms.propertyIsEnumerable(stream.current())) {
226 returnType = ATOM;
227 } else {
228 returnType = VAR;
229 }
230 }
231 }
232
233 return returnType;
234 },
273 },
235
274
236 indent: function (state) {
275 indent: function (state) {
237 if (state.indentStack == null) return state.indentation;
276 var i = state.ctx.indentTo;
238 return state.indentStack.indent;
277
278 return (typeof i === "number") ?
279 i :
280 state.ctx.start + 1;
239 },
281 },
240
282
241 closeBrackets: {pairs: "()[]{}\"\""},
283 closeBrackets: {pairs: "()[]{}\"\""},
242 lineComment: ";;"
284 lineComment: ";;"
243 };
285 };
244 });
286 });
245
287
246 CodeMirror.defineMIME("text/x-clojure", "clojure");
288 CodeMirror.defineMIME("text/x-clojure", "clojure");
247 CodeMirror.defineMIME("text/x-clojurescript", "clojure");
289 CodeMirror.defineMIME("text/x-clojurescript", "clojure");
290 CodeMirror.defineMIME("application/edn", "clojure");
248
291
249 });
292 });
@@ -1,97 +1,97 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object")
5 if (typeof exports == "object" && typeof module == "object")
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd)
7 else if (typeof define == "function" && define.amd)
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else
9 else
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("cmake", function () {
14 CodeMirror.defineMode("cmake", function () {
15 var variable_regex = /({)?[a-zA-Z0-9_]+(})?/;
15 var variable_regex = /({)?[a-zA-Z0-9_]+(})?/;
16
16
17 function tokenString(stream, state) {
17 function tokenString(stream, state) {
18 var current, prev, found_var = false;
18 var current, prev, found_var = false;
19 while (!stream.eol() && (current = stream.next()) != state.pending) {
19 while (!stream.eol() && (current = stream.next()) != state.pending) {
20 if (current === '$' && prev != '\\' && state.pending == '"') {
20 if (current === '$' && prev != '\\' && state.pending == '"') {
21 found_var = true;
21 found_var = true;
22 break;
22 break;
23 }
23 }
24 prev = current;
24 prev = current;
25 }
25 }
26 if (found_var) {
26 if (found_var) {
27 stream.backUp(1);
27 stream.backUp(1);
28 }
28 }
29 if (current == state.pending) {
29 if (current == state.pending) {
30 state.continueString = false;
30 state.continueString = false;
31 } else {
31 } else {
32 state.continueString = true;
32 state.continueString = true;
33 }
33 }
34 return "string";
34 return "string";
35 }
35 }
36
36
37 function tokenize(stream, state) {
37 function tokenize(stream, state) {
38 var ch = stream.next();
38 var ch = stream.next();
39
39
40 // Have we found a variable?
40 // Have we found a variable?
41 if (ch === '$') {
41 if (ch === '$') {
42 if (stream.match(variable_regex)) {
42 if (stream.match(variable_regex)) {
43 return 'variable-2';
43 return 'variable-2';
44 }
44 }
45 return 'variable';
45 return 'variable';
46 }
46 }
47 // Should we still be looking for the end of a string?
47 // Should we still be looking for the end of a string?
48 if (state.continueString) {
48 if (state.continueString) {
49 // If so, go through the loop again
49 // If so, go through the loop again
50 stream.backUp(1);
50 stream.backUp(1);
51 return tokenString(stream, state);
51 return tokenString(stream, state);
52 }
52 }
53 // Do we just have a function on our hands?
53 // Do we just have a function on our hands?
54 // In 'cmake_minimum_required (VERSION 2.8.8)', 'cmake_minimum_required' is matched
54 // In 'cmake_minimum_required (VERSION 2.8.8)', 'cmake_minimum_required' is matched
55 if (stream.match(/(\s+)?\w+\(/) || stream.match(/(\s+)?\w+\ \(/)) {
55 if (stream.match(/(\s+)?\w+\(/) || stream.match(/(\s+)?\w+\ \(/)) {
56 stream.backUp(1);
56 stream.backUp(1);
57 return 'def';
57 return 'def';
58 }
58 }
59 if (ch == "#") {
59 if (ch == "#") {
60 stream.skipToEnd();
60 stream.skipToEnd();
61 return "comment";
61 return "comment";
62 }
62 }
63 // Have we found a string?
63 // Have we found a string?
64 if (ch == "'" || ch == '"') {
64 if (ch == "'" || ch == '"') {
65 // Store the type (single or double)
65 // Store the type (single or double)
66 state.pending = ch;
66 state.pending = ch;
67 // Perform the looping function to find the end
67 // Perform the looping function to find the end
68 return tokenString(stream, state);
68 return tokenString(stream, state);
69 }
69 }
70 if (ch == '(' || ch == ')') {
70 if (ch == '(' || ch == ')') {
71 return 'bracket';
71 return 'bracket';
72 }
72 }
73 if (ch.match(/[0-9]/)) {
73 if (ch.match(/[0-9]/)) {
74 return 'number';
74 return 'number';
75 }
75 }
76 stream.eatWhile(/[\w-]/);
76 stream.eatWhile(/[\w-]/);
77 return null;
77 return null;
78 }
78 }
79 return {
79 return {
80 startState: function () {
80 startState: function () {
81 var state = {};
81 var state = {};
82 state.inDefinition = false;
82 state.inDefinition = false;
83 state.inInclude = false;
83 state.inInclude = false;
84 state.continueString = false;
84 state.continueString = false;
85 state.pending = false;
85 state.pending = false;
86 return state;
86 return state;
87 },
87 },
88 token: function (stream, state) {
88 token: function (stream, state) {
89 if (stream.eatSpace()) return null;
89 if (stream.eatSpace()) return null;
90 return tokenize(stream, state);
90 return tokenize(stream, state);
91 }
91 }
92 };
92 };
93 });
93 });
94
94
95 CodeMirror.defineMIME("text/x-cmake", "cmake");
95 CodeMirror.defineMIME("text/x-cmake", "cmake");
96
96
97 });
97 });
@@ -1,255 +1,255 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 /**
4 /**
5 * Author: Gautam Mehta
5 * Author: Gautam Mehta
6 * Branched from CodeMirror's Scheme mode
6 * Branched from CodeMirror's Scheme mode
7 */
7 */
8 (function(mod) {
8 (function(mod) {
9 if (typeof exports == "object" && typeof module == "object") // CommonJS
9 if (typeof exports == "object" && typeof module == "object") // CommonJS
10 mod(require("../../lib/codemirror"));
10 mod(require("../../lib/codemirror"));
11 else if (typeof define == "function" && define.amd) // AMD
11 else if (typeof define == "function" && define.amd) // AMD
12 define(["../../lib/codemirror"], mod);
12 define(["../../lib/codemirror"], mod);
13 else // Plain browser env
13 else // Plain browser env
14 mod(CodeMirror);
14 mod(CodeMirror);
15 })(function(CodeMirror) {
15 })(function(CodeMirror) {
16 "use strict";
16 "use strict";
17
17
18 CodeMirror.defineMode("cobol", function () {
18 CodeMirror.defineMode("cobol", function () {
19 var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
19 var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
20 ATOM = "atom", NUMBER = "number", KEYWORD = "keyword", MODTAG = "header",
20 ATOM = "atom", NUMBER = "number", KEYWORD = "keyword", MODTAG = "header",
21 COBOLLINENUM = "def", PERIOD = "link";
21 COBOLLINENUM = "def", PERIOD = "link";
22 function makeKeywords(str) {
22 function makeKeywords(str) {
23 var obj = {}, words = str.split(" ");
23 var obj = {}, words = str.split(" ");
24 for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
24 for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
25 return obj;
25 return obj;
26 }
26 }
27 var atoms = makeKeywords("TRUE FALSE ZEROES ZEROS ZERO SPACES SPACE LOW-VALUE LOW-VALUES ");
27 var atoms = makeKeywords("TRUE FALSE ZEROES ZEROS ZERO SPACES SPACE LOW-VALUE LOW-VALUES ");
28 var keywords = makeKeywords(
28 var keywords = makeKeywords(
29 "ACCEPT ACCESS ACQUIRE ADD ADDRESS " +
29 "ACCEPT ACCESS ACQUIRE ADD ADDRESS " +
30 "ADVANCING AFTER ALIAS ALL ALPHABET " +
30 "ADVANCING AFTER ALIAS ALL ALPHABET " +
31 "ALPHABETIC ALPHABETIC-LOWER ALPHABETIC-UPPER ALPHANUMERIC ALPHANUMERIC-EDITED " +
31 "ALPHABETIC ALPHABETIC-LOWER ALPHABETIC-UPPER ALPHANUMERIC ALPHANUMERIC-EDITED " +
32 "ALSO ALTER ALTERNATE AND ANY " +
32 "ALSO ALTER ALTERNATE AND ANY " +
33 "ARE AREA AREAS ARITHMETIC ASCENDING " +
33 "ARE AREA AREAS ARITHMETIC ASCENDING " +
34 "ASSIGN AT ATTRIBUTE AUTHOR AUTO " +
34 "ASSIGN AT ATTRIBUTE AUTHOR AUTO " +
35 "AUTO-SKIP AUTOMATIC B-AND B-EXOR B-LESS " +
35 "AUTO-SKIP AUTOMATIC B-AND B-EXOR B-LESS " +
36 "B-NOT B-OR BACKGROUND-COLOR BACKGROUND-COLOUR BEEP " +
36 "B-NOT B-OR BACKGROUND-COLOR BACKGROUND-COLOUR BEEP " +
37 "BEFORE BELL BINARY BIT BITS " +
37 "BEFORE BELL BINARY BIT BITS " +
38 "BLANK BLINK BLOCK BOOLEAN BOTTOM " +
38 "BLANK BLINK BLOCK BOOLEAN BOTTOM " +
39 "BY CALL CANCEL CD CF " +
39 "BY CALL CANCEL CD CF " +
40 "CH CHARACTER CHARACTERS CLASS CLOCK-UNITS " +
40 "CH CHARACTER CHARACTERS CLASS CLOCK-UNITS " +
41 "CLOSE COBOL CODE CODE-SET COL " +
41 "CLOSE COBOL CODE CODE-SET COL " +
42 "COLLATING COLUMN COMMA COMMIT COMMITMENT " +
42 "COLLATING COLUMN COMMA COMMIT COMMITMENT " +
43 "COMMON COMMUNICATION COMP COMP-0 COMP-1 " +
43 "COMMON COMMUNICATION COMP COMP-0 COMP-1 " +
44 "COMP-2 COMP-3 COMP-4 COMP-5 COMP-6 " +
44 "COMP-2 COMP-3 COMP-4 COMP-5 COMP-6 " +
45 "COMP-7 COMP-8 COMP-9 COMPUTATIONAL COMPUTATIONAL-0 " +
45 "COMP-7 COMP-8 COMP-9 COMPUTATIONAL COMPUTATIONAL-0 " +
46 "COMPUTATIONAL-1 COMPUTATIONAL-2 COMPUTATIONAL-3 COMPUTATIONAL-4 COMPUTATIONAL-5 " +
46 "COMPUTATIONAL-1 COMPUTATIONAL-2 COMPUTATIONAL-3 COMPUTATIONAL-4 COMPUTATIONAL-5 " +
47 "COMPUTATIONAL-6 COMPUTATIONAL-7 COMPUTATIONAL-8 COMPUTATIONAL-9 COMPUTE " +
47 "COMPUTATIONAL-6 COMPUTATIONAL-7 COMPUTATIONAL-8 COMPUTATIONAL-9 COMPUTE " +
48 "CONFIGURATION CONNECT CONSOLE CONTAINED CONTAINS " +
48 "CONFIGURATION CONNECT CONSOLE CONTAINED CONTAINS " +
49 "CONTENT CONTINUE CONTROL CONTROL-AREA CONTROLS " +
49 "CONTENT CONTINUE CONTROL CONTROL-AREA CONTROLS " +
50 "CONVERTING COPY CORR CORRESPONDING COUNT " +
50 "CONVERTING COPY CORR CORRESPONDING COUNT " +
51 "CRT CRT-UNDER CURRENCY CURRENT CURSOR " +
51 "CRT CRT-UNDER CURRENCY CURRENT CURSOR " +
52 "DATA DATE DATE-COMPILED DATE-WRITTEN DAY " +
52 "DATA DATE DATE-COMPILED DATE-WRITTEN DAY " +
53 "DAY-OF-WEEK DB DB-ACCESS-CONTROL-KEY DB-DATA-NAME DB-EXCEPTION " +
53 "DAY-OF-WEEK DB DB-ACCESS-CONTROL-KEY DB-DATA-NAME DB-EXCEPTION " +
54 "DB-FORMAT-NAME DB-RECORD-NAME DB-SET-NAME DB-STATUS DBCS " +
54 "DB-FORMAT-NAME DB-RECORD-NAME DB-SET-NAME DB-STATUS DBCS " +
55 "DBCS-EDITED DE DEBUG-CONTENTS DEBUG-ITEM DEBUG-LINE " +
55 "DBCS-EDITED DE DEBUG-CONTENTS DEBUG-ITEM DEBUG-LINE " +
56 "DEBUG-NAME DEBUG-SUB-1 DEBUG-SUB-2 DEBUG-SUB-3 DEBUGGING " +
56 "DEBUG-NAME DEBUG-SUB-1 DEBUG-SUB-2 DEBUG-SUB-3 DEBUGGING " +
57 "DECIMAL-POINT DECLARATIVES DEFAULT DELETE DELIMITED " +
57 "DECIMAL-POINT DECLARATIVES DEFAULT DELETE DELIMITED " +
58 "DELIMITER DEPENDING DESCENDING DESCRIBED DESTINATION " +
58 "DELIMITER DEPENDING DESCENDING DESCRIBED DESTINATION " +
59 "DETAIL DISABLE DISCONNECT DISPLAY DISPLAY-1 " +
59 "DETAIL DISABLE DISCONNECT DISPLAY DISPLAY-1 " +
60 "DISPLAY-2 DISPLAY-3 DISPLAY-4 DISPLAY-5 DISPLAY-6 " +
60 "DISPLAY-2 DISPLAY-3 DISPLAY-4 DISPLAY-5 DISPLAY-6 " +
61 "DISPLAY-7 DISPLAY-8 DISPLAY-9 DIVIDE DIVISION " +
61 "DISPLAY-7 DISPLAY-8 DISPLAY-9 DIVIDE DIVISION " +
62 "DOWN DROP DUPLICATE DUPLICATES DYNAMIC " +
62 "DOWN DROP DUPLICATE DUPLICATES DYNAMIC " +
63 "EBCDIC EGI EJECT ELSE EMI " +
63 "EBCDIC EGI EJECT ELSE EMI " +
64 "EMPTY EMPTY-CHECK ENABLE END END. END-ACCEPT END-ACCEPT. " +
64 "EMPTY EMPTY-CHECK ENABLE END END. END-ACCEPT END-ACCEPT. " +
65 "END-ADD END-CALL END-COMPUTE END-DELETE END-DISPLAY " +
65 "END-ADD END-CALL END-COMPUTE END-DELETE END-DISPLAY " +
66 "END-DIVIDE END-EVALUATE END-IF END-INVOKE END-MULTIPLY " +
66 "END-DIVIDE END-EVALUATE END-IF END-INVOKE END-MULTIPLY " +
67 "END-OF-PAGE END-PERFORM END-READ END-RECEIVE END-RETURN " +
67 "END-OF-PAGE END-PERFORM END-READ END-RECEIVE END-RETURN " +
68 "END-REWRITE END-SEARCH END-START END-STRING END-SUBTRACT " +
68 "END-REWRITE END-SEARCH END-START END-STRING END-SUBTRACT " +
69 "END-UNSTRING END-WRITE END-XML ENTER ENTRY " +
69 "END-UNSTRING END-WRITE END-XML ENTER ENTRY " +
70 "ENVIRONMENT EOP EQUAL EQUALS ERASE " +
70 "ENVIRONMENT EOP EQUAL EQUALS ERASE " +
71 "ERROR ESI EVALUATE EVERY EXCEEDS " +
71 "ERROR ESI EVALUATE EVERY EXCEEDS " +
72 "EXCEPTION EXCLUSIVE EXIT EXTEND EXTERNAL " +
72 "EXCEPTION EXCLUSIVE EXIT EXTEND EXTERNAL " +
73 "EXTERNALLY-DESCRIBED-KEY FD FETCH FILE FILE-CONTROL " +
73 "EXTERNALLY-DESCRIBED-KEY FD FETCH FILE FILE-CONTROL " +
74 "FILE-STREAM FILES FILLER FINAL FIND " +
74 "FILE-STREAM FILES FILLER FINAL FIND " +
75 "FINISH FIRST FOOTING FOR FOREGROUND-COLOR " +
75 "FINISH FIRST FOOTING FOR FOREGROUND-COLOR " +
76 "FOREGROUND-COLOUR FORMAT FREE FROM FULL " +
76 "FOREGROUND-COLOUR FORMAT FREE FROM FULL " +
77 "FUNCTION GENERATE GET GIVING GLOBAL " +
77 "FUNCTION GENERATE GET GIVING GLOBAL " +
78 "GO GOBACK GREATER GROUP HEADING " +
78 "GO GOBACK GREATER GROUP HEADING " +
79 "HIGH-VALUE HIGH-VALUES HIGHLIGHT I-O I-O-CONTROL " +
79 "HIGH-VALUE HIGH-VALUES HIGHLIGHT I-O I-O-CONTROL " +
80 "ID IDENTIFICATION IF IN INDEX " +
80 "ID IDENTIFICATION IF IN INDEX " +
81 "INDEX-1 INDEX-2 INDEX-3 INDEX-4 INDEX-5 " +
81 "INDEX-1 INDEX-2 INDEX-3 INDEX-4 INDEX-5 " +
82 "INDEX-6 INDEX-7 INDEX-8 INDEX-9 INDEXED " +
82 "INDEX-6 INDEX-7 INDEX-8 INDEX-9 INDEXED " +
83 "INDIC INDICATE INDICATOR INDICATORS INITIAL " +
83 "INDIC INDICATE INDICATOR INDICATORS INITIAL " +
84 "INITIALIZE INITIATE INPUT INPUT-OUTPUT INSPECT " +
84 "INITIALIZE INITIATE INPUT INPUT-OUTPUT INSPECT " +
85 "INSTALLATION INTO INVALID INVOKE IS " +
85 "INSTALLATION INTO INVALID INVOKE IS " +
86 "JUST JUSTIFIED KANJI KEEP KEY " +
86 "JUST JUSTIFIED KANJI KEEP KEY " +
87 "LABEL LAST LD LEADING LEFT " +
87 "LABEL LAST LD LEADING LEFT " +
88 "LEFT-JUSTIFY LENGTH LENGTH-CHECK LESS LIBRARY " +
88 "LEFT-JUSTIFY LENGTH LENGTH-CHECK LESS LIBRARY " +
89 "LIKE LIMIT LIMITS LINAGE LINAGE-COUNTER " +
89 "LIKE LIMIT LIMITS LINAGE LINAGE-COUNTER " +
90 "LINE LINE-COUNTER LINES LINKAGE LOCAL-STORAGE " +
90 "LINE LINE-COUNTER LINES LINKAGE LOCAL-STORAGE " +
91 "LOCALE LOCALLY LOCK " +
91 "LOCALE LOCALLY LOCK " +
92 "MEMBER MEMORY MERGE MESSAGE METACLASS " +
92 "MEMBER MEMORY MERGE MESSAGE METACLASS " +
93 "MODE MODIFIED MODIFY MODULES MOVE " +
93 "MODE MODIFIED MODIFY MODULES MOVE " +
94 "MULTIPLE MULTIPLY NATIONAL NATIVE NEGATIVE " +
94 "MULTIPLE MULTIPLY NATIONAL NATIVE NEGATIVE " +
95 "NEXT NO NO-ECHO NONE NOT " +
95 "NEXT NO NO-ECHO NONE NOT " +
96 "NULL NULL-KEY-MAP NULL-MAP NULLS NUMBER " +
96 "NULL NULL-KEY-MAP NULL-MAP NULLS NUMBER " +
97 "NUMERIC NUMERIC-EDITED OBJECT OBJECT-COMPUTER OCCURS " +
97 "NUMERIC NUMERIC-EDITED OBJECT OBJECT-COMPUTER OCCURS " +
98 "OF OFF OMITTED ON ONLY " +
98 "OF OFF OMITTED ON ONLY " +
99 "OPEN OPTIONAL OR ORDER ORGANIZATION " +
99 "OPEN OPTIONAL OR ORDER ORGANIZATION " +
100 "OTHER OUTPUT OVERFLOW OWNER PACKED-DECIMAL " +
100 "OTHER OUTPUT OVERFLOW OWNER PACKED-DECIMAL " +
101 "PADDING PAGE PAGE-COUNTER PARSE PERFORM " +
101 "PADDING PAGE PAGE-COUNTER PARSE PERFORM " +
102 "PF PH PIC PICTURE PLUS " +
102 "PF PH PIC PICTURE PLUS " +
103 "POINTER POSITION POSITIVE PREFIX PRESENT " +
103 "POINTER POSITION POSITIVE PREFIX PRESENT " +
104 "PRINTING PRIOR PROCEDURE PROCEDURE-POINTER PROCEDURES " +
104 "PRINTING PRIOR PROCEDURE PROCEDURE-POINTER PROCEDURES " +
105 "PROCEED PROCESS PROCESSING PROGRAM PROGRAM-ID " +
105 "PROCEED PROCESS PROCESSING PROGRAM PROGRAM-ID " +
106 "PROMPT PROTECTED PURGE QUEUE QUOTE " +
106 "PROMPT PROTECTED PURGE QUEUE QUOTE " +
107 "QUOTES RANDOM RD READ READY " +
107 "QUOTES RANDOM RD READ READY " +
108 "REALM RECEIVE RECONNECT RECORD RECORD-NAME " +
108 "REALM RECEIVE RECONNECT RECORD RECORD-NAME " +
109 "RECORDS RECURSIVE REDEFINES REEL REFERENCE " +
109 "RECORDS RECURSIVE REDEFINES REEL REFERENCE " +
110 "REFERENCE-MONITOR REFERENCES RELATION RELATIVE RELEASE " +
110 "REFERENCE-MONITOR REFERENCES RELATION RELATIVE RELEASE " +
111 "REMAINDER REMOVAL RENAMES REPEATED REPLACE " +
111 "REMAINDER REMOVAL RENAMES REPEATED REPLACE " +
112 "REPLACING REPORT REPORTING REPORTS REPOSITORY " +
112 "REPLACING REPORT REPORTING REPORTS REPOSITORY " +
113 "REQUIRED RERUN RESERVE RESET RETAINING " +
113 "REQUIRED RERUN RESERVE RESET RETAINING " +
114 "RETRIEVAL RETURN RETURN-CODE RETURNING REVERSE-VIDEO " +
114 "RETRIEVAL RETURN RETURN-CODE RETURNING REVERSE-VIDEO " +
115 "REVERSED REWIND REWRITE RF RH " +
115 "REVERSED REWIND REWRITE RF RH " +
116 "RIGHT RIGHT-JUSTIFY ROLLBACK ROLLING ROUNDED " +
116 "RIGHT RIGHT-JUSTIFY ROLLBACK ROLLING ROUNDED " +
117 "RUN SAME SCREEN SD SEARCH " +
117 "RUN SAME SCREEN SD SEARCH " +
118 "SECTION SECURE SECURITY SEGMENT SEGMENT-LIMIT " +
118 "SECTION SECURE SECURITY SEGMENT SEGMENT-LIMIT " +
119 "SELECT SEND SENTENCE SEPARATE SEQUENCE " +
119 "SELECT SEND SENTENCE SEPARATE SEQUENCE " +
120 "SEQUENTIAL SET SHARED SIGN SIZE " +
120 "SEQUENTIAL SET SHARED SIGN SIZE " +
121 "SKIP1 SKIP2 SKIP3 SORT SORT-MERGE " +
121 "SKIP1 SKIP2 SKIP3 SORT SORT-MERGE " +
122 "SORT-RETURN SOURCE SOURCE-COMPUTER SPACE-FILL " +
122 "SORT-RETURN SOURCE SOURCE-COMPUTER SPACE-FILL " +
123 "SPECIAL-NAMES STANDARD STANDARD-1 STANDARD-2 " +
123 "SPECIAL-NAMES STANDARD STANDARD-1 STANDARD-2 " +
124 "START STARTING STATUS STOP STORE " +
124 "START STARTING STATUS STOP STORE " +
125 "STRING SUB-QUEUE-1 SUB-QUEUE-2 SUB-QUEUE-3 SUB-SCHEMA " +
125 "STRING SUB-QUEUE-1 SUB-QUEUE-2 SUB-QUEUE-3 SUB-SCHEMA " +
126 "SUBFILE SUBSTITUTE SUBTRACT SUM SUPPRESS " +
126 "SUBFILE SUBSTITUTE SUBTRACT SUM SUPPRESS " +
127 "SYMBOLIC SYNC SYNCHRONIZED SYSIN SYSOUT " +
127 "SYMBOLIC SYNC SYNCHRONIZED SYSIN SYSOUT " +
128 "TABLE TALLYING TAPE TENANT TERMINAL " +
128 "TABLE TALLYING TAPE TENANT TERMINAL " +
129 "TERMINATE TEST TEXT THAN THEN " +
129 "TERMINATE TEST TEXT THAN THEN " +
130 "THROUGH THRU TIME TIMES TITLE " +
130 "THROUGH THRU TIME TIMES TITLE " +
131 "TO TOP TRAILING TRAILING-SIGN TRANSACTION " +
131 "TO TOP TRAILING TRAILING-SIGN TRANSACTION " +
132 "TYPE TYPEDEF UNDERLINE UNEQUAL UNIT " +
132 "TYPE TYPEDEF UNDERLINE UNEQUAL UNIT " +
133 "UNSTRING UNTIL UP UPDATE UPON " +
133 "UNSTRING UNTIL UP UPDATE UPON " +
134 "USAGE USAGE-MODE USE USING VALID " +
134 "USAGE USAGE-MODE USE USING VALID " +
135 "VALIDATE VALUE VALUES VARYING VLR " +
135 "VALIDATE VALUE VALUES VARYING VLR " +
136 "WAIT WHEN WHEN-COMPILED WITH WITHIN " +
136 "WAIT WHEN WHEN-COMPILED WITH WITHIN " +
137 "WORDS WORKING-STORAGE WRITE XML XML-CODE " +
137 "WORDS WORKING-STORAGE WRITE XML XML-CODE " +
138 "XML-EVENT XML-NTEXT XML-TEXT ZERO ZERO-FILL " );
138 "XML-EVENT XML-NTEXT XML-TEXT ZERO ZERO-FILL " );
139
139
140 var builtins = makeKeywords("- * ** / + < <= = > >= ");
140 var builtins = makeKeywords("- * ** / + < <= = > >= ");
141 var tests = {
141 var tests = {
142 digit: /\d/,
142 digit: /\d/,
143 digit_or_colon: /[\d:]/,
143 digit_or_colon: /[\d:]/,
144 hex: /[0-9a-f]/i,
144 hex: /[0-9a-f]/i,
145 sign: /[+-]/,
145 sign: /[+-]/,
146 exponent: /e/i,
146 exponent: /e/i,
147 keyword_char: /[^\s\(\[\;\)\]]/,
147 keyword_char: /[^\s\(\[\;\)\]]/,
148 symbol: /[\w*+\-]/
148 symbol: /[\w*+\-]/
149 };
149 };
150 function isNumber(ch, stream){
150 function isNumber(ch, stream){
151 // hex
151 // hex
152 if ( ch === '0' && stream.eat(/x/i) ) {
152 if ( ch === '0' && stream.eat(/x/i) ) {
153 stream.eatWhile(tests.hex);
153 stream.eatWhile(tests.hex);
154 return true;
154 return true;
155 }
155 }
156 // leading sign
156 // leading sign
157 if ( ( ch == '+' || ch == '-' ) && ( tests.digit.test(stream.peek()) ) ) {
157 if ( ( ch == '+' || ch == '-' ) && ( tests.digit.test(stream.peek()) ) ) {
158 stream.eat(tests.sign);
158 stream.eat(tests.sign);
159 ch = stream.next();
159 ch = stream.next();
160 }
160 }
161 if ( tests.digit.test(ch) ) {
161 if ( tests.digit.test(ch) ) {
162 stream.eat(ch);
162 stream.eat(ch);
163 stream.eatWhile(tests.digit);
163 stream.eatWhile(tests.digit);
164 if ( '.' == stream.peek()) {
164 if ( '.' == stream.peek()) {
165 stream.eat('.');
165 stream.eat('.');
166 stream.eatWhile(tests.digit);
166 stream.eatWhile(tests.digit);
167 }
167 }
168 if ( stream.eat(tests.exponent) ) {
168 if ( stream.eat(tests.exponent) ) {
169 stream.eat(tests.sign);
169 stream.eat(tests.sign);
170 stream.eatWhile(tests.digit);
170 stream.eatWhile(tests.digit);
171 }
171 }
172 return true;
172 return true;
173 }
173 }
174 return false;
174 return false;
175 }
175 }
176 return {
176 return {
177 startState: function () {
177 startState: function () {
178 return {
178 return {
179 indentStack: null,
179 indentStack: null,
180 indentation: 0,
180 indentation: 0,
181 mode: false
181 mode: false
182 };
182 };
183 },
183 },
184 token: function (stream, state) {
184 token: function (stream, state) {
185 if (state.indentStack == null && stream.sol()) {
185 if (state.indentStack == null && stream.sol()) {
186 // update indentation, but only if indentStack is empty
186 // update indentation, but only if indentStack is empty
187 state.indentation = 6 ; //stream.indentation();
187 state.indentation = 6 ; //stream.indentation();
188 }
188 }
189 // skip spaces
189 // skip spaces
190 if (stream.eatSpace()) {
190 if (stream.eatSpace()) {
191 return null;
191 return null;
192 }
192 }
193 var returnType = null;
193 var returnType = null;
194 switch(state.mode){
194 switch(state.mode){
195 case "string": // multi-line string parsing mode
195 case "string": // multi-line string parsing mode
196 var next = false;
196 var next = false;
197 while ((next = stream.next()) != null) {
197 while ((next = stream.next()) != null) {
198 if (next == "\"" || next == "\'") {
198 if (next == "\"" || next == "\'") {
199 state.mode = false;
199 state.mode = false;
200 break;
200 break;
201 }
201 }
202 }
202 }
203 returnType = STRING; // continue on in string mode
203 returnType = STRING; // continue on in string mode
204 break;
204 break;
205 default: // default parsing mode
205 default: // default parsing mode
206 var ch = stream.next();
206 var ch = stream.next();
207 var col = stream.column();
207 var col = stream.column();
208 if (col >= 0 && col <= 5) {
208 if (col >= 0 && col <= 5) {
209 returnType = COBOLLINENUM;
209 returnType = COBOLLINENUM;
210 } else if (col >= 72 && col <= 79) {
210 } else if (col >= 72 && col <= 79) {
211 stream.skipToEnd();
211 stream.skipToEnd();
212 returnType = MODTAG;
212 returnType = MODTAG;
213 } else if (ch == "*" && col == 6) { // comment
213 } else if (ch == "*" && col == 6) { // comment
214 stream.skipToEnd(); // rest of the line is a comment
214 stream.skipToEnd(); // rest of the line is a comment
215 returnType = COMMENT;
215 returnType = COMMENT;
216 } else if (ch == "\"" || ch == "\'") {
216 } else if (ch == "\"" || ch == "\'") {
217 state.mode = "string";
217 state.mode = "string";
218 returnType = STRING;
218 returnType = STRING;
219 } else if (ch == "'" && !( tests.digit_or_colon.test(stream.peek()) )) {
219 } else if (ch == "'" && !( tests.digit_or_colon.test(stream.peek()) )) {
220 returnType = ATOM;
220 returnType = ATOM;
221 } else if (ch == ".") {
221 } else if (ch == ".") {
222 returnType = PERIOD;
222 returnType = PERIOD;
223 } else if (isNumber(ch,stream)){
223 } else if (isNumber(ch,stream)){
224 returnType = NUMBER;
224 returnType = NUMBER;
225 } else {
225 } else {
226 if (stream.current().match(tests.symbol)) {
226 if (stream.current().match(tests.symbol)) {
227 while (col < 71) {
227 while (col < 71) {
228 if (stream.eat(tests.symbol) === undefined) {
228 if (stream.eat(tests.symbol) === undefined) {
229 break;
229 break;
230 } else {
230 } else {
231 col++;
231 col++;
232 }
232 }
233 }
233 }
234 }
234 }
235 if (keywords && keywords.propertyIsEnumerable(stream.current().toUpperCase())) {
235 if (keywords && keywords.propertyIsEnumerable(stream.current().toUpperCase())) {
236 returnType = KEYWORD;
236 returnType = KEYWORD;
237 } else if (builtins && builtins.propertyIsEnumerable(stream.current().toUpperCase())) {
237 } else if (builtins && builtins.propertyIsEnumerable(stream.current().toUpperCase())) {
238 returnType = BUILTIN;
238 returnType = BUILTIN;
239 } else if (atoms && atoms.propertyIsEnumerable(stream.current().toUpperCase())) {
239 } else if (atoms && atoms.propertyIsEnumerable(stream.current().toUpperCase())) {
240 returnType = ATOM;
240 returnType = ATOM;
241 } else returnType = null;
241 } else returnType = null;
242 }
242 }
243 }
243 }
244 return returnType;
244 return returnType;
245 },
245 },
246 indent: function (state) {
246 indent: function (state) {
247 if (state.indentStack == null) return state.indentation;
247 if (state.indentStack == null) return state.indentation;
248 return state.indentStack.indent;
248 return state.indentStack.indent;
249 }
249 }
250 };
250 };
251 });
251 });
252
252
253 CodeMirror.defineMIME("text/x-cobol", "cobol");
253 CodeMirror.defineMIME("text/x-cobol", "cobol");
254
254
255 });
255 });
@@ -1,355 +1,359 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 /**
4 /**
5 * Link to the project's GitHub page:
5 * Link to the project's GitHub page:
6 * https://github.com/pickhardt/coffeescript-codemirror-mode
6 * https://github.com/pickhardt/coffeescript-codemirror-mode
7 */
7 */
8 (function(mod) {
8 (function(mod) {
9 if (typeof exports == "object" && typeof module == "object") // CommonJS
9 if (typeof exports == "object" && typeof module == "object") // CommonJS
10 mod(require("../../lib/codemirror"));
10 mod(require("../../lib/codemirror"));
11 else if (typeof define == "function" && define.amd) // AMD
11 else if (typeof define == "function" && define.amd) // AMD
12 define(["../../lib/codemirror"], mod);
12 define(["../../lib/codemirror"], mod);
13 else // Plain browser env
13 else // Plain browser env
14 mod(CodeMirror);
14 mod(CodeMirror);
15 })(function(CodeMirror) {
15 })(function(CodeMirror) {
16 "use strict";
16 "use strict";
17
17
18 CodeMirror.defineMode("coffeescript", function(conf, parserConf) {
18 CodeMirror.defineMode("coffeescript", function(conf, parserConf) {
19 var ERRORCLASS = "error";
19 var ERRORCLASS = "error";
20
20
21 function wordRegexp(words) {
21 function wordRegexp(words) {
22 return new RegExp("^((" + words.join(")|(") + "))\\b");
22 return new RegExp("^((" + words.join(")|(") + "))\\b");
23 }
23 }
24
24
25 var operators = /^(?:->|=>|\+[+=]?|-[\-=]?|\*[\*=]?|\/[\/=]?|[=!]=|<[><]?=?|>>?=?|%=?|&=?|\|=?|\^=?|\~|!|\?|(or|and|\|\||&&|\?)=)/;
25 var operators = /^(?:->|=>|\+[+=]?|-[\-=]?|\*[\*=]?|\/[\/=]?|[=!]=|<[><]?=?|>>?=?|%=?|&=?|\|=?|\^=?|\~|!|\?|(or|and|\|\||&&|\?)=)/;
26 var delimiters = /^(?:[()\[\]{},:`=;]|\.\.?\.?)/;
26 var delimiters = /^(?:[()\[\]{},:`=;]|\.\.?\.?)/;
27 var identifiers = /^[_A-Za-z$][_A-Za-z$0-9]*/;
27 var identifiers = /^[_A-Za-z$][_A-Za-z$0-9]*/;
28 var atProp = /^@[_A-Za-z$][_A-Za-z$0-9]*/;
28 var atProp = /^@[_A-Za-z$][_A-Za-z$0-9]*/;
29
29
30 var wordOperators = wordRegexp(["and", "or", "not",
30 var wordOperators = wordRegexp(["and", "or", "not",
31 "is", "isnt", "in",
31 "is", "isnt", "in",
32 "instanceof", "typeof"]);
32 "instanceof", "typeof"]);
33 var indentKeywords = ["for", "while", "loop", "if", "unless", "else",
33 var indentKeywords = ["for", "while", "loop", "if", "unless", "else",
34 "switch", "try", "catch", "finally", "class"];
34 "switch", "try", "catch", "finally", "class"];
35 var commonKeywords = ["break", "by", "continue", "debugger", "delete",
35 var commonKeywords = ["break", "by", "continue", "debugger", "delete",
36 "do", "in", "of", "new", "return", "then",
36 "do", "in", "of", "new", "return", "then",
37 "this", "@", "throw", "when", "until", "extends"];
37 "this", "@", "throw", "when", "until", "extends"];
38
38
39 var keywords = wordRegexp(indentKeywords.concat(commonKeywords));
39 var keywords = wordRegexp(indentKeywords.concat(commonKeywords));
40
40
41 indentKeywords = wordRegexp(indentKeywords);
41 indentKeywords = wordRegexp(indentKeywords);
42
42
43
43
44 var stringPrefixes = /^('{3}|\"{3}|['\"])/;
44 var stringPrefixes = /^('{3}|\"{3}|['\"])/;
45 var regexPrefixes = /^(\/{3}|\/)/;
45 var regexPrefixes = /^(\/{3}|\/)/;
46 var commonConstants = ["Infinity", "NaN", "undefined", "null", "true", "false", "on", "off", "yes", "no"];
46 var commonConstants = ["Infinity", "NaN", "undefined", "null", "true", "false", "on", "off", "yes", "no"];
47 var constants = wordRegexp(commonConstants);
47 var constants = wordRegexp(commonConstants);
48
48
49 // Tokenizers
49 // Tokenizers
50 function tokenBase(stream, state) {
50 function tokenBase(stream, state) {
51 // Handle scope changes
51 // Handle scope changes
52 if (stream.sol()) {
52 if (stream.sol()) {
53 if (state.scope.align === null) state.scope.align = false;
53 if (state.scope.align === null) state.scope.align = false;
54 var scopeOffset = state.scope.offset;
54 var scopeOffset = state.scope.offset;
55 if (stream.eatSpace()) {
55 if (stream.eatSpace()) {
56 var lineOffset = stream.indentation();
56 var lineOffset = stream.indentation();
57 if (lineOffset > scopeOffset && state.scope.type == "coffee") {
57 if (lineOffset > scopeOffset && state.scope.type == "coffee") {
58 return "indent";
58 return "indent";
59 } else if (lineOffset < scopeOffset) {
59 } else if (lineOffset < scopeOffset) {
60 return "dedent";
60 return "dedent";
61 }
61 }
62 return null;
62 return null;
63 } else {
63 } else {
64 if (scopeOffset > 0) {
64 if (scopeOffset > 0) {
65 dedent(stream, state);
65 dedent(stream, state);
66 }
66 }
67 }
67 }
68 }
68 }
69 if (stream.eatSpace()) {
69 if (stream.eatSpace()) {
70 return null;
70 return null;
71 }
71 }
72
72
73 var ch = stream.peek();
73 var ch = stream.peek();
74
74
75 // Handle docco title comment (single line)
75 // Handle docco title comment (single line)
76 if (stream.match("####")) {
76 if (stream.match("####")) {
77 stream.skipToEnd();
77 stream.skipToEnd();
78 return "comment";
78 return "comment";
79 }
79 }
80
80
81 // Handle multi line comments
81 // Handle multi line comments
82 if (stream.match("###")) {
82 if (stream.match("###")) {
83 state.tokenize = longComment;
83 state.tokenize = longComment;
84 return state.tokenize(stream, state);
84 return state.tokenize(stream, state);
85 }
85 }
86
86
87 // Single line comment
87 // Single line comment
88 if (ch === "#") {
88 if (ch === "#") {
89 stream.skipToEnd();
89 stream.skipToEnd();
90 return "comment";
90 return "comment";
91 }
91 }
92
92
93 // Handle number literals
93 // Handle number literals
94 if (stream.match(/^-?[0-9\.]/, false)) {
94 if (stream.match(/^-?[0-9\.]/, false)) {
95 var floatLiteral = false;
95 var floatLiteral = false;
96 // Floats
96 // Floats
97 if (stream.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i)) {
97 if (stream.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i)) {
98 floatLiteral = true;
98 floatLiteral = true;
99 }
99 }
100 if (stream.match(/^-?\d+\.\d*/)) {
100 if (stream.match(/^-?\d+\.\d*/)) {
101 floatLiteral = true;
101 floatLiteral = true;
102 }
102 }
103 if (stream.match(/^-?\.\d+/)) {
103 if (stream.match(/^-?\.\d+/)) {
104 floatLiteral = true;
104 floatLiteral = true;
105 }
105 }
106
106
107 if (floatLiteral) {
107 if (floatLiteral) {
108 // prevent from getting extra . on 1..
108 // prevent from getting extra . on 1..
109 if (stream.peek() == "."){
109 if (stream.peek() == "."){
110 stream.backUp(1);
110 stream.backUp(1);
111 }
111 }
112 return "number";
112 return "number";
113 }
113 }
114 // Integers
114 // Integers
115 var intLiteral = false;
115 var intLiteral = false;
116 // Hex
116 // Hex
117 if (stream.match(/^-?0x[0-9a-f]+/i)) {
117 if (stream.match(/^-?0x[0-9a-f]+/i)) {
118 intLiteral = true;
118 intLiteral = true;
119 }
119 }
120 // Decimal
120 // Decimal
121 if (stream.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/)) {
121 if (stream.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/)) {
122 intLiteral = true;
122 intLiteral = true;
123 }
123 }
124 // Zero by itself with no other piece of number.
124 // Zero by itself with no other piece of number.
125 if (stream.match(/^-?0(?![\dx])/i)) {
125 if (stream.match(/^-?0(?![\dx])/i)) {
126 intLiteral = true;
126 intLiteral = true;
127 }
127 }
128 if (intLiteral) {
128 if (intLiteral) {
129 return "number";
129 return "number";
130 }
130 }
131 }
131 }
132
132
133 // Handle strings
133 // Handle strings
134 if (stream.match(stringPrefixes)) {
134 if (stream.match(stringPrefixes)) {
135 state.tokenize = tokenFactory(stream.current(), false, "string");
135 state.tokenize = tokenFactory(stream.current(), false, "string");
136 return state.tokenize(stream, state);
136 return state.tokenize(stream, state);
137 }
137 }
138 // Handle regex literals
138 // Handle regex literals
139 if (stream.match(regexPrefixes)) {
139 if (stream.match(regexPrefixes)) {
140 if (stream.current() != "/" || stream.match(/^.*\//, false)) { // prevent highlight of division
140 if (stream.current() != "/" || stream.match(/^.*\//, false)) { // prevent highlight of division
141 state.tokenize = tokenFactory(stream.current(), true, "string-2");
141 state.tokenize = tokenFactory(stream.current(), true, "string-2");
142 return state.tokenize(stream, state);
142 return state.tokenize(stream, state);
143 } else {
143 } else {
144 stream.backUp(1);
144 stream.backUp(1);
145 }
145 }
146 }
146 }
147
147
148
148
149
149
150 // Handle operators and delimiters
150 // Handle operators and delimiters
151 if (stream.match(operators) || stream.match(wordOperators)) {
151 if (stream.match(operators) || stream.match(wordOperators)) {
152 return "operator";
152 return "operator";
153 }
153 }
154 if (stream.match(delimiters)) {
154 if (stream.match(delimiters)) {
155 return "punctuation";
155 return "punctuation";
156 }
156 }
157
157
158 if (stream.match(constants)) {
158 if (stream.match(constants)) {
159 return "atom";
159 return "atom";
160 }
160 }
161
161
162 if (stream.match(atProp) || state.prop && stream.match(identifiers)) {
162 if (stream.match(atProp) || state.prop && stream.match(identifiers)) {
163 return "property";
163 return "property";
164 }
164 }
165
165
166 if (stream.match(keywords)) {
166 if (stream.match(keywords)) {
167 return "keyword";
167 return "keyword";
168 }
168 }
169
169
170 if (stream.match(identifiers)) {
170 if (stream.match(identifiers)) {
171 return "variable";
171 return "variable";
172 }
172 }
173
173
174 // Handle non-detected items
174 // Handle non-detected items
175 stream.next();
175 stream.next();
176 return ERRORCLASS;
176 return ERRORCLASS;
177 }
177 }
178
178
179 function tokenFactory(delimiter, singleline, outclass) {
179 function tokenFactory(delimiter, singleline, outclass) {
180 return function(stream, state) {
180 return function(stream, state) {
181 while (!stream.eol()) {
181 while (!stream.eol()) {
182 stream.eatWhile(/[^'"\/\\]/);
182 stream.eatWhile(/[^'"\/\\]/);
183 if (stream.eat("\\")) {
183 if (stream.eat("\\")) {
184 stream.next();
184 stream.next();
185 if (singleline && stream.eol()) {
185 if (singleline && stream.eol()) {
186 return outclass;
186 return outclass;
187 }
187 }
188 } else if (stream.match(delimiter)) {
188 } else if (stream.match(delimiter)) {
189 state.tokenize = tokenBase;
189 state.tokenize = tokenBase;
190 return outclass;
190 return outclass;
191 } else {
191 } else {
192 stream.eat(/['"\/]/);
192 stream.eat(/['"\/]/);
193 }
193 }
194 }
194 }
195 if (singleline) {
195 if (singleline) {
196 if (parserConf.singleLineStringErrors) {
196 if (parserConf.singleLineStringErrors) {
197 outclass = ERRORCLASS;
197 outclass = ERRORCLASS;
198 } else {
198 } else {
199 state.tokenize = tokenBase;
199 state.tokenize = tokenBase;
200 }
200 }
201 }
201 }
202 return outclass;
202 return outclass;
203 };
203 };
204 }
204 }
205
205
206 function longComment(stream, state) {
206 function longComment(stream, state) {
207 while (!stream.eol()) {
207 while (!stream.eol()) {
208 stream.eatWhile(/[^#]/);
208 stream.eatWhile(/[^#]/);
209 if (stream.match("###")) {
209 if (stream.match("###")) {
210 state.tokenize = tokenBase;
210 state.tokenize = tokenBase;
211 break;
211 break;
212 }
212 }
213 stream.eatWhile("#");
213 stream.eatWhile("#");
214 }
214 }
215 return "comment";
215 return "comment";
216 }
216 }
217
217
218 function indent(stream, state, type) {
218 function indent(stream, state, type) {
219 type = type || "coffee";
219 type = type || "coffee";
220 var offset = 0, align = false, alignOffset = null;
220 var offset = 0, align = false, alignOffset = null;
221 for (var scope = state.scope; scope; scope = scope.prev) {
221 for (var scope = state.scope; scope; scope = scope.prev) {
222 if (scope.type === "coffee" || scope.type == "}") {
222 if (scope.type === "coffee" || scope.type == "}") {
223 offset = scope.offset + conf.indentUnit;
223 offset = scope.offset + conf.indentUnit;
224 break;
224 break;
225 }
225 }
226 }
226 }
227 if (type !== "coffee") {
227 if (type !== "coffee") {
228 align = null;
228 align = null;
229 alignOffset = stream.column() + stream.current().length;
229 alignOffset = stream.column() + stream.current().length;
230 } else if (state.scope.align) {
230 } else if (state.scope.align) {
231 state.scope.align = false;
231 state.scope.align = false;
232 }
232 }
233 state.scope = {
233 state.scope = {
234 offset: offset,
234 offset: offset,
235 type: type,
235 type: type,
236 prev: state.scope,
236 prev: state.scope,
237 align: align,
237 align: align,
238 alignOffset: alignOffset
238 alignOffset: alignOffset
239 };
239 };
240 }
240 }
241
241
242 function dedent(stream, state) {
242 function dedent(stream, state) {
243 if (!state.scope.prev) return;
243 if (!state.scope.prev) return;
244 if (state.scope.type === "coffee") {
244 if (state.scope.type === "coffee") {
245 var _indent = stream.indentation();
245 var _indent = stream.indentation();
246 var matched = false;
246 var matched = false;
247 for (var scope = state.scope; scope; scope = scope.prev) {
247 for (var scope = state.scope; scope; scope = scope.prev) {
248 if (_indent === scope.offset) {
248 if (_indent === scope.offset) {
249 matched = true;
249 matched = true;
250 break;
250 break;
251 }
251 }
252 }
252 }
253 if (!matched) {
253 if (!matched) {
254 return true;
254 return true;
255 }
255 }
256 while (state.scope.prev && state.scope.offset !== _indent) {
256 while (state.scope.prev && state.scope.offset !== _indent) {
257 state.scope = state.scope.prev;
257 state.scope = state.scope.prev;
258 }
258 }
259 return false;
259 return false;
260 } else {
260 } else {
261 state.scope = state.scope.prev;
261 state.scope = state.scope.prev;
262 return false;
262 return false;
263 }
263 }
264 }
264 }
265
265
266 function tokenLexer(stream, state) {
266 function tokenLexer(stream, state) {
267 var style = state.tokenize(stream, state);
267 var style = state.tokenize(stream, state);
268 var current = stream.current();
268 var current = stream.current();
269
269
270 // Handle scope changes.
270 // Handle scope changes.
271 if (current === "return") {
271 if (current === "return") {
272 state.dedent = true;
272 state.dedent = true;
273 }
273 }
274 if (((current === "->" || current === "=>") && stream.eol())
274 if (((current === "->" || current === "=>") && stream.eol())
275 || style === "indent") {
275 || style === "indent") {
276 indent(stream, state);
276 indent(stream, state);
277 }
277 }
278 var delimiter_index = "[({".indexOf(current);
278 var delimiter_index = "[({".indexOf(current);
279 if (delimiter_index !== -1) {
279 if (delimiter_index !== -1) {
280 indent(stream, state, "])}".slice(delimiter_index, delimiter_index+1));
280 indent(stream, state, "])}".slice(delimiter_index, delimiter_index+1));
281 }
281 }
282 if (indentKeywords.exec(current)){
282 if (indentKeywords.exec(current)){
283 indent(stream, state);
283 indent(stream, state);
284 }
284 }
285 if (current == "then"){
285 if (current == "then"){
286 dedent(stream, state);
286 dedent(stream, state);
287 }
287 }
288
288
289
289
290 if (style === "dedent") {
290 if (style === "dedent") {
291 if (dedent(stream, state)) {
291 if (dedent(stream, state)) {
292 return ERRORCLASS;
292 return ERRORCLASS;
293 }
293 }
294 }
294 }
295 delimiter_index = "])}".indexOf(current);
295 delimiter_index = "])}".indexOf(current);
296 if (delimiter_index !== -1) {
296 if (delimiter_index !== -1) {
297 while (state.scope.type == "coffee" && state.scope.prev)
297 while (state.scope.type == "coffee" && state.scope.prev)
298 state.scope = state.scope.prev;
298 state.scope = state.scope.prev;
299 if (state.scope.type == current)
299 if (state.scope.type == current)
300 state.scope = state.scope.prev;
300 state.scope = state.scope.prev;
301 }
301 }
302 if (state.dedent && stream.eol()) {
302 if (state.dedent && stream.eol()) {
303 if (state.scope.type == "coffee" && state.scope.prev)
303 if (state.scope.type == "coffee" && state.scope.prev)
304 state.scope = state.scope.prev;
304 state.scope = state.scope.prev;
305 state.dedent = false;
305 state.dedent = false;
306 }
306 }
307
307
308 return style;
308 return style;
309 }
309 }
310
310
311 var external = {
311 var external = {
312 startState: function(basecolumn) {
312 startState: function(basecolumn) {
313 return {
313 return {
314 tokenize: tokenBase,
314 tokenize: tokenBase,
315 scope: {offset:basecolumn || 0, type:"coffee", prev: null, align: false},
315 scope: {offset:basecolumn || 0, type:"coffee", prev: null, align: false},
316 prop: false,
316 prop: false,
317 dedent: 0
317 dedent: 0
318 };
318 };
319 },
319 },
320
320
321 token: function(stream, state) {
321 token: function(stream, state) {
322 var fillAlign = state.scope.align === null && state.scope;
322 var fillAlign = state.scope.align === null && state.scope;
323 if (fillAlign && stream.sol()) fillAlign.align = false;
323 if (fillAlign && stream.sol()) fillAlign.align = false;
324
324
325 var style = tokenLexer(stream, state);
325 var style = tokenLexer(stream, state);
326 if (style && style != "comment") {
326 if (style && style != "comment") {
327 if (fillAlign) fillAlign.align = true;
327 if (fillAlign) fillAlign.align = true;
328 state.prop = style == "punctuation" && stream.current() == "."
328 state.prop = style == "punctuation" && stream.current() == "."
329 }
329 }
330
330
331 return style;
331 return style;
332 },
332 },
333
333
334 indent: function(state, text) {
334 indent: function(state, text) {
335 if (state.tokenize != tokenBase) return 0;
335 if (state.tokenize != tokenBase) return 0;
336 var scope = state.scope;
336 var scope = state.scope;
337 var closer = text && "])}".indexOf(text.charAt(0)) > -1;
337 var closer = text && "])}".indexOf(text.charAt(0)) > -1;
338 if (closer) while (scope.type == "coffee" && scope.prev) scope = scope.prev;
338 if (closer) while (scope.type == "coffee" && scope.prev) scope = scope.prev;
339 var closes = closer && scope.type === text.charAt(0);
339 var closes = closer && scope.type === text.charAt(0);
340 if (scope.align)
340 if (scope.align)
341 return scope.alignOffset - (closes ? 1 : 0);
341 return scope.alignOffset - (closes ? 1 : 0);
342 else
342 else
343 return (closes ? scope.prev : scope).offset;
343 return (closes ? scope.prev : scope).offset;
344 },
344 },
345
345
346 lineComment: "#",
346 lineComment: "#",
347 fold: "indent"
347 fold: "indent"
348 };
348 };
349 return external;
349 return external;
350 });
350 });
351
351
352 // IANA registered media type
353 // https://www.iana.org/assignments/media-types/
354 CodeMirror.defineMIME("application/vnd.coffeescript", "coffeescript");
355
352 CodeMirror.defineMIME("text/x-coffeescript", "coffeescript");
356 CodeMirror.defineMIME("text/x-coffeescript", "coffeescript");
353 CodeMirror.defineMIME("text/coffeescript", "coffeescript");
357 CodeMirror.defineMIME("text/coffeescript", "coffeescript");
354
358
355 });
359 });
@@ -1,123 +1,124 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("commonlisp", function (config) {
14 CodeMirror.defineMode("commonlisp", function (config) {
15 var specialForm = /^(block|let*|return-from|catch|load-time-value|setq|eval-when|locally|symbol-macrolet|flet|macrolet|tagbody|function|multiple-value-call|the|go|multiple-value-prog1|throw|if|progn|unwind-protect|labels|progv|let|quote)$/;
15 var specialForm = /^(block|let*|return-from|catch|load-time-value|setq|eval-when|locally|symbol-macrolet|flet|macrolet|tagbody|function|multiple-value-call|the|go|multiple-value-prog1|throw|if|progn|unwind-protect|labels|progv|let|quote)$/;
16 var assumeBody = /^with|^def|^do|^prog|case$|^cond$|bind$|when$|unless$/;
16 var assumeBody = /^with|^def|^do|^prog|case$|^cond$|bind$|when$|unless$/;
17 var numLiteral = /^(?:[+\-]?(?:\d+|\d*\.\d+)(?:[efd][+\-]?\d+)?|[+\-]?\d+(?:\/[+\-]?\d+)?|#b[+\-]?[01]+|#o[+\-]?[0-7]+|#x[+\-]?[\da-f]+)/;
17 var numLiteral = /^(?:[+\-]?(?:\d+|\d*\.\d+)(?:[efd][+\-]?\d+)?|[+\-]?\d+(?:\/[+\-]?\d+)?|#b[+\-]?[01]+|#o[+\-]?[0-7]+|#x[+\-]?[\da-f]+)/;
18 var symbol = /[^\s'`,@()\[\]";]/;
18 var symbol = /[^\s'`,@()\[\]";]/;
19 var type;
19 var type;
20
20
21 function readSym(stream) {
21 function readSym(stream) {
22 var ch;
22 var ch;
23 while (ch = stream.next()) {
23 while (ch = stream.next()) {
24 if (ch == "\\") stream.next();
24 if (ch == "\\") stream.next();
25 else if (!symbol.test(ch)) { stream.backUp(1); break; }
25 else if (!symbol.test(ch)) { stream.backUp(1); break; }
26 }
26 }
27 return stream.current();
27 return stream.current();
28 }
28 }
29
29
30 function base(stream, state) {
30 function base(stream, state) {
31 if (stream.eatSpace()) {type = "ws"; return null;}
31 if (stream.eatSpace()) {type = "ws"; return null;}
32 if (stream.match(numLiteral)) return "number";
32 if (stream.match(numLiteral)) return "number";
33 var ch = stream.next();
33 var ch = stream.next();
34 if (ch == "\\") ch = stream.next();
34 if (ch == "\\") ch = stream.next();
35
35
36 if (ch == '"') return (state.tokenize = inString)(stream, state);
36 if (ch == '"') return (state.tokenize = inString)(stream, state);
37 else if (ch == "(") { type = "open"; return "bracket"; }
37 else if (ch == "(") { type = "open"; return "bracket"; }
38 else if (ch == ")" || ch == "]") { type = "close"; return "bracket"; }
38 else if (ch == ")" || ch == "]") { type = "close"; return "bracket"; }
39 else if (ch == ";") { stream.skipToEnd(); type = "ws"; return "comment"; }
39 else if (ch == ";") { stream.skipToEnd(); type = "ws"; return "comment"; }
40 else if (/['`,@]/.test(ch)) return null;
40 else if (/['`,@]/.test(ch)) return null;
41 else if (ch == "|") {
41 else if (ch == "|") {
42 if (stream.skipTo("|")) { stream.next(); return "symbol"; }
42 if (stream.skipTo("|")) { stream.next(); return "symbol"; }
43 else { stream.skipToEnd(); return "error"; }
43 else { stream.skipToEnd(); return "error"; }
44 } else if (ch == "#") {
44 } else if (ch == "#") {
45 var ch = stream.next();
45 var ch = stream.next();
46 if (ch == "[") { type = "open"; return "bracket"; }
46 if (ch == "(") { type = "open"; return "bracket"; }
47 else if (/[+\-=\.']/.test(ch)) return null;
47 else if (/[+\-=\.']/.test(ch)) return null;
48 else if (/\d/.test(ch) && stream.match(/^\d*#/)) return null;
48 else if (/\d/.test(ch) && stream.match(/^\d*#/)) return null;
49 else if (ch == "|") return (state.tokenize = inComment)(stream, state);
49 else if (ch == "|") return (state.tokenize = inComment)(stream, state);
50 else if (ch == ":") { readSym(stream); return "meta"; }
50 else if (ch == ":") { readSym(stream); return "meta"; }
51 else if (ch == "\\") { stream.next(); readSym(stream); return "string-2" }
51 else return "error";
52 else return "error";
52 } else {
53 } else {
53 var name = readSym(stream);
54 var name = readSym(stream);
54 if (name == ".") return null;
55 if (name == ".") return null;
55 type = "symbol";
56 type = "symbol";
56 if (name == "nil" || name == "t" || name.charAt(0) == ":") return "atom";
57 if (name == "nil" || name == "t" || name.charAt(0) == ":") return "atom";
57 if (state.lastType == "open" && (specialForm.test(name) || assumeBody.test(name))) return "keyword";
58 if (state.lastType == "open" && (specialForm.test(name) || assumeBody.test(name))) return "keyword";
58 if (name.charAt(0) == "&") return "variable-2";
59 if (name.charAt(0) == "&") return "variable-2";
59 return "variable";
60 return "variable";
60 }
61 }
61 }
62 }
62
63
63 function inString(stream, state) {
64 function inString(stream, state) {
64 var escaped = false, next;
65 var escaped = false, next;
65 while (next = stream.next()) {
66 while (next = stream.next()) {
66 if (next == '"' && !escaped) { state.tokenize = base; break; }
67 if (next == '"' && !escaped) { state.tokenize = base; break; }
67 escaped = !escaped && next == "\\";
68 escaped = !escaped && next == "\\";
68 }
69 }
69 return "string";
70 return "string";
70 }
71 }
71
72
72 function inComment(stream, state) {
73 function inComment(stream, state) {
73 var next, last;
74 var next, last;
74 while (next = stream.next()) {
75 while (next = stream.next()) {
75 if (next == "#" && last == "|") { state.tokenize = base; break; }
76 if (next == "#" && last == "|") { state.tokenize = base; break; }
76 last = next;
77 last = next;
77 }
78 }
78 type = "ws";
79 type = "ws";
79 return "comment";
80 return "comment";
80 }
81 }
81
82
82 return {
83 return {
83 startState: function () {
84 startState: function () {
84 return {ctx: {prev: null, start: 0, indentTo: 0}, lastType: null, tokenize: base};
85 return {ctx: {prev: null, start: 0, indentTo: 0}, lastType: null, tokenize: base};
85 },
86 },
86
87
87 token: function (stream, state) {
88 token: function (stream, state) {
88 if (stream.sol() && typeof state.ctx.indentTo != "number")
89 if (stream.sol() && typeof state.ctx.indentTo != "number")
89 state.ctx.indentTo = state.ctx.start + 1;
90 state.ctx.indentTo = state.ctx.start + 1;
90
91
91 type = null;
92 type = null;
92 var style = state.tokenize(stream, state);
93 var style = state.tokenize(stream, state);
93 if (type != "ws") {
94 if (type != "ws") {
94 if (state.ctx.indentTo == null) {
95 if (state.ctx.indentTo == null) {
95 if (type == "symbol" && assumeBody.test(stream.current()))
96 if (type == "symbol" && assumeBody.test(stream.current()))
96 state.ctx.indentTo = state.ctx.start + config.indentUnit;
97 state.ctx.indentTo = state.ctx.start + config.indentUnit;
97 else
98 else
98 state.ctx.indentTo = "next";
99 state.ctx.indentTo = "next";
99 } else if (state.ctx.indentTo == "next") {
100 } else if (state.ctx.indentTo == "next") {
100 state.ctx.indentTo = stream.column();
101 state.ctx.indentTo = stream.column();
101 }
102 }
102 state.lastType = type;
103 state.lastType = type;
103 }
104 }
104 if (type == "open") state.ctx = {prev: state.ctx, start: stream.column(), indentTo: null};
105 if (type == "open") state.ctx = {prev: state.ctx, start: stream.column(), indentTo: null};
105 else if (type == "close") state.ctx = state.ctx.prev || state.ctx;
106 else if (type == "close") state.ctx = state.ctx.prev || state.ctx;
106 return style;
107 return style;
107 },
108 },
108
109
109 indent: function (state, _textAfter) {
110 indent: function (state, _textAfter) {
110 var i = state.ctx.indentTo;
111 var i = state.ctx.indentTo;
111 return typeof i == "number" ? i : state.ctx.start + 1;
112 return typeof i == "number" ? i : state.ctx.start + 1;
112 },
113 },
113
114
114 closeBrackets: {pairs: "()[]{}\"\""},
115 closeBrackets: {pairs: "()[]{}\"\""},
115 lineComment: ";;",
116 lineComment: ";;",
116 blockCommentStart: "#|",
117 blockCommentStart: "#|",
117 blockCommentEnd: "|#"
118 blockCommentEnd: "|#"
118 };
119 };
119 });
120 });
120
121
121 CodeMirror.defineMIME("text/x-common-lisp", "commonlisp");
122 CodeMirror.defineMIME("text/x-common-lisp", "commonlisp");
122
123
123 });
124 });
@@ -1,391 +1,433 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("crystal", function(config) {
14 CodeMirror.defineMode("crystal", function(config) {
15 function wordRegExp(words, end) {
15 function wordRegExp(words, end) {
16 return new RegExp((end ? "" : "^") + "(?:" + words.join("|") + ")" + (end ? "$" : "\\b"));
16 return new RegExp((end ? "" : "^") + "(?:" + words.join("|") + ")" + (end ? "$" : "\\b"));
17 }
17 }
18
18
19 function chain(tokenize, stream, state) {
19 function chain(tokenize, stream, state) {
20 state.tokenize.push(tokenize);
20 state.tokenize.push(tokenize);
21 return tokenize(stream, state);
21 return tokenize(stream, state);
22 }
22 }
23
23
24 var operators = /^(?:[-+/%|&^]|\*\*?|[<>]{2})/;
24 var operators = /^(?:[-+/%|&^]|\*\*?|[<>]{2})/;
25 var conditionalOperators = /^(?:[=!]~|===|<=>|[<>=!]=?|[|&]{2}|~)/;
25 var conditionalOperators = /^(?:[=!]~|===|<=>|[<>=!]=?|[|&]{2}|~)/;
26 var indexingOperators = /^(?:\[\][?=]?)/;
26 var indexingOperators = /^(?:\[\][?=]?)/;
27 var anotherOperators = /^(?:\.(?:\.{2})?|->|[?:])/;
27 var anotherOperators = /^(?:\.(?:\.{2})?|->|[?:])/;
28 var idents = /^[a-z_\u009F-\uFFFF][a-zA-Z0-9_\u009F-\uFFFF]*/;
28 var idents = /^[a-z_\u009F-\uFFFF][a-zA-Z0-9_\u009F-\uFFFF]*/;
29 var types = /^[A-Z_\u009F-\uFFFF][a-zA-Z0-9_\u009F-\uFFFF]*/;
29 var types = /^[A-Z_\u009F-\uFFFF][a-zA-Z0-9_\u009F-\uFFFF]*/;
30 var keywords = wordRegExp([
30 var keywords = wordRegExp([
31 "abstract", "alias", "as", "asm", "begin", "break", "case", "class", "def", "do",
31 "abstract", "alias", "as", "asm", "begin", "break", "case", "class", "def", "do",
32 "else", "elsif", "end", "ensure", "enum", "extend", "for", "fun", "if", "ifdef",
32 "else", "elsif", "end", "ensure", "enum", "extend", "for", "fun", "if",
33 "include", "instance_sizeof", "lib", "macro", "module", "next", "of", "out", "pointerof",
33 "include", "instance_sizeof", "lib", "macro", "module", "next", "of", "out", "pointerof",
34 "private", "protected", "rescue", "return", "require", "sizeof", "struct",
34 "private", "protected", "rescue", "return", "require", "select", "sizeof", "struct",
35 "super", "then", "type", "typeof", "union", "unless", "until", "when", "while", "with",
35 "super", "then", "type", "typeof", "uninitialized", "union", "unless", "until", "when", "while", "with",
36 "yield", "__DIR__", "__FILE__", "__LINE__"
36 "yield", "__DIR__", "__END_LINE__", "__FILE__", "__LINE__"
37 ]);
37 ]);
38 var atomWords = wordRegExp(["true", "false", "nil", "self"]);
38 var atomWords = wordRegExp(["true", "false", "nil", "self"]);
39 var indentKeywordsArray = [
39 var indentKeywordsArray = [
40 "def", "fun", "macro",
40 "def", "fun", "macro",
41 "class", "module", "struct", "lib", "enum", "union",
41 "class", "module", "struct", "lib", "enum", "union",
42 "if", "unless", "case", "while", "until", "begin", "then",
42 "do", "for"
43 "do",
44 "for", "ifdef"
45 ];
43 ];
46 var indentKeywords = wordRegExp(indentKeywordsArray);
44 var indentKeywords = wordRegExp(indentKeywordsArray);
47 var dedentKeywordsArray = [
45 var indentExpressionKeywordsArray = ["if", "unless", "case", "while", "until", "begin", "then"];
48 "end",
46 var indentExpressionKeywords = wordRegExp(indentExpressionKeywordsArray);
49 "else", "elsif",
47 var dedentKeywordsArray = ["end", "else", "elsif", "rescue", "ensure"];
50 "rescue", "ensure"
51 ];
52 var dedentKeywords = wordRegExp(dedentKeywordsArray);
48 var dedentKeywords = wordRegExp(dedentKeywordsArray);
53 var dedentPunctualsArray = ["\\)", "\\}", "\\]"];
49 var dedentPunctualsArray = ["\\)", "\\}", "\\]"];
54 var dedentPunctuals = new RegExp("^(?:" + dedentPunctualsArray.join("|") + ")$");
50 var dedentPunctuals = new RegExp("^(?:" + dedentPunctualsArray.join("|") + ")$");
55 var nextTokenizer = {
51 var nextTokenizer = {
56 "def": tokenFollowIdent, "fun": tokenFollowIdent, "macro": tokenMacroDef,
52 "def": tokenFollowIdent, "fun": tokenFollowIdent, "macro": tokenMacroDef,
57 "class": tokenFollowType, "module": tokenFollowType, "struct": tokenFollowType,
53 "class": tokenFollowType, "module": tokenFollowType, "struct": tokenFollowType,
58 "lib": tokenFollowType, "enum": tokenFollowType, "union": tokenFollowType
54 "lib": tokenFollowType, "enum": tokenFollowType, "union": tokenFollowType
59 };
55 };
60 var matching = {"[": "]", "{": "}", "(": ")", "<": ">"};
56 var matching = {"[": "]", "{": "}", "(": ")", "<": ">"};
61
57
62 function tokenBase(stream, state) {
58 function tokenBase(stream, state) {
63 if (stream.eatSpace()) {
59 if (stream.eatSpace()) {
64 return null;
60 return null;
65 }
61 }
66
62
67 // Macros
63 // Macros
68 if (state.lastToken != "\\" && stream.match("{%", false)) {
64 if (state.lastToken != "\\" && stream.match("{%", false)) {
69 return chain(tokenMacro("%", "%"), stream, state);
65 return chain(tokenMacro("%", "%"), stream, state);
70 }
66 }
71
67
72 if (state.lastToken != "\\" && stream.match("{{", false)) {
68 if (state.lastToken != "\\" && stream.match("{{", false)) {
73 return chain(tokenMacro("{", "}"), stream, state);
69 return chain(tokenMacro("{", "}"), stream, state);
74 }
70 }
75
71
76 // Comments
72 // Comments
77 if (stream.peek() == "#") {
73 if (stream.peek() == "#") {
78 stream.skipToEnd();
74 stream.skipToEnd();
79 return "comment";
75 return "comment";
80 }
76 }
81
77
82 // Variables and keywords
78 // Variables and keywords
83 var matched;
79 var matched;
84 if (stream.match(idents)) {
80 if (stream.match(idents)) {
85 stream.eat(/[?!]/);
81 stream.eat(/[?!]/);
86
82
87 matched = stream.current();
83 matched = stream.current();
88 if (stream.eat(":")) {
84 if (stream.eat(":")) {
89 return "atom";
85 return "atom";
90 } else if (state.lastToken == ".") {
86 } else if (state.lastToken == ".") {
91 return "property";
87 return "property";
92 } else if (keywords.test(matched)) {
88 } else if (keywords.test(matched)) {
93 if (state.lastToken != "abstract" && indentKeywords.test(matched)) {
89 if (indentKeywords.test(matched)) {
94 if (!(matched == "fun" && state.blocks.indexOf("lib") >= 0)) {
90 if (!(matched == "fun" && state.blocks.indexOf("lib") >= 0) && !(matched == "def" && state.lastToken == "abstract")) {
95 state.blocks.push(matched);
91 state.blocks.push(matched);
96 state.currentIndent += 1;
92 state.currentIndent += 1;
97 }
93 }
98 } else if (dedentKeywords.test(matched)) {
94 } else if ((state.lastStyle == "operator" || !state.lastStyle) && indentExpressionKeywords.test(matched)) {
95 state.blocks.push(matched);
96 state.currentIndent += 1;
97 } else if (matched == "end") {
99 state.blocks.pop();
98 state.blocks.pop();
100 state.currentIndent -= 1;
99 state.currentIndent -= 1;
101 }
100 }
102
101
103 if (nextTokenizer.hasOwnProperty(matched)) {
102 if (nextTokenizer.hasOwnProperty(matched)) {
104 state.tokenize.push(nextTokenizer[matched]);
103 state.tokenize.push(nextTokenizer[matched]);
105 }
104 }
106
105
107 return "keyword";
106 return "keyword";
108 } else if (atomWords.test(matched)) {
107 } else if (atomWords.test(matched)) {
109 return "atom";
108 return "atom";
110 }
109 }
111
110
112 return "variable";
111 return "variable";
113 }
112 }
114
113
115 // Class variables and instance variables
114 // Class variables and instance variables
116 // or attributes
115 // or attributes
117 if (stream.eat("@")) {
116 if (stream.eat("@")) {
118 if (stream.peek() == "[") {
117 if (stream.peek() == "[") {
119 return chain(tokenNest("[", "]", "meta"), stream, state);
118 return chain(tokenNest("[", "]", "meta"), stream, state);
120 }
119 }
121
120
122 stream.eat("@");
121 stream.eat("@");
123 stream.match(idents) || stream.match(types);
122 stream.match(idents) || stream.match(types);
124 return "variable-2";
123 return "variable-2";
125 }
124 }
126
125
127 // Global variables
128 if (stream.eat("$")) {
129 stream.eat(/[0-9]+|\?/) || stream.match(idents) || stream.match(types);
130 return "variable-3";
131 }
132
133 // Constants and types
126 // Constants and types
134 if (stream.match(types)) {
127 if (stream.match(types)) {
135 return "tag";
128 return "tag";
136 }
129 }
137
130
138 // Symbols or ':' operator
131 // Symbols or ':' operator
139 if (stream.eat(":")) {
132 if (stream.eat(":")) {
140 if (stream.eat("\"")) {
133 if (stream.eat("\"")) {
141 return chain(tokenQuote("\"", "atom", false), stream, state);
134 return chain(tokenQuote("\"", "atom", false), stream, state);
142 } else if (stream.match(idents) || stream.match(types) ||
135 } else if (stream.match(idents) || stream.match(types) ||
143 stream.match(operators) || stream.match(conditionalOperators) || stream.match(indexingOperators)) {
136 stream.match(operators) || stream.match(conditionalOperators) || stream.match(indexingOperators)) {
144 return "atom";
137 return "atom";
145 }
138 }
146 stream.eat(":");
139 stream.eat(":");
147 return "operator";
140 return "operator";
148 }
141 }
149
142
150 // Strings
143 // Strings
151 if (stream.eat("\"")) {
144 if (stream.eat("\"")) {
152 return chain(tokenQuote("\"", "string", true), stream, state);
145 return chain(tokenQuote("\"", "string", true), stream, state);
153 }
146 }
154
147
155 // Strings or regexps or macro variables or '%' operator
148 // Strings or regexps or macro variables or '%' operator
156 if (stream.peek() == "%") {
149 if (stream.peek() == "%") {
157 var style = "string";
150 var style = "string";
158 var embed = true;
151 var embed = true;
159 var delim;
152 var delim;
160
153
161 if (stream.match("%r")) {
154 if (stream.match("%r")) {
162 // Regexps
155 // Regexps
163 style = "string-2";
156 style = "string-2";
164 delim = stream.next();
157 delim = stream.next();
165 } else if (stream.match("%w")) {
158 } else if (stream.match("%w")) {
166 embed = false;
159 embed = false;
167 delim = stream.next();
160 delim = stream.next();
161 } else if (stream.match("%q")) {
162 embed = false;
163 delim = stream.next();
168 } else {
164 } else {
169 if(delim = stream.match(/^%([^\w\s=])/)) {
165 if(delim = stream.match(/^%([^\w\s=])/)) {
170 delim = delim[1];
166 delim = delim[1];
171 } else if (stream.match(/^%[a-zA-Z0-9_\u009F-\uFFFF]*/)) {
167 } else if (stream.match(/^%[a-zA-Z0-9_\u009F-\uFFFF]*/)) {
172 // Macro variables
168 // Macro variables
173 return "meta";
169 return "meta";
174 } else {
170 } else {
175 // '%' operator
171 // '%' operator
176 return "operator";
172 return "operator";
177 }
173 }
178 }
174 }
179
175
180 if (matching.hasOwnProperty(delim)) {
176 if (matching.hasOwnProperty(delim)) {
181 delim = matching[delim];
177 delim = matching[delim];
182 }
178 }
183 return chain(tokenQuote(delim, style, embed), stream, state);
179 return chain(tokenQuote(delim, style, embed), stream, state);
184 }
180 }
185
181
182 // Here Docs
183 if (matched = stream.match(/^<<-('?)([A-Z]\w*)\1/)) {
184 return chain(tokenHereDoc(matched[2], !matched[1]), stream, state)
185 }
186
186 // Characters
187 // Characters
187 if (stream.eat("'")) {
188 if (stream.eat("'")) {
188 stream.match(/^(?:[^']|\\(?:[befnrtv0'"]|[0-7]{3}|u(?:[0-9a-fA-F]{4}|\{[0-9a-fA-F]{1,6}\})))/);
189 stream.match(/^(?:[^']|\\(?:[befnrtv0'"]|[0-7]{3}|u(?:[0-9a-fA-F]{4}|\{[0-9a-fA-F]{1,6}\})))/);
189 stream.eat("'");
190 stream.eat("'");
190 return "atom";
191 return "atom";
191 }
192 }
192
193
193 // Numbers
194 // Numbers
194 if (stream.eat("0")) {
195 if (stream.eat("0")) {
195 if (stream.eat("x")) {
196 if (stream.eat("x")) {
196 stream.match(/^[0-9a-fA-F]+/);
197 stream.match(/^[0-9a-fA-F]+/);
197 } else if (stream.eat("o")) {
198 } else if (stream.eat("o")) {
198 stream.match(/^[0-7]+/);
199 stream.match(/^[0-7]+/);
199 } else if (stream.eat("b")) {
200 } else if (stream.eat("b")) {
200 stream.match(/^[01]+/);
201 stream.match(/^[01]+/);
201 }
202 }
202 return "number";
203 return "number";
203 }
204 }
204
205
205 if (stream.eat(/\d/)) {
206 if (stream.eat(/^\d/)) {
206 stream.match(/^\d*(?:\.\d+)?(?:[eE][+-]?\d+)?/);
207 stream.match(/^\d*(?:\.\d+)?(?:[eE][+-]?\d+)?/);
207 return "number";
208 return "number";
208 }
209 }
209
210
210 // Operators
211 // Operators
211 if (stream.match(operators)) {
212 if (stream.match(operators)) {
212 stream.eat("="); // Operators can follow assigin symbol.
213 stream.eat("="); // Operators can follow assign symbol.
213 return "operator";
214 return "operator";
214 }
215 }
215
216
216 if (stream.match(conditionalOperators) || stream.match(anotherOperators)) {
217 if (stream.match(conditionalOperators) || stream.match(anotherOperators)) {
217 return "operator";
218 return "operator";
218 }
219 }
219
220
220 // Parens and braces
221 // Parens and braces
221 if (matched = stream.match(/[({[]/, false)) {
222 if (matched = stream.match(/[({[]/, false)) {
222 matched = matched[0];
223 matched = matched[0];
223 return chain(tokenNest(matched, matching[matched], null), stream, state);
224 return chain(tokenNest(matched, matching[matched], null), stream, state);
224 }
225 }
225
226
226 // Escapes
227 // Escapes
227 if (stream.eat("\\")) {
228 if (stream.eat("\\")) {
228 stream.next();
229 stream.next();
229 return "meta";
230 return "meta";
230 }
231 }
231
232
232 stream.next();
233 stream.next();
233 return null;
234 return null;
234 }
235 }
235
236
236 function tokenNest(begin, end, style, started) {
237 function tokenNest(begin, end, style, started) {
237 return function (stream, state) {
238 return function (stream, state) {
238 if (!started && stream.match(begin)) {
239 if (!started && stream.match(begin)) {
239 state.tokenize[state.tokenize.length - 1] = tokenNest(begin, end, style, true);
240 state.tokenize[state.tokenize.length - 1] = tokenNest(begin, end, style, true);
240 state.currentIndent += 1;
241 state.currentIndent += 1;
241 return style;
242 return style;
242 }
243 }
243
244
244 var nextStyle = tokenBase(stream, state);
245 var nextStyle = tokenBase(stream, state);
245 if (stream.current() === end) {
246 if (stream.current() === end) {
246 state.tokenize.pop();
247 state.tokenize.pop();
247 state.currentIndent -= 1;
248 state.currentIndent -= 1;
248 nextStyle = style;
249 nextStyle = style;
249 }
250 }
250
251
251 return nextStyle;
252 return nextStyle;
252 };
253 };
253 }
254 }
254
255
255 function tokenMacro(begin, end, started) {
256 function tokenMacro(begin, end, started) {
256 return function (stream, state) {
257 return function (stream, state) {
257 if (!started && stream.match("{" + begin)) {
258 if (!started && stream.match("{" + begin)) {
258 state.currentIndent += 1;
259 state.currentIndent += 1;
259 state.tokenize[state.tokenize.length - 1] = tokenMacro(begin, end, true);
260 state.tokenize[state.tokenize.length - 1] = tokenMacro(begin, end, true);
260 return "meta";
261 return "meta";
261 }
262 }
262
263
263 if (stream.match(end + "}")) {
264 if (stream.match(end + "}")) {
264 state.currentIndent -= 1;
265 state.currentIndent -= 1;
265 state.tokenize.pop();
266 state.tokenize.pop();
266 return "meta";
267 return "meta";
267 }
268 }
268
269
269 return tokenBase(stream, state);
270 return tokenBase(stream, state);
270 };
271 };
271 }
272 }
272
273
273 function tokenMacroDef(stream, state) {
274 function tokenMacroDef(stream, state) {
274 if (stream.eatSpace()) {
275 if (stream.eatSpace()) {
275 return null;
276 return null;
276 }
277 }
277
278
278 var matched;
279 var matched;
279 if (matched = stream.match(idents)) {
280 if (matched = stream.match(idents)) {
280 if (matched == "def") {
281 if (matched == "def") {
281 return "keyword";
282 return "keyword";
282 }
283 }
283 stream.eat(/[?!]/);
284 stream.eat(/[?!]/);
284 }
285 }
285
286
286 state.tokenize.pop();
287 state.tokenize.pop();
287 return "def";
288 return "def";
288 }
289 }
289
290
290 function tokenFollowIdent(stream, state) {
291 function tokenFollowIdent(stream, state) {
291 if (stream.eatSpace()) {
292 if (stream.eatSpace()) {
292 return null;
293 return null;
293 }
294 }
294
295
295 if (stream.match(idents)) {
296 if (stream.match(idents)) {
296 stream.eat(/[!?]/);
297 stream.eat(/[!?]/);
297 } else {
298 } else {
298 stream.match(operators) || stream.match(conditionalOperators) || stream.match(indexingOperators);
299 stream.match(operators) || stream.match(conditionalOperators) || stream.match(indexingOperators);
299 }
300 }
300 state.tokenize.pop();
301 state.tokenize.pop();
301 return "def";
302 return "def";
302 }
303 }
303
304
304 function tokenFollowType(stream, state) {
305 function tokenFollowType(stream, state) {
305 if (stream.eatSpace()) {
306 if (stream.eatSpace()) {
306 return null;
307 return null;
307 }
308 }
308
309
309 stream.match(types);
310 stream.match(types);
310 state.tokenize.pop();
311 state.tokenize.pop();
311 return "def";
312 return "def";
312 }
313 }
313
314
314 function tokenQuote(end, style, embed) {
315 function tokenQuote(end, style, embed) {
315 return function (stream, state) {
316 return function (stream, state) {
316 var escaped = false;
317 var escaped = false;
317
318
318 while (stream.peek()) {
319 while (stream.peek()) {
319 if (!escaped) {
320 if (!escaped) {
320 if (stream.match("{%", false)) {
321 if (stream.match("{%", false)) {
321 state.tokenize.push(tokenMacro("%", "%"));
322 state.tokenize.push(tokenMacro("%", "%"));
322 return style;
323 return style;
323 }
324 }
324
325
325 if (stream.match("{{", false)) {
326 if (stream.match("{{", false)) {
326 state.tokenize.push(tokenMacro("{", "}"));
327 state.tokenize.push(tokenMacro("{", "}"));
327 return style;
328 return style;
328 }
329 }
329
330
330 if (embed && stream.match("#{", false)) {
331 if (embed && stream.match("#{", false)) {
331 state.tokenize.push(tokenNest("#{", "}", "meta"));
332 state.tokenize.push(tokenNest("#{", "}", "meta"));
332 return style;
333 return style;
333 }
334 }
334
335
335 var ch = stream.next();
336 var ch = stream.next();
336
337
337 if (ch == end) {
338 if (ch == end) {
338 state.tokenize.pop();
339 state.tokenize.pop();
339 return style;
340 return style;
340 }
341 }
341
342
342 escaped = ch == "\\";
343 escaped = embed && ch == "\\";
343 } else {
344 } else {
344 stream.next();
345 stream.next();
345 escaped = false;
346 escaped = false;
346 }
347 }
347 }
348 }
348
349
349 return style;
350 return style;
350 };
351 };
351 }
352 }
352
353
354 function tokenHereDoc(phrase, embed) {
355 return function (stream, state) {
356 if (stream.sol()) {
357 stream.eatSpace()
358 if (stream.match(phrase)) {
359 state.tokenize.pop();
360 return "string";
361 }
362 }
363
364 var escaped = false;
365 while (stream.peek()) {
366 if (!escaped) {
367 if (stream.match("{%", false)) {
368 state.tokenize.push(tokenMacro("%", "%"));
369 return "string";
370 }
371
372 if (stream.match("{{", false)) {
373 state.tokenize.push(tokenMacro("{", "}"));
374 return "string";
375 }
376
377 if (embed && stream.match("#{", false)) {
378 state.tokenize.push(tokenNest("#{", "}", "meta"));
379 return "string";
380 }
381
382 escaped = embed && stream.next() == "\\";
383 } else {
384 stream.next();
385 escaped = false;
386 }
387 }
388
389 return "string";
390 }
391 }
392
353 return {
393 return {
354 startState: function () {
394 startState: function () {
355 return {
395 return {
356 tokenize: [tokenBase],
396 tokenize: [tokenBase],
357 currentIndent: 0,
397 currentIndent: 0,
358 lastToken: null,
398 lastToken: null,
399 lastStyle: null,
359 blocks: []
400 blocks: []
360 };
401 };
361 },
402 },
362
403
363 token: function (stream, state) {
404 token: function (stream, state) {
364 var style = state.tokenize[state.tokenize.length - 1](stream, state);
405 var style = state.tokenize[state.tokenize.length - 1](stream, state);
365 var token = stream.current();
406 var token = stream.current();
366
407
367 if (style && style != "comment") {
408 if (style && style != "comment") {
368 state.lastToken = token;
409 state.lastToken = token;
410 state.lastStyle = style;
369 }
411 }
370
412
371 return style;
413 return style;
372 },
414 },
373
415
374 indent: function (state, textAfter) {
416 indent: function (state, textAfter) {
375 textAfter = textAfter.replace(/^\s*(?:\{%)?\s*|\s*(?:%\})?\s*$/g, "");
417 textAfter = textAfter.replace(/^\s*(?:\{%)?\s*|\s*(?:%\})?\s*$/g, "");
376
418
377 if (dedentKeywords.test(textAfter) || dedentPunctuals.test(textAfter)) {
419 if (dedentKeywords.test(textAfter) || dedentPunctuals.test(textAfter)) {
378 return config.indentUnit * (state.currentIndent - 1);
420 return config.indentUnit * (state.currentIndent - 1);
379 }
421 }
380
422
381 return config.indentUnit * state.currentIndent;
423 return config.indentUnit * state.currentIndent;
382 },
424 },
383
425
384 fold: "indent",
426 fold: "indent",
385 electricInput: wordRegExp(dedentPunctualsArray.concat(dedentKeywordsArray), true),
427 electricInput: wordRegExp(dedentPunctualsArray.concat(dedentKeywordsArray), true),
386 lineComment: '#'
428 lineComment: '#'
387 };
429 };
388 });
430 });
389
431
390 CodeMirror.defineMIME("text/x-crystal", "crystal");
432 CodeMirror.defineMIME("text/x-crystal", "crystal");
391 });
433 });
@@ -1,825 +1,831 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("css", function(config, parserConfig) {
14 CodeMirror.defineMode("css", function(config, parserConfig) {
15 var inline = parserConfig.inline
15 var inline = parserConfig.inline
16 if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
16 if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
17
17
18 var indentUnit = config.indentUnit,
18 var indentUnit = config.indentUnit,
19 tokenHooks = parserConfig.tokenHooks,
19 tokenHooks = parserConfig.tokenHooks,
20 documentTypes = parserConfig.documentTypes || {},
20 documentTypes = parserConfig.documentTypes || {},
21 mediaTypes = parserConfig.mediaTypes || {},
21 mediaTypes = parserConfig.mediaTypes || {},
22 mediaFeatures = parserConfig.mediaFeatures || {},
22 mediaFeatures = parserConfig.mediaFeatures || {},
23 mediaValueKeywords = parserConfig.mediaValueKeywords || {},
23 mediaValueKeywords = parserConfig.mediaValueKeywords || {},
24 propertyKeywords = parserConfig.propertyKeywords || {},
24 propertyKeywords = parserConfig.propertyKeywords || {},
25 nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {},
25 nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {},
26 fontProperties = parserConfig.fontProperties || {},
26 fontProperties = parserConfig.fontProperties || {},
27 counterDescriptors = parserConfig.counterDescriptors || {},
27 counterDescriptors = parserConfig.counterDescriptors || {},
28 colorKeywords = parserConfig.colorKeywords || {},
28 colorKeywords = parserConfig.colorKeywords || {},
29 valueKeywords = parserConfig.valueKeywords || {},
29 valueKeywords = parserConfig.valueKeywords || {},
30 allowNested = parserConfig.allowNested,
30 allowNested = parserConfig.allowNested,
31 lineComment = parserConfig.lineComment,
31 supportsAtComponent = parserConfig.supportsAtComponent === true;
32 supportsAtComponent = parserConfig.supportsAtComponent === true;
32
33
33 var type, override;
34 var type, override;
34 function ret(style, tp) { type = tp; return style; }
35 function ret(style, tp) { type = tp; return style; }
35
36
36 // Tokenizers
37 // Tokenizers
37
38
38 function tokenBase(stream, state) {
39 function tokenBase(stream, state) {
39 var ch = stream.next();
40 var ch = stream.next();
40 if (tokenHooks[ch]) {
41 if (tokenHooks[ch]) {
41 var result = tokenHooks[ch](stream, state);
42 var result = tokenHooks[ch](stream, state);
42 if (result !== false) return result;
43 if (result !== false) return result;
43 }
44 }
44 if (ch == "@") {
45 if (ch == "@") {
45 stream.eatWhile(/[\w\\\-]/);
46 stream.eatWhile(/[\w\\\-]/);
46 return ret("def", stream.current());
47 return ret("def", stream.current());
47 } else if (ch == "=" || (ch == "~" || ch == "|") && stream.eat("=")) {
48 } else if (ch == "=" || (ch == "~" || ch == "|") && stream.eat("=")) {
48 return ret(null, "compare");
49 return ret(null, "compare");
49 } else if (ch == "\"" || ch == "'") {
50 } else if (ch == "\"" || ch == "'") {
50 state.tokenize = tokenString(ch);
51 state.tokenize = tokenString(ch);
51 return state.tokenize(stream, state);
52 return state.tokenize(stream, state);
52 } else if (ch == "#") {
53 } else if (ch == "#") {
53 stream.eatWhile(/[\w\\\-]/);
54 stream.eatWhile(/[\w\\\-]/);
54 return ret("atom", "hash");
55 return ret("atom", "hash");
55 } else if (ch == "!") {
56 } else if (ch == "!") {
56 stream.match(/^\s*\w*/);
57 stream.match(/^\s*\w*/);
57 return ret("keyword", "important");
58 return ret("keyword", "important");
58 } else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) {
59 } else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) {
59 stream.eatWhile(/[\w.%]/);
60 stream.eatWhile(/[\w.%]/);
60 return ret("number", "unit");
61 return ret("number", "unit");
61 } else if (ch === "-") {
62 } else if (ch === "-") {
62 if (/[\d.]/.test(stream.peek())) {
63 if (/[\d.]/.test(stream.peek())) {
63 stream.eatWhile(/[\w.%]/);
64 stream.eatWhile(/[\w.%]/);
64 return ret("number", "unit");
65 return ret("number", "unit");
65 } else if (stream.match(/^-[\w\\\-]+/)) {
66 } else if (stream.match(/^-[\w\\\-]*/)) {
66 stream.eatWhile(/[\w\\\-]/);
67 stream.eatWhile(/[\w\\\-]/);
67 if (stream.match(/^\s*:/, false))
68 if (stream.match(/^\s*:/, false))
68 return ret("variable-2", "variable-definition");
69 return ret("variable-2", "variable-definition");
69 return ret("variable-2", "variable");
70 return ret("variable-2", "variable");
70 } else if (stream.match(/^\w+-/)) {
71 } else if (stream.match(/^\w+-/)) {
71 return ret("meta", "meta");
72 return ret("meta", "meta");
72 }
73 }
73 } else if (/[,+>*\/]/.test(ch)) {
74 } else if (/[,+>*\/]/.test(ch)) {
74 return ret(null, "select-op");
75 return ret(null, "select-op");
75 } else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
76 } else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
76 return ret("qualifier", "qualifier");
77 return ret("qualifier", "qualifier");
77 } else if (/[:;{}\[\]\(\)]/.test(ch)) {
78 } else if (/[:;{}\[\]\(\)]/.test(ch)) {
78 return ret(null, ch);
79 return ret(null, ch);
79 } else if ((ch == "u" && stream.match(/rl(-prefix)?\(/)) ||
80 } else if (stream.match(/[\w-.]+(?=\()/)) {
80 (ch == "d" && stream.match("omain(")) ||
81 if (/^(url(-prefix)?|domain|regexp)$/.test(stream.current().toLowerCase())) {
81 (ch == "r" && stream.match("egexp("))) {
82 stream.backUp(1);
83 state.tokenize = tokenParenthesized;
82 state.tokenize = tokenParenthesized;
84 return ret("property", "word");
83 }
84 return ret("variable callee", "variable");
85 } else if (/[\w\\\-]/.test(ch)) {
85 } else if (/[\w\\\-]/.test(ch)) {
86 stream.eatWhile(/[\w\\\-]/);
86 stream.eatWhile(/[\w\\\-]/);
87 return ret("property", "word");
87 return ret("property", "word");
88 } else {
88 } else {
89 return ret(null, null);
89 return ret(null, null);
90 }
90 }
91 }
91 }
92
92
93 function tokenString(quote) {
93 function tokenString(quote) {
94 return function(stream, state) {
94 return function(stream, state) {
95 var escaped = false, ch;
95 var escaped = false, ch;
96 while ((ch = stream.next()) != null) {
96 while ((ch = stream.next()) != null) {
97 if (ch == quote && !escaped) {
97 if (ch == quote && !escaped) {
98 if (quote == ")") stream.backUp(1);
98 if (quote == ")") stream.backUp(1);
99 break;
99 break;
100 }
100 }
101 escaped = !escaped && ch == "\\";
101 escaped = !escaped && ch == "\\";
102 }
102 }
103 if (ch == quote || !escaped && quote != ")") state.tokenize = null;
103 if (ch == quote || !escaped && quote != ")") state.tokenize = null;
104 return ret("string", "string");
104 return ret("string", "string");
105 };
105 };
106 }
106 }
107
107
108 function tokenParenthesized(stream, state) {
108 function tokenParenthesized(stream, state) {
109 stream.next(); // Must be '('
109 stream.next(); // Must be '('
110 if (!stream.match(/\s*[\"\')]/, false))
110 if (!stream.match(/\s*[\"\')]/, false))
111 state.tokenize = tokenString(")");
111 state.tokenize = tokenString(")");
112 else
112 else
113 state.tokenize = null;
113 state.tokenize = null;
114 return ret(null, "(");
114 return ret(null, "(");
115 }
115 }
116
116
117 // Context management
117 // Context management
118
118
119 function Context(type, indent, prev) {
119 function Context(type, indent, prev) {
120 this.type = type;
120 this.type = type;
121 this.indent = indent;
121 this.indent = indent;
122 this.prev = prev;
122 this.prev = prev;
123 }
123 }
124
124
125 function pushContext(state, stream, type, indent) {
125 function pushContext(state, stream, type, indent) {
126 state.context = new Context(type, stream.indentation() + (indent === false ? 0 : indentUnit), state.context);
126 state.context = new Context(type, stream.indentation() + (indent === false ? 0 : indentUnit), state.context);
127 return type;
127 return type;
128 }
128 }
129
129
130 function popContext(state) {
130 function popContext(state) {
131 if (state.context.prev)
131 if (state.context.prev)
132 state.context = state.context.prev;
132 state.context = state.context.prev;
133 return state.context.type;
133 return state.context.type;
134 }
134 }
135
135
136 function pass(type, stream, state) {
136 function pass(type, stream, state) {
137 return states[state.context.type](type, stream, state);
137 return states[state.context.type](type, stream, state);
138 }
138 }
139 function popAndPass(type, stream, state, n) {
139 function popAndPass(type, stream, state, n) {
140 for (var i = n || 1; i > 0; i--)
140 for (var i = n || 1; i > 0; i--)
141 state.context = state.context.prev;
141 state.context = state.context.prev;
142 return pass(type, stream, state);
142 return pass(type, stream, state);
143 }
143 }
144
144
145 // Parser
145 // Parser
146
146
147 function wordAsValue(stream) {
147 function wordAsValue(stream) {
148 var word = stream.current().toLowerCase();
148 var word = stream.current().toLowerCase();
149 if (valueKeywords.hasOwnProperty(word))
149 if (valueKeywords.hasOwnProperty(word))
150 override = "atom";
150 override = "atom";
151 else if (colorKeywords.hasOwnProperty(word))
151 else if (colorKeywords.hasOwnProperty(word))
152 override = "keyword";
152 override = "keyword";
153 else
153 else
154 override = "variable";
154 override = "variable";
155 }
155 }
156
156
157 var states = {};
157 var states = {};
158
158
159 states.top = function(type, stream, state) {
159 states.top = function(type, stream, state) {
160 if (type == "{") {
160 if (type == "{") {
161 return pushContext(state, stream, "block");
161 return pushContext(state, stream, "block");
162 } else if (type == "}" && state.context.prev) {
162 } else if (type == "}" && state.context.prev) {
163 return popContext(state);
163 return popContext(state);
164 } else if (supportsAtComponent && /@component/.test(type)) {
164 } else if (supportsAtComponent && /@component/i.test(type)) {
165 return pushContext(state, stream, "atComponentBlock");
165 return pushContext(state, stream, "atComponentBlock");
166 } else if (/^@(-moz-)?document$/.test(type)) {
166 } else if (/^@(-moz-)?document$/i.test(type)) {
167 return pushContext(state, stream, "documentTypes");
167 return pushContext(state, stream, "documentTypes");
168 } else if (/^@(media|supports|(-moz-)?document|import)$/.test(type)) {
168 } else if (/^@(media|supports|(-moz-)?document|import)$/i.test(type)) {
169 return pushContext(state, stream, "atBlock");
169 return pushContext(state, stream, "atBlock");
170 } else if (/^@(font-face|counter-style)/.test(type)) {
170 } else if (/^@(font-face|counter-style)/i.test(type)) {
171 state.stateArg = type;
171 state.stateArg = type;
172 return "restricted_atBlock_before";
172 return "restricted_atBlock_before";
173 } else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) {
173 } else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(type)) {
174 return "keyframes";
174 return "keyframes";
175 } else if (type && type.charAt(0) == "@") {
175 } else if (type && type.charAt(0) == "@") {
176 return pushContext(state, stream, "at");
176 return pushContext(state, stream, "at");
177 } else if (type == "hash") {
177 } else if (type == "hash") {
178 override = "builtin";
178 override = "builtin";
179 } else if (type == "word") {
179 } else if (type == "word") {
180 override = "tag";
180 override = "tag";
181 } else if (type == "variable-definition") {
181 } else if (type == "variable-definition") {
182 return "maybeprop";
182 return "maybeprop";
183 } else if (type == "interpolation") {
183 } else if (type == "interpolation") {
184 return pushContext(state, stream, "interpolation");
184 return pushContext(state, stream, "interpolation");
185 } else if (type == ":") {
185 } else if (type == ":") {
186 return "pseudo";
186 return "pseudo";
187 } else if (allowNested && type == "(") {
187 } else if (allowNested && type == "(") {
188 return pushContext(state, stream, "parens");
188 return pushContext(state, stream, "parens");
189 }
189 }
190 return state.context.type;
190 return state.context.type;
191 };
191 };
192
192
193 states.block = function(type, stream, state) {
193 states.block = function(type, stream, state) {
194 if (type == "word") {
194 if (type == "word") {
195 var word = stream.current().toLowerCase();
195 var word = stream.current().toLowerCase();
196 if (propertyKeywords.hasOwnProperty(word)) {
196 if (propertyKeywords.hasOwnProperty(word)) {
197 override = "property";
197 override = "property";
198 return "maybeprop";
198 return "maybeprop";
199 } else if (nonStandardPropertyKeywords.hasOwnProperty(word)) {
199 } else if (nonStandardPropertyKeywords.hasOwnProperty(word)) {
200 override = "string-2";
200 override = "string-2";
201 return "maybeprop";
201 return "maybeprop";
202 } else if (allowNested) {
202 } else if (allowNested) {
203 override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag";
203 override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag";
204 return "block";
204 return "block";
205 } else {
205 } else {
206 override += " error";
206 override += " error";
207 return "maybeprop";
207 return "maybeprop";
208 }
208 }
209 } else if (type == "meta") {
209 } else if (type == "meta") {
210 return "block";
210 return "block";
211 } else if (!allowNested && (type == "hash" || type == "qualifier")) {
211 } else if (!allowNested && (type == "hash" || type == "qualifier")) {
212 override = "error";
212 override = "error";
213 return "block";
213 return "block";
214 } else {
214 } else {
215 return states.top(type, stream, state);
215 return states.top(type, stream, state);
216 }
216 }
217 };
217 };
218
218
219 states.maybeprop = function(type, stream, state) {
219 states.maybeprop = function(type, stream, state) {
220 if (type == ":") return pushContext(state, stream, "prop");
220 if (type == ":") return pushContext(state, stream, "prop");
221 return pass(type, stream, state);
221 return pass(type, stream, state);
222 };
222 };
223
223
224 states.prop = function(type, stream, state) {
224 states.prop = function(type, stream, state) {
225 if (type == ";") return popContext(state);
225 if (type == ";") return popContext(state);
226 if (type == "{" && allowNested) return pushContext(state, stream, "propBlock");
226 if (type == "{" && allowNested) return pushContext(state, stream, "propBlock");
227 if (type == "}" || type == "{") return popAndPass(type, stream, state);
227 if (type == "}" || type == "{") return popAndPass(type, stream, state);
228 if (type == "(") return pushContext(state, stream, "parens");
228 if (type == "(") return pushContext(state, stream, "parens");
229
229
230 if (type == "hash" && !/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(stream.current())) {
230 if (type == "hash" && !/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(stream.current())) {
231 override += " error";
231 override += " error";
232 } else if (type == "word") {
232 } else if (type == "word") {
233 wordAsValue(stream);
233 wordAsValue(stream);
234 } else if (type == "interpolation") {
234 } else if (type == "interpolation") {
235 return pushContext(state, stream, "interpolation");
235 return pushContext(state, stream, "interpolation");
236 }
236 }
237 return "prop";
237 return "prop";
238 };
238 };
239
239
240 states.propBlock = function(type, _stream, state) {
240 states.propBlock = function(type, _stream, state) {
241 if (type == "}") return popContext(state);
241 if (type == "}") return popContext(state);
242 if (type == "word") { override = "property"; return "maybeprop"; }
242 if (type == "word") { override = "property"; return "maybeprop"; }
243 return state.context.type;
243 return state.context.type;
244 };
244 };
245
245
246 states.parens = function(type, stream, state) {
246 states.parens = function(type, stream, state) {
247 if (type == "{" || type == "}") return popAndPass(type, stream, state);
247 if (type == "{" || type == "}") return popAndPass(type, stream, state);
248 if (type == ")") return popContext(state);
248 if (type == ")") return popContext(state);
249 if (type == "(") return pushContext(state, stream, "parens");
249 if (type == "(") return pushContext(state, stream, "parens");
250 if (type == "interpolation") return pushContext(state, stream, "interpolation");
250 if (type == "interpolation") return pushContext(state, stream, "interpolation");
251 if (type == "word") wordAsValue(stream);
251 if (type == "word") wordAsValue(stream);
252 return "parens";
252 return "parens";
253 };
253 };
254
254
255 states.pseudo = function(type, stream, state) {
255 states.pseudo = function(type, stream, state) {
256 if (type == "meta") return "pseudo";
257
256 if (type == "word") {
258 if (type == "word") {
257 override = "variable-3";
259 override = "variable-3";
258 return state.context.type;
260 return state.context.type;
259 }
261 }
260 return pass(type, stream, state);
262 return pass(type, stream, state);
261 };
263 };
262
264
263 states.documentTypes = function(type, stream, state) {
265 states.documentTypes = function(type, stream, state) {
264 if (type == "word" && documentTypes.hasOwnProperty(stream.current())) {
266 if (type == "word" && documentTypes.hasOwnProperty(stream.current())) {
265 override = "tag";
267 override = "tag";
266 return state.context.type;
268 return state.context.type;
267 } else {
269 } else {
268 return states.atBlock(type, stream, state);
270 return states.atBlock(type, stream, state);
269 }
271 }
270 };
272 };
271
273
272 states.atBlock = function(type, stream, state) {
274 states.atBlock = function(type, stream, state) {
273 if (type == "(") return pushContext(state, stream, "atBlock_parens");
275 if (type == "(") return pushContext(state, stream, "atBlock_parens");
274 if (type == "}" || type == ";") return popAndPass(type, stream, state);
276 if (type == "}" || type == ";") return popAndPass(type, stream, state);
275 if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");
277 if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");
276
278
277 if (type == "interpolation") return pushContext(state, stream, "interpolation");
279 if (type == "interpolation") return pushContext(state, stream, "interpolation");
278
280
279 if (type == "word") {
281 if (type == "word") {
280 var word = stream.current().toLowerCase();
282 var word = stream.current().toLowerCase();
281 if (word == "only" || word == "not" || word == "and" || word == "or")
283 if (word == "only" || word == "not" || word == "and" || word == "or")
282 override = "keyword";
284 override = "keyword";
283 else if (mediaTypes.hasOwnProperty(word))
285 else if (mediaTypes.hasOwnProperty(word))
284 override = "attribute";
286 override = "attribute";
285 else if (mediaFeatures.hasOwnProperty(word))
287 else if (mediaFeatures.hasOwnProperty(word))
286 override = "property";
288 override = "property";
287 else if (mediaValueKeywords.hasOwnProperty(word))
289 else if (mediaValueKeywords.hasOwnProperty(word))
288 override = "keyword";
290 override = "keyword";
289 else if (propertyKeywords.hasOwnProperty(word))
291 else if (propertyKeywords.hasOwnProperty(word))
290 override = "property";
292 override = "property";
291 else if (nonStandardPropertyKeywords.hasOwnProperty(word))
293 else if (nonStandardPropertyKeywords.hasOwnProperty(word))
292 override = "string-2";
294 override = "string-2";
293 else if (valueKeywords.hasOwnProperty(word))
295 else if (valueKeywords.hasOwnProperty(word))
294 override = "atom";
296 override = "atom";
295 else if (colorKeywords.hasOwnProperty(word))
297 else if (colorKeywords.hasOwnProperty(word))
296 override = "keyword";
298 override = "keyword";
297 else
299 else
298 override = "error";
300 override = "error";
299 }
301 }
300 return state.context.type;
302 return state.context.type;
301 };
303 };
302
304
303 states.atComponentBlock = function(type, stream, state) {
305 states.atComponentBlock = function(type, stream, state) {
304 if (type == "}")
306 if (type == "}")
305 return popAndPass(type, stream, state);
307 return popAndPass(type, stream, state);
306 if (type == "{")
308 if (type == "{")
307 return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top", false);
309 return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top", false);
308 if (type == "word")
310 if (type == "word")
309 override = "error";
311 override = "error";
310 return state.context.type;
312 return state.context.type;
311 };
313 };
312
314
313 states.atBlock_parens = function(type, stream, state) {
315 states.atBlock_parens = function(type, stream, state) {
314 if (type == ")") return popContext(state);
316 if (type == ")") return popContext(state);
315 if (type == "{" || type == "}") return popAndPass(type, stream, state, 2);
317 if (type == "{" || type == "}") return popAndPass(type, stream, state, 2);
316 return states.atBlock(type, stream, state);
318 return states.atBlock(type, stream, state);
317 };
319 };
318
320
319 states.restricted_atBlock_before = function(type, stream, state) {
321 states.restricted_atBlock_before = function(type, stream, state) {
320 if (type == "{")
322 if (type == "{")
321 return pushContext(state, stream, "restricted_atBlock");
323 return pushContext(state, stream, "restricted_atBlock");
322 if (type == "word" && state.stateArg == "@counter-style") {
324 if (type == "word" && state.stateArg == "@counter-style") {
323 override = "variable";
325 override = "variable";
324 return "restricted_atBlock_before";
326 return "restricted_atBlock_before";
325 }
327 }
326 return pass(type, stream, state);
328 return pass(type, stream, state);
327 };
329 };
328
330
329 states.restricted_atBlock = function(type, stream, state) {
331 states.restricted_atBlock = function(type, stream, state) {
330 if (type == "}") {
332 if (type == "}") {
331 state.stateArg = null;
333 state.stateArg = null;
332 return popContext(state);
334 return popContext(state);
333 }
335 }
334 if (type == "word") {
336 if (type == "word") {
335 if ((state.stateArg == "@font-face" && !fontProperties.hasOwnProperty(stream.current().toLowerCase())) ||
337 if ((state.stateArg == "@font-face" && !fontProperties.hasOwnProperty(stream.current().toLowerCase())) ||
336 (state.stateArg == "@counter-style" && !counterDescriptors.hasOwnProperty(stream.current().toLowerCase())))
338 (state.stateArg == "@counter-style" && !counterDescriptors.hasOwnProperty(stream.current().toLowerCase())))
337 override = "error";
339 override = "error";
338 else
340 else
339 override = "property";
341 override = "property";
340 return "maybeprop";
342 return "maybeprop";
341 }
343 }
342 return "restricted_atBlock";
344 return "restricted_atBlock";
343 };
345 };
344
346
345 states.keyframes = function(type, stream, state) {
347 states.keyframes = function(type, stream, state) {
346 if (type == "word") { override = "variable"; return "keyframes"; }
348 if (type == "word") { override = "variable"; return "keyframes"; }
347 if (type == "{") return pushContext(state, stream, "top");
349 if (type == "{") return pushContext(state, stream, "top");
348 return pass(type, stream, state);
350 return pass(type, stream, state);
349 };
351 };
350
352
351 states.at = function(type, stream, state) {
353 states.at = function(type, stream, state) {
352 if (type == ";") return popContext(state);
354 if (type == ";") return popContext(state);
353 if (type == "{" || type == "}") return popAndPass(type, stream, state);
355 if (type == "{" || type == "}") return popAndPass(type, stream, state);
354 if (type == "word") override = "tag";
356 if (type == "word") override = "tag";
355 else if (type == "hash") override = "builtin";
357 else if (type == "hash") override = "builtin";
356 return "at";
358 return "at";
357 };
359 };
358
360
359 states.interpolation = function(type, stream, state) {
361 states.interpolation = function(type, stream, state) {
360 if (type == "}") return popContext(state);
362 if (type == "}") return popContext(state);
361 if (type == "{" || type == ";") return popAndPass(type, stream, state);
363 if (type == "{" || type == ";") return popAndPass(type, stream, state);
362 if (type == "word") override = "variable";
364 if (type == "word") override = "variable";
363 else if (type != "variable" && type != "(" && type != ")") override = "error";
365 else if (type != "variable" && type != "(" && type != ")") override = "error";
364 return "interpolation";
366 return "interpolation";
365 };
367 };
366
368
367 return {
369 return {
368 startState: function(base) {
370 startState: function(base) {
369 return {tokenize: null,
371 return {tokenize: null,
370 state: inline ? "block" : "top",
372 state: inline ? "block" : "top",
371 stateArg: null,
373 stateArg: null,
372 context: new Context(inline ? "block" : "top", base || 0, null)};
374 context: new Context(inline ? "block" : "top", base || 0, null)};
373 },
375 },
374
376
375 token: function(stream, state) {
377 token: function(stream, state) {
376 if (!state.tokenize && stream.eatSpace()) return null;
378 if (!state.tokenize && stream.eatSpace()) return null;
377 var style = (state.tokenize || tokenBase)(stream, state);
379 var style = (state.tokenize || tokenBase)(stream, state);
378 if (style && typeof style == "object") {
380 if (style && typeof style == "object") {
379 type = style[1];
381 type = style[1];
380 style = style[0];
382 style = style[0];
381 }
383 }
382 override = style;
384 override = style;
385 if (type != "comment")
383 state.state = states[state.state](type, stream, state);
386 state.state = states[state.state](type, stream, state);
384 return override;
387 return override;
385 },
388 },
386
389
387 indent: function(state, textAfter) {
390 indent: function(state, textAfter) {
388 var cx = state.context, ch = textAfter && textAfter.charAt(0);
391 var cx = state.context, ch = textAfter && textAfter.charAt(0);
389 var indent = cx.indent;
392 var indent = cx.indent;
390 if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
393 if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
391 if (cx.prev) {
394 if (cx.prev) {
392 if (ch == "}" && (cx.type == "block" || cx.type == "top" ||
395 if (ch == "}" && (cx.type == "block" || cx.type == "top" ||
393 cx.type == "interpolation" || cx.type == "restricted_atBlock")) {
396 cx.type == "interpolation" || cx.type == "restricted_atBlock")) {
394 // Resume indentation from parent context.
397 // Resume indentation from parent context.
395 cx = cx.prev;
398 cx = cx.prev;
396 indent = cx.indent;
399 indent = cx.indent;
397 } else if (ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") ||
400 } else if (ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") ||
398 ch == "{" && (cx.type == "at" || cx.type == "atBlock")) {
401 ch == "{" && (cx.type == "at" || cx.type == "atBlock")) {
399 // Dedent relative to current context.
402 // Dedent relative to current context.
400 indent = Math.max(0, cx.indent - indentUnit);
403 indent = Math.max(0, cx.indent - indentUnit);
401 cx = cx.prev;
402 }
404 }
403 }
405 }
404 return indent;
406 return indent;
405 },
407 },
406
408
407 electricChars: "}",
409 electricChars: "}",
408 blockCommentStart: "/*",
410 blockCommentStart: "/*",
409 blockCommentEnd: "*/",
411 blockCommentEnd: "*/",
412 blockCommentContinue: " * ",
413 lineComment: lineComment,
410 fold: "brace"
414 fold: "brace"
411 };
415 };
412 });
416 });
413
417
414 function keySet(array) {
418 function keySet(array) {
415 var keys = {};
419 var keys = {};
416 for (var i = 0; i < array.length; ++i) {
420 for (var i = 0; i < array.length; ++i) {
417 keys[array[i]] = true;
421 keys[array[i].toLowerCase()] = true;
418 }
422 }
419 return keys;
423 return keys;
420 }
424 }
421
425
422 var documentTypes_ = [
426 var documentTypes_ = [
423 "domain", "regexp", "url", "url-prefix"
427 "domain", "regexp", "url", "url-prefix"
424 ], documentTypes = keySet(documentTypes_);
428 ], documentTypes = keySet(documentTypes_);
425
429
426 var mediaTypes_ = [
430 var mediaTypes_ = [
427 "all", "aural", "braille", "handheld", "print", "projection", "screen",
431 "all", "aural", "braille", "handheld", "print", "projection", "screen",
428 "tty", "tv", "embossed"
432 "tty", "tv", "embossed"
429 ], mediaTypes = keySet(mediaTypes_);
433 ], mediaTypes = keySet(mediaTypes_);
430
434
431 var mediaFeatures_ = [
435 var mediaFeatures_ = [
432 "width", "min-width", "max-width", "height", "min-height", "max-height",
436 "width", "min-width", "max-width", "height", "min-height", "max-height",
433 "device-width", "min-device-width", "max-device-width", "device-height",
437 "device-width", "min-device-width", "max-device-width", "device-height",
434 "min-device-height", "max-device-height", "aspect-ratio",
438 "min-device-height", "max-device-height", "aspect-ratio",
435 "min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio",
439 "min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio",
436 "min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
440 "min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
437 "max-color", "color-index", "min-color-index", "max-color-index",
441 "max-color", "color-index", "min-color-index", "max-color-index",
438 "monochrome", "min-monochrome", "max-monochrome", "resolution",
442 "monochrome", "min-monochrome", "max-monochrome", "resolution",
439 "min-resolution", "max-resolution", "scan", "grid", "orientation",
443 "min-resolution", "max-resolution", "scan", "grid", "orientation",
440 "device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio",
444 "device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio",
441 "pointer", "any-pointer", "hover", "any-hover"
445 "pointer", "any-pointer", "hover", "any-hover"
442 ], mediaFeatures = keySet(mediaFeatures_);
446 ], mediaFeatures = keySet(mediaFeatures_);
443
447
444 var mediaValueKeywords_ = [
448 var mediaValueKeywords_ = [
445 "landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover",
449 "landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover",
446 "interlace", "progressive"
450 "interlace", "progressive"
447 ], mediaValueKeywords = keySet(mediaValueKeywords_);
451 ], mediaValueKeywords = keySet(mediaValueKeywords_);
448
452
449 var propertyKeywords_ = [
453 var propertyKeywords_ = [
450 "align-content", "align-items", "align-self", "alignment-adjust",
454 "align-content", "align-items", "align-self", "alignment-adjust",
451 "alignment-baseline", "anchor-point", "animation", "animation-delay",
455 "alignment-baseline", "anchor-point", "animation", "animation-delay",
452 "animation-direction", "animation-duration", "animation-fill-mode",
456 "animation-direction", "animation-duration", "animation-fill-mode",
453 "animation-iteration-count", "animation-name", "animation-play-state",
457 "animation-iteration-count", "animation-name", "animation-play-state",
454 "animation-timing-function", "appearance", "azimuth", "backface-visibility",
458 "animation-timing-function", "appearance", "azimuth", "backface-visibility",
455 "background", "background-attachment", "background-blend-mode", "background-clip",
459 "background", "background-attachment", "background-blend-mode", "background-clip",
456 "background-color", "background-image", "background-origin", "background-position",
460 "background-color", "background-image", "background-origin", "background-position",
457 "background-repeat", "background-size", "baseline-shift", "binding",
461 "background-repeat", "background-size", "baseline-shift", "binding",
458 "bleed", "bookmark-label", "bookmark-level", "bookmark-state",
462 "bleed", "bookmark-label", "bookmark-level", "bookmark-state",
459 "bookmark-target", "border", "border-bottom", "border-bottom-color",
463 "bookmark-target", "border", "border-bottom", "border-bottom-color",
460 "border-bottom-left-radius", "border-bottom-right-radius",
464 "border-bottom-left-radius", "border-bottom-right-radius",
461 "border-bottom-style", "border-bottom-width", "border-collapse",
465 "border-bottom-style", "border-bottom-width", "border-collapse",
462 "border-color", "border-image", "border-image-outset",
466 "border-color", "border-image", "border-image-outset",
463 "border-image-repeat", "border-image-slice", "border-image-source",
467 "border-image-repeat", "border-image-slice", "border-image-source",
464 "border-image-width", "border-left", "border-left-color",
468 "border-image-width", "border-left", "border-left-color",
465 "border-left-style", "border-left-width", "border-radius", "border-right",
469 "border-left-style", "border-left-width", "border-radius", "border-right",
466 "border-right-color", "border-right-style", "border-right-width",
470 "border-right-color", "border-right-style", "border-right-width",
467 "border-spacing", "border-style", "border-top", "border-top-color",
471 "border-spacing", "border-style", "border-top", "border-top-color",
468 "border-top-left-radius", "border-top-right-radius", "border-top-style",
472 "border-top-left-radius", "border-top-right-radius", "border-top-style",
469 "border-top-width", "border-width", "bottom", "box-decoration-break",
473 "border-top-width", "border-width", "bottom", "box-decoration-break",
470 "box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
474 "box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
471 "caption-side", "clear", "clip", "color", "color-profile", "column-count",
475 "caption-side", "caret-color", "clear", "clip", "color", "color-profile", "column-count",
472 "column-fill", "column-gap", "column-rule", "column-rule-color",
476 "column-fill", "column-gap", "column-rule", "column-rule-color",
473 "column-rule-style", "column-rule-width", "column-span", "column-width",
477 "column-rule-style", "column-rule-width", "column-span", "column-width",
474 "columns", "content", "counter-increment", "counter-reset", "crop", "cue",
478 "columns", "content", "counter-increment", "counter-reset", "crop", "cue",
475 "cue-after", "cue-before", "cursor", "direction", "display",
479 "cue-after", "cue-before", "cursor", "direction", "display",
476 "dominant-baseline", "drop-initial-after-adjust",
480 "dominant-baseline", "drop-initial-after-adjust",
477 "drop-initial-after-align", "drop-initial-before-adjust",
481 "drop-initial-after-align", "drop-initial-before-adjust",
478 "drop-initial-before-align", "drop-initial-size", "drop-initial-value",
482 "drop-initial-before-align", "drop-initial-size", "drop-initial-value",
479 "elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
483 "elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
480 "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
484 "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
481 "float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings",
485 "float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings",
482 "font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust",
486 "font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust",
483 "font-stretch", "font-style", "font-synthesis", "font-variant",
487 "font-stretch", "font-style", "font-synthesis", "font-variant",
484 "font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
488 "font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
485 "font-variant-ligatures", "font-variant-numeric", "font-variant-position",
489 "font-variant-ligatures", "font-variant-numeric", "font-variant-position",
486 "font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow",
490 "font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow",
487 "grid-auto-position", "grid-auto-rows", "grid-column", "grid-column-end",
491 "grid-auto-rows", "grid-column", "grid-column-end", "grid-column-gap",
488 "grid-column-start", "grid-row", "grid-row-end", "grid-row-start",
492 "grid-column-start", "grid-gap", "grid-row", "grid-row-end", "grid-row-gap",
489 "grid-template", "grid-template-areas", "grid-template-columns",
493 "grid-row-start", "grid-template", "grid-template-areas", "grid-template-columns",
490 "grid-template-rows", "hanging-punctuation", "height", "hyphens",
494 "grid-template-rows", "hanging-punctuation", "height", "hyphens",
491 "icon", "image-orientation", "image-rendering", "image-resolution",
495 "icon", "image-orientation", "image-rendering", "image-resolution",
492 "inline-box-align", "justify-content", "left", "letter-spacing",
496 "inline-box-align", "justify-content", "justify-items", "justify-self", "left", "letter-spacing",
493 "line-break", "line-height", "line-stacking", "line-stacking-ruby",
497 "line-break", "line-height", "line-stacking", "line-stacking-ruby",
494 "line-stacking-shift", "line-stacking-strategy", "list-style",
498 "line-stacking-shift", "line-stacking-strategy", "list-style",
495 "list-style-image", "list-style-position", "list-style-type", "margin",
499 "list-style-image", "list-style-position", "list-style-type", "margin",
496 "margin-bottom", "margin-left", "margin-right", "margin-top",
500 "margin-bottom", "margin-left", "margin-right", "margin-top",
497 "marker-offset", "marks", "marquee-direction", "marquee-loop",
501 "marks", "marquee-direction", "marquee-loop",
498 "marquee-play-count", "marquee-speed", "marquee-style", "max-height",
502 "marquee-play-count", "marquee-speed", "marquee-style", "max-height",
499 "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index",
503 "max-width", "min-height", "min-width", "mix-blend-mode", "move-to", "nav-down", "nav-index",
500 "nav-left", "nav-right", "nav-up", "object-fit", "object-position",
504 "nav-left", "nav-right", "nav-up", "object-fit", "object-position",
501 "opacity", "order", "orphans", "outline",
505 "opacity", "order", "orphans", "outline",
502 "outline-color", "outline-offset", "outline-style", "outline-width",
506 "outline-color", "outline-offset", "outline-style", "outline-width",
503 "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
507 "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
504 "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
508 "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
505 "page", "page-break-after", "page-break-before", "page-break-inside",
509 "page", "page-break-after", "page-break-before", "page-break-inside",
506 "page-policy", "pause", "pause-after", "pause-before", "perspective",
510 "page-policy", "pause", "pause-after", "pause-before", "perspective",
507 "perspective-origin", "pitch", "pitch-range", "play-during", "position",
511 "perspective-origin", "pitch", "pitch-range", "place-content", "place-items", "place-self", "play-during", "position",
508 "presentation-level", "punctuation-trim", "quotes", "region-break-after",
512 "presentation-level", "punctuation-trim", "quotes", "region-break-after",
509 "region-break-before", "region-break-inside", "region-fragment",
513 "region-break-before", "region-break-inside", "region-fragment",
510 "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
514 "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
511 "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
515 "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
512 "ruby-position", "ruby-span", "shape-image-threshold", "shape-inside", "shape-margin",
516 "ruby-position", "ruby-span", "shape-image-threshold", "shape-inside", "shape-margin",
513 "shape-outside", "size", "speak", "speak-as", "speak-header",
517 "shape-outside", "size", "speak", "speak-as", "speak-header",
514 "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
518 "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
515 "tab-size", "table-layout", "target", "target-name", "target-new",
519 "tab-size", "table-layout", "target", "target-name", "target-new",
516 "target-position", "text-align", "text-align-last", "text-decoration",
520 "target-position", "text-align", "text-align-last", "text-decoration",
517 "text-decoration-color", "text-decoration-line", "text-decoration-skip",
521 "text-decoration-color", "text-decoration-line", "text-decoration-skip",
518 "text-decoration-style", "text-emphasis", "text-emphasis-color",
522 "text-decoration-style", "text-emphasis", "text-emphasis-color",
519 "text-emphasis-position", "text-emphasis-style", "text-height",
523 "text-emphasis-position", "text-emphasis-style", "text-height",
520 "text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
524 "text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
521 "text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
525 "text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
522 "text-wrap", "top", "transform", "transform-origin", "transform-style",
526 "text-wrap", "top", "transform", "transform-origin", "transform-style",
523 "transition", "transition-delay", "transition-duration",
527 "transition", "transition-delay", "transition-duration",
524 "transition-property", "transition-timing-function", "unicode-bidi",
528 "transition-property", "transition-timing-function", "unicode-bidi",
525 "vertical-align", "visibility", "voice-balance", "voice-duration",
529 "user-select", "vertical-align", "visibility", "voice-balance", "voice-duration",
526 "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
530 "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
527 "voice-volume", "volume", "white-space", "widows", "width", "word-break",
531 "voice-volume", "volume", "white-space", "widows", "width", "will-change", "word-break",
528 "word-spacing", "word-wrap", "z-index",
532 "word-spacing", "word-wrap", "z-index",
529 // SVG-specific
533 // SVG-specific
530 "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
534 "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
531 "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
535 "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
532 "color-interpolation", "color-interpolation-filters",
536 "color-interpolation", "color-interpolation-filters",
533 "color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering",
537 "color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering",
534 "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke",
538 "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke",
535 "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
539 "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
536 "stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering",
540 "stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering",
537 "baseline-shift", "dominant-baseline", "glyph-orientation-horizontal",
541 "baseline-shift", "dominant-baseline", "glyph-orientation-horizontal",
538 "glyph-orientation-vertical", "text-anchor", "writing-mode"
542 "glyph-orientation-vertical", "text-anchor", "writing-mode"
539 ], propertyKeywords = keySet(propertyKeywords_);
543 ], propertyKeywords = keySet(propertyKeywords_);
540
544
541 var nonStandardPropertyKeywords_ = [
545 var nonStandardPropertyKeywords_ = [
542 "scrollbar-arrow-color", "scrollbar-base-color", "scrollbar-dark-shadow-color",
546 "scrollbar-arrow-color", "scrollbar-base-color", "scrollbar-dark-shadow-color",
543 "scrollbar-face-color", "scrollbar-highlight-color", "scrollbar-shadow-color",
547 "scrollbar-face-color", "scrollbar-highlight-color", "scrollbar-shadow-color",
544 "scrollbar-3d-light-color", "scrollbar-track-color", "shape-inside",
548 "scrollbar-3d-light-color", "scrollbar-track-color", "shape-inside",
545 "searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button",
549 "searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button",
546 "searchfield-results-decoration", "zoom"
550 "searchfield-results-decoration", "zoom"
547 ], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_);
551 ], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_);
548
552
549 var fontProperties_ = [
553 var fontProperties_ = [
550 "font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
554 "font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
551 "font-stretch", "font-weight", "font-style"
555 "font-stretch", "font-weight", "font-style"
552 ], fontProperties = keySet(fontProperties_);
556 ], fontProperties = keySet(fontProperties_);
553
557
554 var counterDescriptors_ = [
558 var counterDescriptors_ = [
555 "additive-symbols", "fallback", "negative", "pad", "prefix", "range",
559 "additive-symbols", "fallback", "negative", "pad", "prefix", "range",
556 "speak-as", "suffix", "symbols", "system"
560 "speak-as", "suffix", "symbols", "system"
557 ], counterDescriptors = keySet(counterDescriptors_);
561 ], counterDescriptors = keySet(counterDescriptors_);
558
562
559 var colorKeywords_ = [
563 var colorKeywords_ = [
560 "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
564 "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
561 "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
565 "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
562 "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
566 "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
563 "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
567 "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
564 "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
568 "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
565 "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
569 "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
566 "darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
570 "darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
567 "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
571 "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
568 "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
572 "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
569 "gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
573 "gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
570 "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
574 "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
571 "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
575 "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
572 "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
576 "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
573 "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
577 "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
574 "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
578 "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
575 "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
579 "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
576 "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
580 "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
577 "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
581 "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
578 "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered",
582 "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered",
579 "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
583 "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
580 "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
584 "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
581 "purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown",
585 "purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown",
582 "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
586 "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
583 "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
587 "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
584 "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
588 "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
585 "whitesmoke", "yellow", "yellowgreen"
589 "whitesmoke", "yellow", "yellowgreen"
586 ], colorKeywords = keySet(colorKeywords_);
590 ], colorKeywords = keySet(colorKeywords_);
587
591
588 var valueKeywords_ = [
592 var valueKeywords_ = [
589 "above", "absolute", "activeborder", "additive", "activecaption", "afar",
593 "above", "absolute", "activeborder", "additive", "activecaption", "afar",
590 "after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate",
594 "after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate",
591 "always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
595 "always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
592 "arabic-indic", "armenian", "asterisks", "attr", "auto", "avoid", "avoid-column", "avoid-page",
596 "arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page",
593 "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
597 "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
594 "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
598 "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
595 "both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel",
599 "both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel",
596 "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian",
600 "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian",
597 "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
601 "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
598 "cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
602 "cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
599 "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
603 "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
600 "col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse",
604 "col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse",
601 "compact", "condensed", "contain", "content",
605 "compact", "condensed", "contain", "content", "contents",
602 "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop",
606 "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop",
603 "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
607 "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
604 "decimal-leading-zero", "default", "default-button", "destination-atop",
608 "decimal-leading-zero", "default", "default-button", "dense", "destination-atop",
605 "destination-in", "destination-out", "destination-over", "devanagari", "difference",
609 "destination-in", "destination-out", "destination-over", "devanagari", "difference",
606 "disc", "discard", "disclosure-closed", "disclosure-open", "document",
610 "disc", "discard", "disclosure-closed", "disclosure-open", "document",
607 "dot-dash", "dot-dot-dash",
611 "dot-dash", "dot-dot-dash",
608 "dotted", "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
612 "dotted", "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
609 "element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
613 "element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
610 "ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
614 "ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
611 "ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
615 "ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
612 "ethiopic-halehame-aa-et", "ethiopic-halehame-am-et",
616 "ethiopic-halehame-aa-et", "ethiopic-halehame-am-et",
613 "ethiopic-halehame-gez", "ethiopic-halehame-om-et",
617 "ethiopic-halehame-gez", "ethiopic-halehame-om-et",
614 "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
618 "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
615 "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig",
619 "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig",
616 "ethiopic-numeric", "ew-resize", "exclusion", "expanded", "extends", "extra-condensed",
620 "ethiopic-numeric", "ew-resize", "exclusion", "expanded", "extends", "extra-condensed",
617 "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes",
621 "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes",
618 "forwards", "from", "geometricPrecision", "georgian", "graytext", "groove",
622 "forwards", "from", "geometricPrecision", "georgian", "graytext", "grid", "groove",
619 "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hard-light", "hebrew",
623 "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hard-light", "hebrew",
620 "help", "hidden", "hide", "higher", "highlight", "highlighttext",
624 "help", "hidden", "hide", "higher", "highlight", "highlighttext",
621 "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "hue", "icon", "ignore",
625 "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "hue", "icon", "ignore",
622 "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
626 "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
623 "infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
627 "infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
624 "inline-block", "inline-flex", "inline-table", "inset", "inside", "intrinsic", "invert",
628 "inline-block", "inline-flex", "inline-grid", "inline-table", "inset", "inside", "intrinsic", "invert",
625 "italic", "japanese-formal", "japanese-informal", "justify", "kannada",
629 "italic", "japanese-formal", "japanese-informal", "justify", "kannada",
626 "katakana", "katakana-iroha", "keep-all", "khmer",
630 "katakana", "katakana-iroha", "keep-all", "khmer",
627 "korean-hangul-formal", "korean-hanja-formal", "korean-hanja-informal",
631 "korean-hangul-formal", "korean-hanja-formal", "korean-hanja-informal",
628 "landscape", "lao", "large", "larger", "left", "level", "lighter", "lighten",
632 "landscape", "lao", "large", "larger", "left", "level", "lighter", "lighten",
629 "line-through", "linear", "linear-gradient", "lines", "list-item", "listbox", "listitem",
633 "line-through", "linear", "linear-gradient", "lines", "list-item", "listbox", "listitem",
630 "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
634 "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
631 "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
635 "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
632 "lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "match", "matrix", "matrix3d",
636 "lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "match", "matrix", "matrix3d",
633 "media-controls-background", "media-current-time-display",
637 "media-controls-background", "media-current-time-display",
634 "media-fullscreen-button", "media-mute-button", "media-play-button",
638 "media-fullscreen-button", "media-mute-button", "media-play-button",
635 "media-return-to-realtime-button", "media-rewind-button",
639 "media-return-to-realtime-button", "media-rewind-button",
636 "media-seek-back-button", "media-seek-forward-button", "media-slider",
640 "media-seek-back-button", "media-seek-forward-button", "media-slider",
637 "media-sliderthumb", "media-time-remaining-display", "media-volume-slider",
641 "media-sliderthumb", "media-time-remaining-display", "media-volume-slider",
638 "media-volume-slider-container", "media-volume-sliderthumb", "medium",
642 "media-volume-slider-container", "media-volume-sliderthumb", "medium",
639 "menu", "menulist", "menulist-button", "menulist-text",
643 "menu", "menulist", "menulist-button", "menulist-text",
640 "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
644 "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
641 "mix", "mongolian", "monospace", "move", "multiple", "multiply", "myanmar", "n-resize",
645 "mix", "mongolian", "monospace", "move", "multiple", "multiply", "myanmar", "n-resize",
642 "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
646 "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
643 "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
647 "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
644 "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote",
648 "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "opacity", "open-quote",
645 "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
649 "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
646 "outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
650 "outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
647 "painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter",
651 "painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter",
648 "pointer", "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d",
652 "pointer", "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d",
649 "progress", "push-button", "radial-gradient", "radio", "read-only",
653 "progress", "push-button", "radial-gradient", "radio", "read-only",
650 "read-write", "read-write-plaintext-only", "rectangle", "region",
654 "read-write", "read-write-plaintext-only", "rectangle", "region",
651 "relative", "repeat", "repeating-linear-gradient",
655 "relative", "repeat", "repeating-linear-gradient",
652 "repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
656 "repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
653 "rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY",
657 "rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY",
654 "rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running",
658 "rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running",
655 "s-resize", "sans-serif", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen",
659 "s-resize", "sans-serif", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen",
656 "scroll", "scrollbar", "se-resize", "searchfield",
660 "scroll", "scrollbar", "scroll-position", "se-resize", "searchfield",
657 "searchfield-cancel-button", "searchfield-decoration",
661 "searchfield-cancel-button", "searchfield-decoration",
658 "searchfield-results-button", "searchfield-results-decoration",
662 "searchfield-results-button", "searchfield-results-decoration", "self-start", "self-end",
659 "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
663 "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
660 "simp-chinese-formal", "simp-chinese-informal", "single",
664 "simp-chinese-formal", "simp-chinese-informal", "single",
661 "skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
665 "skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
662 "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
666 "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
663 "small", "small-caps", "small-caption", "smaller", "soft-light", "solid", "somali",
667 "small", "small-caps", "small-caption", "smaller", "soft-light", "solid", "somali",
664 "source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "spell-out", "square",
668 "source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square",
665 "square-button", "start", "static", "status-bar", "stretch", "stroke", "sub",
669 "square-button", "start", "static", "status-bar", "stretch", "stroke", "sub",
666 "subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "table",
670 "subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table",
667 "table-caption", "table-cell", "table-column", "table-column-group",
671 "table-caption", "table-cell", "table-column", "table-column-group",
668 "table-footer-group", "table-header-group", "table-row", "table-row-group",
672 "table-footer-group", "table-header-group", "table-row", "table-row-group",
669 "tamil",
673 "tamil",
670 "telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai",
674 "telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai",
671 "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
675 "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
672 "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
676 "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
673 "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
677 "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
674 "trad-chinese-formal", "trad-chinese-informal",
678 "trad-chinese-formal", "trad-chinese-informal", "transform",
675 "translate", "translate3d", "translateX", "translateY", "translateZ",
679 "translate", "translate3d", "translateX", "translateY", "translateZ",
676 "transparent", "ultra-condensed", "ultra-expanded", "underline", "up",
680 "transparent", "ultra-condensed", "ultra-expanded", "underline", "unset", "up",
677 "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
681 "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
678 "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
682 "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
679 "var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
683 "var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
680 "visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
684 "visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
681 "window", "windowframe", "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor",
685 "window", "windowframe", "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor",
682 "xx-large", "xx-small"
686 "xx-large", "xx-small"
683 ], valueKeywords = keySet(valueKeywords_);
687 ], valueKeywords = keySet(valueKeywords_);
684
688
685 var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(mediaValueKeywords_)
689 var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(mediaValueKeywords_)
686 .concat(propertyKeywords_).concat(nonStandardPropertyKeywords_).concat(colorKeywords_)
690 .concat(propertyKeywords_).concat(nonStandardPropertyKeywords_).concat(colorKeywords_)
687 .concat(valueKeywords_);
691 .concat(valueKeywords_);
688 CodeMirror.registerHelper("hintWords", "css", allWords);
692 CodeMirror.registerHelper("hintWords", "css", allWords);
689
693
690 function tokenCComment(stream, state) {
694 function tokenCComment(stream, state) {
691 var maybeEnd = false, ch;
695 var maybeEnd = false, ch;
692 while ((ch = stream.next()) != null) {
696 while ((ch = stream.next()) != null) {
693 if (maybeEnd && ch == "/") {
697 if (maybeEnd && ch == "/") {
694 state.tokenize = null;
698 state.tokenize = null;
695 break;
699 break;
696 }
700 }
697 maybeEnd = (ch == "*");
701 maybeEnd = (ch == "*");
698 }
702 }
699 return ["comment", "comment"];
703 return ["comment", "comment"];
700 }
704 }
701
705
702 CodeMirror.defineMIME("text/css", {
706 CodeMirror.defineMIME("text/css", {
703 documentTypes: documentTypes,
707 documentTypes: documentTypes,
704 mediaTypes: mediaTypes,
708 mediaTypes: mediaTypes,
705 mediaFeatures: mediaFeatures,
709 mediaFeatures: mediaFeatures,
706 mediaValueKeywords: mediaValueKeywords,
710 mediaValueKeywords: mediaValueKeywords,
707 propertyKeywords: propertyKeywords,
711 propertyKeywords: propertyKeywords,
708 nonStandardPropertyKeywords: nonStandardPropertyKeywords,
712 nonStandardPropertyKeywords: nonStandardPropertyKeywords,
709 fontProperties: fontProperties,
713 fontProperties: fontProperties,
710 counterDescriptors: counterDescriptors,
714 counterDescriptors: counterDescriptors,
711 colorKeywords: colorKeywords,
715 colorKeywords: colorKeywords,
712 valueKeywords: valueKeywords,
716 valueKeywords: valueKeywords,
713 tokenHooks: {
717 tokenHooks: {
714 "/": function(stream, state) {
718 "/": function(stream, state) {
715 if (!stream.eat("*")) return false;
719 if (!stream.eat("*")) return false;
716 state.tokenize = tokenCComment;
720 state.tokenize = tokenCComment;
717 return tokenCComment(stream, state);
721 return tokenCComment(stream, state);
718 }
722 }
719 },
723 },
720 name: "css"
724 name: "css"
721 });
725 });
722
726
723 CodeMirror.defineMIME("text/x-scss", {
727 CodeMirror.defineMIME("text/x-scss", {
724 mediaTypes: mediaTypes,
728 mediaTypes: mediaTypes,
725 mediaFeatures: mediaFeatures,
729 mediaFeatures: mediaFeatures,
726 mediaValueKeywords: mediaValueKeywords,
730 mediaValueKeywords: mediaValueKeywords,
727 propertyKeywords: propertyKeywords,
731 propertyKeywords: propertyKeywords,
728 nonStandardPropertyKeywords: nonStandardPropertyKeywords,
732 nonStandardPropertyKeywords: nonStandardPropertyKeywords,
729 colorKeywords: colorKeywords,
733 colorKeywords: colorKeywords,
730 valueKeywords: valueKeywords,
734 valueKeywords: valueKeywords,
731 fontProperties: fontProperties,
735 fontProperties: fontProperties,
732 allowNested: true,
736 allowNested: true,
737 lineComment: "//",
733 tokenHooks: {
738 tokenHooks: {
734 "/": function(stream, state) {
739 "/": function(stream, state) {
735 if (stream.eat("/")) {
740 if (stream.eat("/")) {
736 stream.skipToEnd();
741 stream.skipToEnd();
737 return ["comment", "comment"];
742 return ["comment", "comment"];
738 } else if (stream.eat("*")) {
743 } else if (stream.eat("*")) {
739 state.tokenize = tokenCComment;
744 state.tokenize = tokenCComment;
740 return tokenCComment(stream, state);
745 return tokenCComment(stream, state);
741 } else {
746 } else {
742 return ["operator", "operator"];
747 return ["operator", "operator"];
743 }
748 }
744 },
749 },
745 ":": function(stream) {
750 ":": function(stream) {
746 if (stream.match(/\s*\{/))
751 if (stream.match(/\s*\{/, false))
747 return [null, "{"];
752 return [null, null]
748 return false;
753 return false;
749 },
754 },
750 "$": function(stream) {
755 "$": function(stream) {
751 stream.match(/^[\w-]+/);
756 stream.match(/^[\w-]+/);
752 if (stream.match(/^\s*:/, false))
757 if (stream.match(/^\s*:/, false))
753 return ["variable-2", "variable-definition"];
758 return ["variable-2", "variable-definition"];
754 return ["variable-2", "variable"];
759 return ["variable-2", "variable"];
755 },
760 },
756 "#": function(stream) {
761 "#": function(stream) {
757 if (!stream.eat("{")) return false;
762 if (!stream.eat("{")) return false;
758 return [null, "interpolation"];
763 return [null, "interpolation"];
759 }
764 }
760 },
765 },
761 name: "css",
766 name: "css",
762 helperType: "scss"
767 helperType: "scss"
763 });
768 });
764
769
765 CodeMirror.defineMIME("text/x-less", {
770 CodeMirror.defineMIME("text/x-less", {
766 mediaTypes: mediaTypes,
771 mediaTypes: mediaTypes,
767 mediaFeatures: mediaFeatures,
772 mediaFeatures: mediaFeatures,
768 mediaValueKeywords: mediaValueKeywords,
773 mediaValueKeywords: mediaValueKeywords,
769 propertyKeywords: propertyKeywords,
774 propertyKeywords: propertyKeywords,
770 nonStandardPropertyKeywords: nonStandardPropertyKeywords,
775 nonStandardPropertyKeywords: nonStandardPropertyKeywords,
771 colorKeywords: colorKeywords,
776 colorKeywords: colorKeywords,
772 valueKeywords: valueKeywords,
777 valueKeywords: valueKeywords,
773 fontProperties: fontProperties,
778 fontProperties: fontProperties,
774 allowNested: true,
779 allowNested: true,
780 lineComment: "//",
775 tokenHooks: {
781 tokenHooks: {
776 "/": function(stream, state) {
782 "/": function(stream, state) {
777 if (stream.eat("/")) {
783 if (stream.eat("/")) {
778 stream.skipToEnd();
784 stream.skipToEnd();
779 return ["comment", "comment"];
785 return ["comment", "comment"];
780 } else if (stream.eat("*")) {
786 } else if (stream.eat("*")) {
781 state.tokenize = tokenCComment;
787 state.tokenize = tokenCComment;
782 return tokenCComment(stream, state);
788 return tokenCComment(stream, state);
783 } else {
789 } else {
784 return ["operator", "operator"];
790 return ["operator", "operator"];
785 }
791 }
786 },
792 },
787 "@": function(stream) {
793 "@": function(stream) {
788 if (stream.eat("{")) return [null, "interpolation"];
794 if (stream.eat("{")) return [null, "interpolation"];
789 if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/, false)) return false;
795 if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i, false)) return false;
790 stream.eatWhile(/[\w\\\-]/);
796 stream.eatWhile(/[\w\\\-]/);
791 if (stream.match(/^\s*:/, false))
797 if (stream.match(/^\s*:/, false))
792 return ["variable-2", "variable-definition"];
798 return ["variable-2", "variable-definition"];
793 return ["variable-2", "variable"];
799 return ["variable-2", "variable"];
794 },
800 },
795 "&": function() {
801 "&": function() {
796 return ["atom", "atom"];
802 return ["atom", "atom"];
797 }
803 }
798 },
804 },
799 name: "css",
805 name: "css",
800 helperType: "less"
806 helperType: "less"
801 });
807 });
802
808
803 CodeMirror.defineMIME("text/x-gss", {
809 CodeMirror.defineMIME("text/x-gss", {
804 documentTypes: documentTypes,
810 documentTypes: documentTypes,
805 mediaTypes: mediaTypes,
811 mediaTypes: mediaTypes,
806 mediaFeatures: mediaFeatures,
812 mediaFeatures: mediaFeatures,
807 propertyKeywords: propertyKeywords,
813 propertyKeywords: propertyKeywords,
808 nonStandardPropertyKeywords: nonStandardPropertyKeywords,
814 nonStandardPropertyKeywords: nonStandardPropertyKeywords,
809 fontProperties: fontProperties,
815 fontProperties: fontProperties,
810 counterDescriptors: counterDescriptors,
816 counterDescriptors: counterDescriptors,
811 colorKeywords: colorKeywords,
817 colorKeywords: colorKeywords,
812 valueKeywords: valueKeywords,
818 valueKeywords: valueKeywords,
813 supportsAtComponent: true,
819 supportsAtComponent: true,
814 tokenHooks: {
820 tokenHooks: {
815 "/": function(stream, state) {
821 "/": function(stream, state) {
816 if (!stream.eat("*")) return false;
822 if (!stream.eat("*")) return false;
817 state.tokenize = tokenCComment;
823 state.tokenize = tokenCComment;
818 return tokenCComment(stream, state);
824 return tokenCComment(stream, state);
819 }
825 }
820 },
826 },
821 name: "css",
827 name: "css",
822 helperType: "gss"
828 helperType: "gss"
823 });
829 });
824
830
825 });
831 });
@@ -1,146 +1,150 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 // By the Neo4j Team and contributors.
4 // By the Neo4j Team and contributors.
5 // https://github.com/neo4j-contrib/CodeMirror
5 // https://github.com/neo4j-contrib/CodeMirror
6
6
7 (function(mod) {
7 (function(mod) {
8 if (typeof exports == "object" && typeof module == "object") // CommonJS
8 if (typeof exports == "object" && typeof module == "object") // CommonJS
9 mod(require("../../lib/codemirror"));
9 mod(require("../../lib/codemirror"));
10 else if (typeof define == "function" && define.amd) // AMD
10 else if (typeof define == "function" && define.amd) // AMD
11 define(["../../lib/codemirror"], mod);
11 define(["../../lib/codemirror"], mod);
12 else // Plain browser env
12 else // Plain browser env
13 mod(CodeMirror);
13 mod(CodeMirror);
14 })(function(CodeMirror) {
14 })(function(CodeMirror) {
15 "use strict";
15 "use strict";
16 var wordRegexp = function(words) {
16 var wordRegexp = function(words) {
17 return new RegExp("^(?:" + words.join("|") + ")$", "i");
17 return new RegExp("^(?:" + words.join("|") + ")$", "i");
18 };
18 };
19
19
20 CodeMirror.defineMode("cypher", function(config) {
20 CodeMirror.defineMode("cypher", function(config) {
21 var tokenBase = function(stream/*, state*/) {
21 var tokenBase = function(stream/*, state*/) {
22 var ch = stream.next();
22 var ch = stream.next();
23 if (ch === "\"" || ch === "'") {
23 if (ch ==='"') {
24 stream.match(/.+?["']/);
24 stream.match(/.*?"/);
25 return "string";
26 }
27 if (ch === "'") {
28 stream.match(/.*?'/);
25 return "string";
29 return "string";
26 }
30 }
27 if (/[{}\(\),\.;\[\]]/.test(ch)) {
31 if (/[{}\(\),\.;\[\]]/.test(ch)) {
28 curPunc = ch;
32 curPunc = ch;
29 return "node";
33 return "node";
30 } else if (ch === "/" && stream.eat("/")) {
34 } else if (ch === "/" && stream.eat("/")) {
31 stream.skipToEnd();
35 stream.skipToEnd();
32 return "comment";
36 return "comment";
33 } else if (operatorChars.test(ch)) {
37 } else if (operatorChars.test(ch)) {
34 stream.eatWhile(operatorChars);
38 stream.eatWhile(operatorChars);
35 return null;
39 return null;
36 } else {
40 } else {
37 stream.eatWhile(/[_\w\d]/);
41 stream.eatWhile(/[_\w\d]/);
38 if (stream.eat(":")) {
42 if (stream.eat(":")) {
39 stream.eatWhile(/[\w\d_\-]/);
43 stream.eatWhile(/[\w\d_\-]/);
40 return "atom";
44 return "atom";
41 }
45 }
42 var word = stream.current();
46 var word = stream.current();
43 if (funcs.test(word)) return "builtin";
47 if (funcs.test(word)) return "builtin";
44 if (preds.test(word)) return "def";
48 if (preds.test(word)) return "def";
45 if (keywords.test(word)) return "keyword";
49 if (keywords.test(word)) return "keyword";
46 return "variable";
50 return "variable";
47 }
51 }
48 };
52 };
49 var pushContext = function(state, type, col) {
53 var pushContext = function(state, type, col) {
50 return state.context = {
54 return state.context = {
51 prev: state.context,
55 prev: state.context,
52 indent: state.indent,
56 indent: state.indent,
53 col: col,
57 col: col,
54 type: type
58 type: type
55 };
59 };
56 };
60 };
57 var popContext = function(state) {
61 var popContext = function(state) {
58 state.indent = state.context.indent;
62 state.indent = state.context.indent;
59 return state.context = state.context.prev;
63 return state.context = state.context.prev;
60 };
64 };
61 var indentUnit = config.indentUnit;
65 var indentUnit = config.indentUnit;
62 var curPunc;
66 var curPunc;
63 var funcs = wordRegexp(["abs", "acos", "allShortestPaths", "asin", "atan", "atan2", "avg", "ceil", "coalesce", "collect", "cos", "cot", "count", "degrees", "e", "endnode", "exp", "extract", "filter", "floor", "haversin", "head", "id", "keys", "labels", "last", "left", "length", "log", "log10", "lower", "ltrim", "max", "min", "node", "nodes", "percentileCont", "percentileDisc", "pi", "radians", "rand", "range", "reduce", "rel", "relationship", "relationships", "replace", "reverse", "right", "round", "rtrim", "shortestPath", "sign", "sin", "size", "split", "sqrt", "startnode", "stdev", "stdevp", "str", "substring", "sum", "tail", "tan", "timestamp", "toFloat", "toInt", "toString", "trim", "type", "upper"]);
67 var funcs = wordRegexp(["abs", "acos", "allShortestPaths", "asin", "atan", "atan2", "avg", "ceil", "coalesce", "collect", "cos", "cot", "count", "degrees", "e", "endnode", "exp", "extract", "filter", "floor", "haversin", "head", "id", "keys", "labels", "last", "left", "length", "log", "log10", "lower", "ltrim", "max", "min", "node", "nodes", "percentileCont", "percentileDisc", "pi", "radians", "rand", "range", "reduce", "rel", "relationship", "relationships", "replace", "reverse", "right", "round", "rtrim", "shortestPath", "sign", "sin", "size", "split", "sqrt", "startnode", "stdev", "stdevp", "str", "substring", "sum", "tail", "tan", "timestamp", "toFloat", "toInt", "toString", "trim", "type", "upper"]);
64 var preds = wordRegexp(["all", "and", "any", "contains", "exists", "has", "in", "none", "not", "or", "single", "xor"]);
68 var preds = wordRegexp(["all", "and", "any", "contains", "exists", "has", "in", "none", "not", "or", "single", "xor"]);
65 var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "detach", "distinct", "drop", "else", "end", "ends", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "join", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "starts", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with"]);
69 var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "detach", "distinct", "drop", "else", "end", "ends", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "join", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "starts", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with", "call", "yield"]);
66 var operatorChars = /[*+\-<>=&|~%^]/;
70 var operatorChars = /[*+\-<>=&|~%^]/;
67
71
68 return {
72 return {
69 startState: function(/*base*/) {
73 startState: function(/*base*/) {
70 return {
74 return {
71 tokenize: tokenBase,
75 tokenize: tokenBase,
72 context: null,
76 context: null,
73 indent: 0,
77 indent: 0,
74 col: 0
78 col: 0
75 };
79 };
76 },
80 },
77 token: function(stream, state) {
81 token: function(stream, state) {
78 if (stream.sol()) {
82 if (stream.sol()) {
79 if (state.context && (state.context.align == null)) {
83 if (state.context && (state.context.align == null)) {
80 state.context.align = false;
84 state.context.align = false;
81 }
85 }
82 state.indent = stream.indentation();
86 state.indent = stream.indentation();
83 }
87 }
84 if (stream.eatSpace()) {
88 if (stream.eatSpace()) {
85 return null;
89 return null;
86 }
90 }
87 var style = state.tokenize(stream, state);
91 var style = state.tokenize(stream, state);
88 if (style !== "comment" && state.context && (state.context.align == null) && state.context.type !== "pattern") {
92 if (style !== "comment" && state.context && (state.context.align == null) && state.context.type !== "pattern") {
89 state.context.align = true;
93 state.context.align = true;
90 }
94 }
91 if (curPunc === "(") {
95 if (curPunc === "(") {
92 pushContext(state, ")", stream.column());
96 pushContext(state, ")", stream.column());
93 } else if (curPunc === "[") {
97 } else if (curPunc === "[") {
94 pushContext(state, "]", stream.column());
98 pushContext(state, "]", stream.column());
95 } else if (curPunc === "{") {
99 } else if (curPunc === "{") {
96 pushContext(state, "}", stream.column());
100 pushContext(state, "}", stream.column());
97 } else if (/[\]\}\)]/.test(curPunc)) {
101 } else if (/[\]\}\)]/.test(curPunc)) {
98 while (state.context && state.context.type === "pattern") {
102 while (state.context && state.context.type === "pattern") {
99 popContext(state);
103 popContext(state);
100 }
104 }
101 if (state.context && curPunc === state.context.type) {
105 if (state.context && curPunc === state.context.type) {
102 popContext(state);
106 popContext(state);
103 }
107 }
104 } else if (curPunc === "." && state.context && state.context.type === "pattern") {
108 } else if (curPunc === "." && state.context && state.context.type === "pattern") {
105 popContext(state);
109 popContext(state);
106 } else if (/atom|string|variable/.test(style) && state.context) {
110 } else if (/atom|string|variable/.test(style) && state.context) {
107 if (/[\}\]]/.test(state.context.type)) {
111 if (/[\}\]]/.test(state.context.type)) {
108 pushContext(state, "pattern", stream.column());
112 pushContext(state, "pattern", stream.column());
109 } else if (state.context.type === "pattern" && !state.context.align) {
113 } else if (state.context.type === "pattern" && !state.context.align) {
110 state.context.align = true;
114 state.context.align = true;
111 state.context.col = stream.column();
115 state.context.col = stream.column();
112 }
116 }
113 }
117 }
114 return style;
118 return style;
115 },
119 },
116 indent: function(state, textAfter) {
120 indent: function(state, textAfter) {
117 var firstChar = textAfter && textAfter.charAt(0);
121 var firstChar = textAfter && textAfter.charAt(0);
118 var context = state.context;
122 var context = state.context;
119 if (/[\]\}]/.test(firstChar)) {
123 if (/[\]\}]/.test(firstChar)) {
120 while (context && context.type === "pattern") {
124 while (context && context.type === "pattern") {
121 context = context.prev;
125 context = context.prev;
122 }
126 }
123 }
127 }
124 var closing = context && firstChar === context.type;
128 var closing = context && firstChar === context.type;
125 if (!context) return 0;
129 if (!context) return 0;
126 if (context.type === "keywords") return CodeMirror.commands.newlineAndIndent;
130 if (context.type === "keywords") return CodeMirror.commands.newlineAndIndent;
127 if (context.align) return context.col + (closing ? 0 : 1);
131 if (context.align) return context.col + (closing ? 0 : 1);
128 return context.indent + (closing ? 0 : indentUnit);
132 return context.indent + (closing ? 0 : indentUnit);
129 }
133 }
130 };
134 };
131 });
135 });
132
136
133 CodeMirror.modeExtensions["cypher"] = {
137 CodeMirror.modeExtensions["cypher"] = {
134 autoFormatLineBreaks: function(text) {
138 autoFormatLineBreaks: function(text) {
135 var i, lines, reProcessedPortion;
139 var i, lines, reProcessedPortion;
136 var lines = text.split("\n");
140 var lines = text.split("\n");
137 var reProcessedPortion = /\s+\b(return|where|order by|match|with|skip|limit|create|delete|set)\b\s/g;
141 var reProcessedPortion = /\s+\b(return|where|order by|match|with|skip|limit|create|delete|set)\b\s/g;
138 for (var i = 0; i < lines.length; i++)
142 for (var i = 0; i < lines.length; i++)
139 lines[i] = lines[i].replace(reProcessedPortion, " \n$1 ").trim();
143 lines[i] = lines[i].replace(reProcessedPortion, " \n$1 ").trim();
140 return lines.join("\n");
144 return lines.join("\n");
141 }
145 }
142 };
146 };
143
147
144 CodeMirror.defineMIME("application/x-cypher-query", "cypher");
148 CodeMirror.defineMIME("application/x-cypher-query", "cypher");
145
149
146 });
150 });
@@ -1,218 +1,223 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("d", function(config, parserConfig) {
14 CodeMirror.defineMode("d", function(config, parserConfig) {
15 var indentUnit = config.indentUnit,
15 var indentUnit = config.indentUnit,
16 statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
16 statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
17 keywords = parserConfig.keywords || {},
17 keywords = parserConfig.keywords || {},
18 builtin = parserConfig.builtin || {},
18 builtin = parserConfig.builtin || {},
19 blockKeywords = parserConfig.blockKeywords || {},
19 blockKeywords = parserConfig.blockKeywords || {},
20 atoms = parserConfig.atoms || {},
20 atoms = parserConfig.atoms || {},
21 hooks = parserConfig.hooks || {},
21 hooks = parserConfig.hooks || {},
22 multiLineStrings = parserConfig.multiLineStrings;
22 multiLineStrings = parserConfig.multiLineStrings;
23 var isOperatorChar = /[+\-*&%=<>!?|\/]/;
23 var isOperatorChar = /[+\-*&%=<>!?|\/]/;
24
24
25 var curPunc;
25 var curPunc;
26
26
27 function tokenBase(stream, state) {
27 function tokenBase(stream, state) {
28 var ch = stream.next();
28 var ch = stream.next();
29 if (hooks[ch]) {
29 if (hooks[ch]) {
30 var result = hooks[ch](stream, state);
30 var result = hooks[ch](stream, state);
31 if (result !== false) return result;
31 if (result !== false) return result;
32 }
32 }
33 if (ch == '"' || ch == "'" || ch == "`") {
33 if (ch == '"' || ch == "'" || ch == "`") {
34 state.tokenize = tokenString(ch);
34 state.tokenize = tokenString(ch);
35 return state.tokenize(stream, state);
35 return state.tokenize(stream, state);
36 }
36 }
37 if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
37 if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
38 curPunc = ch;
38 curPunc = ch;
39 return null;
39 return null;
40 }
40 }
41 if (/\d/.test(ch)) {
41 if (/\d/.test(ch)) {
42 stream.eatWhile(/[\w\.]/);
42 stream.eatWhile(/[\w\.]/);
43 return "number";
43 return "number";
44 }
44 }
45 if (ch == "/") {
45 if (ch == "/") {
46 if (stream.eat("+")) {
46 if (stream.eat("+")) {
47 state.tokenize = tokenComment;
47 state.tokenize = tokenNestedComment;
48 return tokenNestedComment(stream, state);
48 return tokenNestedComment(stream, state);
49 }
49 }
50 if (stream.eat("*")) {
50 if (stream.eat("*")) {
51 state.tokenize = tokenComment;
51 state.tokenize = tokenComment;
52 return tokenComment(stream, state);
52 return tokenComment(stream, state);
53 }
53 }
54 if (stream.eat("/")) {
54 if (stream.eat("/")) {
55 stream.skipToEnd();
55 stream.skipToEnd();
56 return "comment";
56 return "comment";
57 }
57 }
58 }
58 }
59 if (isOperatorChar.test(ch)) {
59 if (isOperatorChar.test(ch)) {
60 stream.eatWhile(isOperatorChar);
60 stream.eatWhile(isOperatorChar);
61 return "operator";
61 return "operator";
62 }
62 }
63 stream.eatWhile(/[\w\$_\xa1-\uffff]/);
63 stream.eatWhile(/[\w\$_\xa1-\uffff]/);
64 var cur = stream.current();
64 var cur = stream.current();
65 if (keywords.propertyIsEnumerable(cur)) {
65 if (keywords.propertyIsEnumerable(cur)) {
66 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
66 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
67 return "keyword";
67 return "keyword";
68 }
68 }
69 if (builtin.propertyIsEnumerable(cur)) {
69 if (builtin.propertyIsEnumerable(cur)) {
70 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
70 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
71 return "builtin";
71 return "builtin";
72 }
72 }
73 if (atoms.propertyIsEnumerable(cur)) return "atom";
73 if (atoms.propertyIsEnumerable(cur)) return "atom";
74 return "variable";
74 return "variable";
75 }
75 }
76
76
77 function tokenString(quote) {
77 function tokenString(quote) {
78 return function(stream, state) {
78 return function(stream, state) {
79 var escaped = false, next, end = false;
79 var escaped = false, next, end = false;
80 while ((next = stream.next()) != null) {
80 while ((next = stream.next()) != null) {
81 if (next == quote && !escaped) {end = true; break;}
81 if (next == quote && !escaped) {end = true; break;}
82 escaped = !escaped && next == "\\";
82 escaped = !escaped && next == "\\";
83 }
83 }
84 if (end || !(escaped || multiLineStrings))
84 if (end || !(escaped || multiLineStrings))
85 state.tokenize = null;
85 state.tokenize = null;
86 return "string";
86 return "string";
87 };
87 };
88 }
88 }
89
89
90 function tokenComment(stream, state) {
90 function tokenComment(stream, state) {
91 var maybeEnd = false, ch;
91 var maybeEnd = false, ch;
92 while (ch = stream.next()) {
92 while (ch = stream.next()) {
93 if (ch == "/" && maybeEnd) {
93 if (ch == "/" && maybeEnd) {
94 state.tokenize = null;
94 state.tokenize = null;
95 break;
95 break;
96 }
96 }
97 maybeEnd = (ch == "*");
97 maybeEnd = (ch == "*");
98 }
98 }
99 return "comment";
99 return "comment";
100 }
100 }
101
101
102 function tokenNestedComment(stream, state) {
102 function tokenNestedComment(stream, state) {
103 var maybeEnd = false, ch;
103 var maybeEnd = false, ch;
104 while (ch = stream.next()) {
104 while (ch = stream.next()) {
105 if (ch == "/" && maybeEnd) {
105 if (ch == "/" && maybeEnd) {
106 state.tokenize = null;
106 state.tokenize = null;
107 break;
107 break;
108 }
108 }
109 maybeEnd = (ch == "+");
109 maybeEnd = (ch == "+");
110 }
110 }
111 return "comment";
111 return "comment";
112 }
112 }
113
113
114 function Context(indented, column, type, align, prev) {
114 function Context(indented, column, type, align, prev) {
115 this.indented = indented;
115 this.indented = indented;
116 this.column = column;
116 this.column = column;
117 this.type = type;
117 this.type = type;
118 this.align = align;
118 this.align = align;
119 this.prev = prev;
119 this.prev = prev;
120 }
120 }
121 function pushContext(state, col, type) {
121 function pushContext(state, col, type) {
122 var indent = state.indented;
122 var indent = state.indented;
123 if (state.context && state.context.type == "statement")
123 if (state.context && state.context.type == "statement")
124 indent = state.context.indented;
124 indent = state.context.indented;
125 return state.context = new Context(indent, col, type, null, state.context);
125 return state.context = new Context(indent, col, type, null, state.context);
126 }
126 }
127 function popContext(state) {
127 function popContext(state) {
128 var t = state.context.type;
128 var t = state.context.type;
129 if (t == ")" || t == "]" || t == "}")
129 if (t == ")" || t == "]" || t == "}")
130 state.indented = state.context.indented;
130 state.indented = state.context.indented;
131 return state.context = state.context.prev;
131 return state.context = state.context.prev;
132 }
132 }
133
133
134 // Interface
134 // Interface
135
135
136 return {
136 return {
137 startState: function(basecolumn) {
137 startState: function(basecolumn) {
138 return {
138 return {
139 tokenize: null,
139 tokenize: null,
140 context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
140 context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
141 indented: 0,
141 indented: 0,
142 startOfLine: true
142 startOfLine: true
143 };
143 };
144 },
144 },
145
145
146 token: function(stream, state) {
146 token: function(stream, state) {
147 var ctx = state.context;
147 var ctx = state.context;
148 if (stream.sol()) {
148 if (stream.sol()) {
149 if (ctx.align == null) ctx.align = false;
149 if (ctx.align == null) ctx.align = false;
150 state.indented = stream.indentation();
150 state.indented = stream.indentation();
151 state.startOfLine = true;
151 state.startOfLine = true;
152 }
152 }
153 if (stream.eatSpace()) return null;
153 if (stream.eatSpace()) return null;
154 curPunc = null;
154 curPunc = null;
155 var style = (state.tokenize || tokenBase)(stream, state);
155 var style = (state.tokenize || tokenBase)(stream, state);
156 if (style == "comment" || style == "meta") return style;
156 if (style == "comment" || style == "meta") return style;
157 if (ctx.align == null) ctx.align = true;
157 if (ctx.align == null) ctx.align = true;
158
158
159 if ((curPunc == ";" || curPunc == ":" || curPunc == ",") && ctx.type == "statement") popContext(state);
159 if ((curPunc == ";" || curPunc == ":" || curPunc == ",") && ctx.type == "statement") popContext(state);
160 else if (curPunc == "{") pushContext(state, stream.column(), "}");
160 else if (curPunc == "{") pushContext(state, stream.column(), "}");
161 else if (curPunc == "[") pushContext(state, stream.column(), "]");
161 else if (curPunc == "[") pushContext(state, stream.column(), "]");
162 else if (curPunc == "(") pushContext(state, stream.column(), ")");
162 else if (curPunc == "(") pushContext(state, stream.column(), ")");
163 else if (curPunc == "}") {
163 else if (curPunc == "}") {
164 while (ctx.type == "statement") ctx = popContext(state);
164 while (ctx.type == "statement") ctx = popContext(state);
165 if (ctx.type == "}") ctx = popContext(state);
165 if (ctx.type == "}") ctx = popContext(state);
166 while (ctx.type == "statement") ctx = popContext(state);
166 while (ctx.type == "statement") ctx = popContext(state);
167 }
167 }
168 else if (curPunc == ctx.type) popContext(state);
168 else if (curPunc == ctx.type) popContext(state);
169 else if (((ctx.type == "}" || ctx.type == "top") && curPunc != ';') || (ctx.type == "statement" && curPunc == "newstatement"))
169 else if (((ctx.type == "}" || ctx.type == "top") && curPunc != ';') || (ctx.type == "statement" && curPunc == "newstatement"))
170 pushContext(state, stream.column(), "statement");
170 pushContext(state, stream.column(), "statement");
171 state.startOfLine = false;
171 state.startOfLine = false;
172 return style;
172 return style;
173 },
173 },
174
174
175 indent: function(state, textAfter) {
175 indent: function(state, textAfter) {
176 if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
176 if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
177 var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
177 var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
178 if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
178 if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
179 var closing = firstChar == ctx.type;
179 var closing = firstChar == ctx.type;
180 if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
180 if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
181 else if (ctx.align) return ctx.column + (closing ? 0 : 1);
181 else if (ctx.align) return ctx.column + (closing ? 0 : 1);
182 else return ctx.indented + (closing ? 0 : indentUnit);
182 else return ctx.indented + (closing ? 0 : indentUnit);
183 },
183 },
184
184
185 electricChars: "{}"
185 electricChars: "{}",
186 blockCommentStart: "/*",
187 blockCommentEnd: "*/",
188 blockCommentContinue: " * ",
189 lineComment: "//",
190 fold: "brace"
186 };
191 };
187 });
192 });
188
193
189 function words(str) {
194 function words(str) {
190 var obj = {}, words = str.split(" ");
195 var obj = {}, words = str.split(" ");
191 for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
196 for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
192 return obj;
197 return obj;
193 }
198 }
194
199
195 var blockKeywords = "body catch class do else enum for foreach foreach_reverse if in interface mixin " +
200 var blockKeywords = "body catch class do else enum for foreach foreach_reverse if in interface mixin " +
196 "out scope struct switch try union unittest version while with";
201 "out scope struct switch try union unittest version while with";
197
202
198 CodeMirror.defineMIME("text/x-d", {
203 CodeMirror.defineMIME("text/x-d", {
199 name: "d",
204 name: "d",
200 keywords: words("abstract alias align asm assert auto break case cast cdouble cent cfloat const continue " +
205 keywords: words("abstract alias align asm assert auto break case cast cdouble cent cfloat const continue " +
201 "debug default delegate delete deprecated export extern final finally function goto immutable " +
206 "debug default delegate delete deprecated export extern final finally function goto immutable " +
202 "import inout invariant is lazy macro module new nothrow override package pragma private " +
207 "import inout invariant is lazy macro module new nothrow override package pragma private " +
203 "protected public pure ref return shared short static super synchronized template this " +
208 "protected public pure ref return shared short static super synchronized template this " +
204 "throw typedef typeid typeof volatile __FILE__ __LINE__ __gshared __traits __vector __parameters " +
209 "throw typedef typeid typeof volatile __FILE__ __LINE__ __gshared __traits __vector __parameters " +
205 blockKeywords),
210 blockKeywords),
206 blockKeywords: words(blockKeywords),
211 blockKeywords: words(blockKeywords),
207 builtin: words("bool byte char creal dchar double float idouble ifloat int ireal long real short ubyte " +
212 builtin: words("bool byte char creal dchar double float idouble ifloat int ireal long real short ubyte " +
208 "ucent uint ulong ushort wchar wstring void size_t sizediff_t"),
213 "ucent uint ulong ushort wchar wstring void size_t sizediff_t"),
209 atoms: words("exit failure success true false null"),
214 atoms: words("exit failure success true false null"),
210 hooks: {
215 hooks: {
211 "@": function(stream, _state) {
216 "@": function(stream, _state) {
212 stream.eatWhile(/[\w\$_]/);
217 stream.eatWhile(/[\w\$_]/);
213 return "meta";
218 return "meta";
214 }
219 }
215 }
220 }
216 });
221 });
217
222
218 });
223 });
@@ -1,130 +1,166 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"), require("../clike/clike"));
6 mod(require("../../lib/codemirror"), require("../clike/clike"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror", "../clike/clike"], mod);
8 define(["../../lib/codemirror", "../clike/clike"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 var keywords = ("this super static final const abstract class extends external factory " +
14 var keywords = ("this super static final const abstract class extends external factory " +
15 "implements get native operator set typedef with enum throw rethrow " +
15 "implements mixin get native set typedef with enum throw rethrow " +
16 "assert break case continue default in return new deferred async await " +
16 "assert break case continue default in return new deferred async await covariant " +
17 "try catch finally do else for if switch while import library export " +
17 "try catch finally do else for if switch while import library export " +
18 "part of show hide is as").split(" ");
18 "part of show hide is as extension on").split(" ");
19 var blockKeywords = "try catch finally do else for if switch while".split(" ");
19 var blockKeywords = "try catch finally do else for if switch while".split(" ");
20 var atoms = "true false null".split(" ");
20 var atoms = "true false null".split(" ");
21 var builtins = "void bool num int double dynamic var String".split(" ");
21 var builtins = "void bool num int double dynamic var String".split(" ");
22
22
23 function set(words) {
23 function set(words) {
24 var obj = {};
24 var obj = {};
25 for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
25 for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
26 return obj;
26 return obj;
27 }
27 }
28
28
29 function pushInterpolationStack(state) {
29 function pushInterpolationStack(state) {
30 (state.interpolationStack || (state.interpolationStack = [])).push(state.tokenize);
30 (state.interpolationStack || (state.interpolationStack = [])).push(state.tokenize);
31 }
31 }
32
32
33 function popInterpolationStack(state) {
33 function popInterpolationStack(state) {
34 return (state.interpolationStack || (state.interpolationStack = [])).pop();
34 return (state.interpolationStack || (state.interpolationStack = [])).pop();
35 }
35 }
36
36
37 function sizeInterpolationStack(state) {
37 function sizeInterpolationStack(state) {
38 return state.interpolationStack ? state.interpolationStack.length : 0;
38 return state.interpolationStack ? state.interpolationStack.length : 0;
39 }
39 }
40
40
41 CodeMirror.defineMIME("application/dart", {
41 CodeMirror.defineMIME("application/dart", {
42 name: "clike",
42 name: "clike",
43 keywords: set(keywords),
43 keywords: set(keywords),
44 blockKeywords: set(blockKeywords),
44 blockKeywords: set(blockKeywords),
45 builtin: set(builtins),
45 builtin: set(builtins),
46 atoms: set(atoms),
46 atoms: set(atoms),
47 hooks: {
47 hooks: {
48 "@": function(stream) {
48 "@": function(stream) {
49 stream.eatWhile(/[\w\$_\.]/);
49 stream.eatWhile(/[\w\$_\.]/);
50 return "meta";
50 return "meta";
51 },
51 },
52
52
53 // custom string handling to deal with triple-quoted strings and string interpolation
53 // custom string handling to deal with triple-quoted strings and string interpolation
54 "'": function(stream, state) {
54 "'": function(stream, state) {
55 return tokenString("'", stream, state, false);
55 return tokenString("'", stream, state, false);
56 },
56 },
57 "\"": function(stream, state) {
57 "\"": function(stream, state) {
58 return tokenString("\"", stream, state, false);
58 return tokenString("\"", stream, state, false);
59 },
59 },
60 "r": function(stream, state) {
60 "r": function(stream, state) {
61 var peek = stream.peek();
61 var peek = stream.peek();
62 if (peek == "'" || peek == "\"") {
62 if (peek == "'" || peek == "\"") {
63 return tokenString(stream.next(), stream, state, true);
63 return tokenString(stream.next(), stream, state, true);
64 }
64 }
65 return false;
65 return false;
66 },
66 },
67
67
68 "}": function(_stream, state) {
68 "}": function(_stream, state) {
69 // "}" is end of interpolation, if interpolation stack is non-empty
69 // "}" is end of interpolation, if interpolation stack is non-empty
70 if (sizeInterpolationStack(state) > 0) {
70 if (sizeInterpolationStack(state) > 0) {
71 state.tokenize = popInterpolationStack(state);
71 state.tokenize = popInterpolationStack(state);
72 return null;
72 return null;
73 }
73 }
74 return false;
74 return false;
75 },
76
77 "/": function(stream, state) {
78 if (!stream.eat("*")) return false
79 state.tokenize = tokenNestedComment(1)
80 return state.tokenize(stream, state)
81 },
82 token: function(stream, _, style) {
83 if (style == "variable") {
84 // Assume uppercase symbols are classes using variable-2
85 var isUpper = RegExp('^[_$]*[A-Z][a-zA-Z0-9_$]*$','g');
86 if (isUpper.test(stream.current())) {
87 return 'variable-2';
88 }
89 }
75 }
90 }
76 }
91 }
77 });
92 });
78
93
79 function tokenString(quote, stream, state, raw) {
94 function tokenString(quote, stream, state, raw) {
80 var tripleQuoted = false;
95 var tripleQuoted = false;
81 if (stream.eat(quote)) {
96 if (stream.eat(quote)) {
82 if (stream.eat(quote)) tripleQuoted = true;
97 if (stream.eat(quote)) tripleQuoted = true;
83 else return "string"; //empty string
98 else return "string"; //empty string
84 }
99 }
85 function tokenStringHelper(stream, state) {
100 function tokenStringHelper(stream, state) {
86 var escaped = false;
101 var escaped = false;
87 while (!stream.eol()) {
102 while (!stream.eol()) {
88 if (!raw && !escaped && stream.peek() == "$") {
103 if (!raw && !escaped && stream.peek() == "$") {
89 pushInterpolationStack(state);
104 pushInterpolationStack(state);
90 state.tokenize = tokenInterpolation;
105 state.tokenize = tokenInterpolation;
91 return "string";
106 return "string";
92 }
107 }
93 var next = stream.next();
108 var next = stream.next();
94 if (next == quote && !escaped && (!tripleQuoted || stream.match(quote + quote))) {
109 if (next == quote && !escaped && (!tripleQuoted || stream.match(quote + quote))) {
95 state.tokenize = null;
110 state.tokenize = null;
96 break;
111 break;
97 }
112 }
98 escaped = !raw && !escaped && next == "\\";
113 escaped = !raw && !escaped && next == "\\";
99 }
114 }
100 return "string";
115 return "string";
101 }
116 }
102 state.tokenize = tokenStringHelper;
117 state.tokenize = tokenStringHelper;
103 return tokenStringHelper(stream, state);
118 return tokenStringHelper(stream, state);
104 }
119 }
105
120
106 function tokenInterpolation(stream, state) {
121 function tokenInterpolation(stream, state) {
107 stream.eat("$");
122 stream.eat("$");
108 if (stream.eat("{")) {
123 if (stream.eat("{")) {
109 // let clike handle the content of ${...},
124 // let clike handle the content of ${...},
110 // we take over again when "}" appears (see hooks).
125 // we take over again when "}" appears (see hooks).
111 state.tokenize = null;
126 state.tokenize = null;
112 } else {
127 } else {
113 state.tokenize = tokenInterpolationIdentifier;
128 state.tokenize = tokenInterpolationIdentifier;
114 }
129 }
115 return null;
130 return null;
116 }
131 }
117
132
118 function tokenInterpolationIdentifier(stream, state) {
133 function tokenInterpolationIdentifier(stream, state) {
119 stream.eatWhile(/[\w_]/);
134 stream.eatWhile(/[\w_]/);
120 state.tokenize = popInterpolationStack(state);
135 state.tokenize = popInterpolationStack(state);
121 return "variable";
136 return "variable";
122 }
137 }
123
138
139 function tokenNestedComment(depth) {
140 return function (stream, state) {
141 var ch
142 while (ch = stream.next()) {
143 if (ch == "*" && stream.eat("/")) {
144 if (depth == 1) {
145 state.tokenize = null
146 break
147 } else {
148 state.tokenize = tokenNestedComment(depth - 1)
149 return state.tokenize(stream, state)
150 }
151 } else if (ch == "/" && stream.eat("*")) {
152 state.tokenize = tokenNestedComment(depth + 1)
153 return state.tokenize(stream, state)
154 }
155 }
156 return "comment"
157 }
158 }
159
124 CodeMirror.registerHelper("hintWords", "application/dart", keywords.concat(atoms).concat(builtins));
160 CodeMirror.registerHelper("hintWords", "application/dart", keywords.concat(atoms).concat(builtins));
125
161
126 // This is needed to make loading through meta.js work.
162 // This is needed to make loading through meta.js work.
127 CodeMirror.defineMode("dart", function(conf) {
163 CodeMirror.defineMode("dart", function(conf) {
128 return CodeMirror.getMode(conf, "application/dart");
164 return CodeMirror.getMode(conf, "application/dart");
129 }, "clike");
165 }, "clike");
130 });
166 });
@@ -1,47 +1,47 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("diff", function() {
14 CodeMirror.defineMode("diff", function() {
15
15
16 var TOKEN_NAMES = {
16 var TOKEN_NAMES = {
17 '+': 'positive',
17 '+': 'positive',
18 '-': 'negative',
18 '-': 'negative',
19 '@': 'meta'
19 '@': 'meta'
20 };
20 };
21
21
22 return {
22 return {
23 token: function(stream) {
23 token: function(stream) {
24 var tw_pos = stream.string.search(/[\t ]+?$/);
24 var tw_pos = stream.string.search(/[\t ]+?$/);
25
25
26 if (!stream.sol() || tw_pos === 0) {
26 if (!stream.sol() || tw_pos === 0) {
27 stream.skipToEnd();
27 stream.skipToEnd();
28 return ("error " + (
28 return ("error " + (
29 TOKEN_NAMES[stream.string.charAt(0)] || '')).replace(/ $/, '');
29 TOKEN_NAMES[stream.string.charAt(0)] || '')).replace(/ $/, '');
30 }
30 }
31
31
32 var token_name = TOKEN_NAMES[stream.peek()] || stream.skipToEnd();
32 var token_name = TOKEN_NAMES[stream.peek()] || stream.skipToEnd();
33
33
34 if (tw_pos === -1) {
34 if (tw_pos === -1) {
35 stream.skipToEnd();
35 stream.skipToEnd();
36 } else {
36 } else {
37 stream.pos = tw_pos;
37 stream.pos = tw_pos;
38 }
38 }
39
39
40 return token_name;
40 return token_name;
41 }
41 }
42 };
42 };
43 });
43 });
44
44
45 CodeMirror.defineMIME("text/x-diff", "diff");
45 CodeMirror.defineMIME("text/x-diff", "diff");
46
46
47 });
47 });
@@ -1,356 +1,356 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"),
6 mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"),
7 require("../../addon/mode/overlay"));
7 require("../../addon/mode/overlay"));
8 else if (typeof define == "function" && define.amd) // AMD
8 else if (typeof define == "function" && define.amd) // AMD
9 define(["../../lib/codemirror", "../htmlmixed/htmlmixed",
9 define(["../../lib/codemirror", "../htmlmixed/htmlmixed",
10 "../../addon/mode/overlay"], mod);
10 "../../addon/mode/overlay"], mod);
11 else // Plain browser env
11 else // Plain browser env
12 mod(CodeMirror);
12 mod(CodeMirror);
13 })(function(CodeMirror) {
13 })(function(CodeMirror) {
14 "use strict";
14 "use strict";
15
15
16 CodeMirror.defineMode("django:inner", function() {
16 CodeMirror.defineMode("django:inner", function() {
17 var keywords = ["block", "endblock", "for", "endfor", "true", "false", "filter", "endfilter",
17 var keywords = ["block", "endblock", "for", "endfor", "true", "false", "filter", "endfilter",
18 "loop", "none", "self", "super", "if", "elif", "endif", "as", "else", "import",
18 "loop", "none", "self", "super", "if", "elif", "endif", "as", "else", "import",
19 "with", "endwith", "without", "context", "ifequal", "endifequal", "ifnotequal",
19 "with", "endwith", "without", "context", "ifequal", "endifequal", "ifnotequal",
20 "endifnotequal", "extends", "include", "load", "comment", "endcomment",
20 "endifnotequal", "extends", "include", "load", "comment", "endcomment",
21 "empty", "url", "static", "trans", "blocktrans", "endblocktrans", "now",
21 "empty", "url", "static", "trans", "blocktrans", "endblocktrans", "now",
22 "regroup", "lorem", "ifchanged", "endifchanged", "firstof", "debug", "cycle",
22 "regroup", "lorem", "ifchanged", "endifchanged", "firstof", "debug", "cycle",
23 "csrf_token", "autoescape", "endautoescape", "spaceless", "endspaceless",
23 "csrf_token", "autoescape", "endautoescape", "spaceless", "endspaceless",
24 "ssi", "templatetag", "verbatim", "endverbatim", "widthratio"],
24 "ssi", "templatetag", "verbatim", "endverbatim", "widthratio"],
25 filters = ["add", "addslashes", "capfirst", "center", "cut", "date",
25 filters = ["add", "addslashes", "capfirst", "center", "cut", "date",
26 "default", "default_if_none", "dictsort",
26 "default", "default_if_none", "dictsort",
27 "dictsortreversed", "divisibleby", "escape", "escapejs",
27 "dictsortreversed", "divisibleby", "escape", "escapejs",
28 "filesizeformat", "first", "floatformat", "force_escape",
28 "filesizeformat", "first", "floatformat", "force_escape",
29 "get_digit", "iriencode", "join", "last", "length",
29 "get_digit", "iriencode", "join", "last", "length",
30 "length_is", "linebreaks", "linebreaksbr", "linenumbers",
30 "length_is", "linebreaks", "linebreaksbr", "linenumbers",
31 "ljust", "lower", "make_list", "phone2numeric", "pluralize",
31 "ljust", "lower", "make_list", "phone2numeric", "pluralize",
32 "pprint", "random", "removetags", "rjust", "safe",
32 "pprint", "random", "removetags", "rjust", "safe",
33 "safeseq", "slice", "slugify", "stringformat", "striptags",
33 "safeseq", "slice", "slugify", "stringformat", "striptags",
34 "time", "timesince", "timeuntil", "title", "truncatechars",
34 "time", "timesince", "timeuntil", "title", "truncatechars",
35 "truncatechars_html", "truncatewords", "truncatewords_html",
35 "truncatechars_html", "truncatewords", "truncatewords_html",
36 "unordered_list", "upper", "urlencode", "urlize",
36 "unordered_list", "upper", "urlencode", "urlize",
37 "urlizetrunc", "wordcount", "wordwrap", "yesno"],
37 "urlizetrunc", "wordcount", "wordwrap", "yesno"],
38 operators = ["==", "!=", "<", ">", "<=", ">="],
38 operators = ["==", "!=", "<", ">", "<=", ">="],
39 wordOperators = ["in", "not", "or", "and"];
39 wordOperators = ["in", "not", "or", "and"];
40
40
41 keywords = new RegExp("^\\b(" + keywords.join("|") + ")\\b");
41 keywords = new RegExp("^\\b(" + keywords.join("|") + ")\\b");
42 filters = new RegExp("^\\b(" + filters.join("|") + ")\\b");
42 filters = new RegExp("^\\b(" + filters.join("|") + ")\\b");
43 operators = new RegExp("^\\b(" + operators.join("|") + ")\\b");
43 operators = new RegExp("^\\b(" + operators.join("|") + ")\\b");
44 wordOperators = new RegExp("^\\b(" + wordOperators.join("|") + ")\\b");
44 wordOperators = new RegExp("^\\b(" + wordOperators.join("|") + ")\\b");
45
45
46 // We have to return "null" instead of null, in order to avoid string
46 // We have to return "null" instead of null, in order to avoid string
47 // styling as the default, when using Django templates inside HTML
47 // styling as the default, when using Django templates inside HTML
48 // element attributes
48 // element attributes
49 function tokenBase (stream, state) {
49 function tokenBase (stream, state) {
50 // Attempt to identify a variable, template or comment tag respectively
50 // Attempt to identify a variable, template or comment tag respectively
51 if (stream.match("{{")) {
51 if (stream.match("{{")) {
52 state.tokenize = inVariable;
52 state.tokenize = inVariable;
53 return "tag";
53 return "tag";
54 } else if (stream.match("{%")) {
54 } else if (stream.match("{%")) {
55 state.tokenize = inTag;
55 state.tokenize = inTag;
56 return "tag";
56 return "tag";
57 } else if (stream.match("{#")) {
57 } else if (stream.match("{#")) {
58 state.tokenize = inComment;
58 state.tokenize = inComment;
59 return "comment";
59 return "comment";
60 }
60 }
61
61
62 // Ignore completely any stream series that do not match the
62 // Ignore completely any stream series that do not match the
63 // Django template opening tags.
63 // Django template opening tags.
64 while (stream.next() != null && !stream.match(/\{[{%#]/, false)) {}
64 while (stream.next() != null && !stream.match(/\{[{%#]/, false)) {}
65 return null;
65 return null;
66 }
66 }
67
67
68 // A string can be included in either single or double quotes (this is
68 // A string can be included in either single or double quotes (this is
69 // the delimeter). Mark everything as a string until the start delimeter
69 // the delimiter). Mark everything as a string until the start delimiter
70 // occurs again.
70 // occurs again.
71 function inString (delimeter, previousTokenizer) {
71 function inString (delimiter, previousTokenizer) {
72 return function (stream, state) {
72 return function (stream, state) {
73 if (!state.escapeNext && stream.eat(delimeter)) {
73 if (!state.escapeNext && stream.eat(delimiter)) {
74 state.tokenize = previousTokenizer;
74 state.tokenize = previousTokenizer;
75 } else {
75 } else {
76 if (state.escapeNext) {
76 if (state.escapeNext) {
77 state.escapeNext = false;
77 state.escapeNext = false;
78 }
78 }
79
79
80 var ch = stream.next();
80 var ch = stream.next();
81
81
82 // Take into account the backslash for escaping characters, such as
82 // Take into account the backslash for escaping characters, such as
83 // the string delimeter.
83 // the string delimiter.
84 if (ch == "\\") {
84 if (ch == "\\") {
85 state.escapeNext = true;
85 state.escapeNext = true;
86 }
86 }
87 }
87 }
88
88
89 return "string";
89 return "string";
90 };
90 };
91 }
91 }
92
92
93 // Apply Django template variable syntax highlighting
93 // Apply Django template variable syntax highlighting
94 function inVariable (stream, state) {
94 function inVariable (stream, state) {
95 // Attempt to match a dot that precedes a property
95 // Attempt to match a dot that precedes a property
96 if (state.waitDot) {
96 if (state.waitDot) {
97 state.waitDot = false;
97 state.waitDot = false;
98
98
99 if (stream.peek() != ".") {
99 if (stream.peek() != ".") {
100 return "null";
100 return "null";
101 }
101 }
102
102
103 // Dot folowed by a non-word character should be considered an error.
103 // Dot followed by a non-word character should be considered an error.
104 if (stream.match(/\.\W+/)) {
104 if (stream.match(/\.\W+/)) {
105 return "error";
105 return "error";
106 } else if (stream.eat(".")) {
106 } else if (stream.eat(".")) {
107 state.waitProperty = true;
107 state.waitProperty = true;
108 return "null";
108 return "null";
109 } else {
109 } else {
110 throw Error ("Unexpected error while waiting for property.");
110 throw Error ("Unexpected error while waiting for property.");
111 }
111 }
112 }
112 }
113
113
114 // Attempt to match a pipe that precedes a filter
114 // Attempt to match a pipe that precedes a filter
115 if (state.waitPipe) {
115 if (state.waitPipe) {
116 state.waitPipe = false;
116 state.waitPipe = false;
117
117
118 if (stream.peek() != "|") {
118 if (stream.peek() != "|") {
119 return "null";
119 return "null";
120 }
120 }
121
121
122 // Pipe folowed by a non-word character should be considered an error.
122 // Pipe followed by a non-word character should be considered an error.
123 if (stream.match(/\.\W+/)) {
123 if (stream.match(/\.\W+/)) {
124 return "error";
124 return "error";
125 } else if (stream.eat("|")) {
125 } else if (stream.eat("|")) {
126 state.waitFilter = true;
126 state.waitFilter = true;
127 return "null";
127 return "null";
128 } else {
128 } else {
129 throw Error ("Unexpected error while waiting for filter.");
129 throw Error ("Unexpected error while waiting for filter.");
130 }
130 }
131 }
131 }
132
132
133 // Highlight properties
133 // Highlight properties
134 if (state.waitProperty) {
134 if (state.waitProperty) {
135 state.waitProperty = false;
135 state.waitProperty = false;
136 if (stream.match(/\b(\w+)\b/)) {
136 if (stream.match(/\b(\w+)\b/)) {
137 state.waitDot = true; // A property can be followed by another property
137 state.waitDot = true; // A property can be followed by another property
138 state.waitPipe = true; // A property can be followed by a filter
138 state.waitPipe = true; // A property can be followed by a filter
139 return "property";
139 return "property";
140 }
140 }
141 }
141 }
142
142
143 // Highlight filters
143 // Highlight filters
144 if (state.waitFilter) {
144 if (state.waitFilter) {
145 state.waitFilter = false;
145 state.waitFilter = false;
146 if (stream.match(filters)) {
146 if (stream.match(filters)) {
147 return "variable-2";
147 return "variable-2";
148 }
148 }
149 }
149 }
150
150
151 // Ignore all white spaces
151 // Ignore all white spaces
152 if (stream.eatSpace()) {
152 if (stream.eatSpace()) {
153 state.waitProperty = false;
153 state.waitProperty = false;
154 return "null";
154 return "null";
155 }
155 }
156
156
157 // Identify numbers
157 // Identify numbers
158 if (stream.match(/\b\d+(\.\d+)?\b/)) {
158 if (stream.match(/\b\d+(\.\d+)?\b/)) {
159 return "number";
159 return "number";
160 }
160 }
161
161
162 // Identify strings
162 // Identify strings
163 if (stream.match("'")) {
163 if (stream.match("'")) {
164 state.tokenize = inString("'", state.tokenize);
164 state.tokenize = inString("'", state.tokenize);
165 return "string";
165 return "string";
166 } else if (stream.match('"')) {
166 } else if (stream.match('"')) {
167 state.tokenize = inString('"', state.tokenize);
167 state.tokenize = inString('"', state.tokenize);
168 return "string";
168 return "string";
169 }
169 }
170
170
171 // Attempt to find the variable
171 // Attempt to find the variable
172 if (stream.match(/\b(\w+)\b/) && !state.foundVariable) {
172 if (stream.match(/\b(\w+)\b/) && !state.foundVariable) {
173 state.waitDot = true;
173 state.waitDot = true;
174 state.waitPipe = true; // A property can be followed by a filter
174 state.waitPipe = true; // A property can be followed by a filter
175 return "variable";
175 return "variable";
176 }
176 }
177
177
178 // If found closing tag reset
178 // If found closing tag reset
179 if (stream.match("}}")) {
179 if (stream.match("}}")) {
180 state.waitProperty = null;
180 state.waitProperty = null;
181 state.waitFilter = null;
181 state.waitFilter = null;
182 state.waitDot = null;
182 state.waitDot = null;
183 state.waitPipe = null;
183 state.waitPipe = null;
184 state.tokenize = tokenBase;
184 state.tokenize = tokenBase;
185 return "tag";
185 return "tag";
186 }
186 }
187
187
188 // If nothing was found, advance to the next character
188 // If nothing was found, advance to the next character
189 stream.next();
189 stream.next();
190 return "null";
190 return "null";
191 }
191 }
192
192
193 function inTag (stream, state) {
193 function inTag (stream, state) {
194 // Attempt to match a dot that precedes a property
194 // Attempt to match a dot that precedes a property
195 if (state.waitDot) {
195 if (state.waitDot) {
196 state.waitDot = false;
196 state.waitDot = false;
197
197
198 if (stream.peek() != ".") {
198 if (stream.peek() != ".") {
199 return "null";
199 return "null";
200 }
200 }
201
201
202 // Dot folowed by a non-word character should be considered an error.
202 // Dot followed by a non-word character should be considered an error.
203 if (stream.match(/\.\W+/)) {
203 if (stream.match(/\.\W+/)) {
204 return "error";
204 return "error";
205 } else if (stream.eat(".")) {
205 } else if (stream.eat(".")) {
206 state.waitProperty = true;
206 state.waitProperty = true;
207 return "null";
207 return "null";
208 } else {
208 } else {
209 throw Error ("Unexpected error while waiting for property.");
209 throw Error ("Unexpected error while waiting for property.");
210 }
210 }
211 }
211 }
212
212
213 // Attempt to match a pipe that precedes a filter
213 // Attempt to match a pipe that precedes a filter
214 if (state.waitPipe) {
214 if (state.waitPipe) {
215 state.waitPipe = false;
215 state.waitPipe = false;
216
216
217 if (stream.peek() != "|") {
217 if (stream.peek() != "|") {
218 return "null";
218 return "null";
219 }
219 }
220
220
221 // Pipe folowed by a non-word character should be considered an error.
221 // Pipe followed by a non-word character should be considered an error.
222 if (stream.match(/\.\W+/)) {
222 if (stream.match(/\.\W+/)) {
223 return "error";
223 return "error";
224 } else if (stream.eat("|")) {
224 } else if (stream.eat("|")) {
225 state.waitFilter = true;
225 state.waitFilter = true;
226 return "null";
226 return "null";
227 } else {
227 } else {
228 throw Error ("Unexpected error while waiting for filter.");
228 throw Error ("Unexpected error while waiting for filter.");
229 }
229 }
230 }
230 }
231
231
232 // Highlight properties
232 // Highlight properties
233 if (state.waitProperty) {
233 if (state.waitProperty) {
234 state.waitProperty = false;
234 state.waitProperty = false;
235 if (stream.match(/\b(\w+)\b/)) {
235 if (stream.match(/\b(\w+)\b/)) {
236 state.waitDot = true; // A property can be followed by another property
236 state.waitDot = true; // A property can be followed by another property
237 state.waitPipe = true; // A property can be followed by a filter
237 state.waitPipe = true; // A property can be followed by a filter
238 return "property";
238 return "property";
239 }
239 }
240 }
240 }
241
241
242 // Highlight filters
242 // Highlight filters
243 if (state.waitFilter) {
243 if (state.waitFilter) {
244 state.waitFilter = false;
244 state.waitFilter = false;
245 if (stream.match(filters)) {
245 if (stream.match(filters)) {
246 return "variable-2";
246 return "variable-2";
247 }
247 }
248 }
248 }
249
249
250 // Ignore all white spaces
250 // Ignore all white spaces
251 if (stream.eatSpace()) {
251 if (stream.eatSpace()) {
252 state.waitProperty = false;
252 state.waitProperty = false;
253 return "null";
253 return "null";
254 }
254 }
255
255
256 // Identify numbers
256 // Identify numbers
257 if (stream.match(/\b\d+(\.\d+)?\b/)) {
257 if (stream.match(/\b\d+(\.\d+)?\b/)) {
258 return "number";
258 return "number";
259 }
259 }
260
260
261 // Identify strings
261 // Identify strings
262 if (stream.match("'")) {
262 if (stream.match("'")) {
263 state.tokenize = inString("'", state.tokenize);
263 state.tokenize = inString("'", state.tokenize);
264 return "string";
264 return "string";
265 } else if (stream.match('"')) {
265 } else if (stream.match('"')) {
266 state.tokenize = inString('"', state.tokenize);
266 state.tokenize = inString('"', state.tokenize);
267 return "string";
267 return "string";
268 }
268 }
269
269
270 // Attempt to match an operator
270 // Attempt to match an operator
271 if (stream.match(operators)) {
271 if (stream.match(operators)) {
272 return "operator";
272 return "operator";
273 }
273 }
274
274
275 // Attempt to match a word operator
275 // Attempt to match a word operator
276 if (stream.match(wordOperators)) {
276 if (stream.match(wordOperators)) {
277 return "keyword";
277 return "keyword";
278 }
278 }
279
279
280 // Attempt to match a keyword
280 // Attempt to match a keyword
281 var keywordMatch = stream.match(keywords);
281 var keywordMatch = stream.match(keywords);
282 if (keywordMatch) {
282 if (keywordMatch) {
283 if (keywordMatch[0] == "comment") {
283 if (keywordMatch[0] == "comment") {
284 state.blockCommentTag = true;
284 state.blockCommentTag = true;
285 }
285 }
286 return "keyword";
286 return "keyword";
287 }
287 }
288
288
289 // Attempt to match a variable
289 // Attempt to match a variable
290 if (stream.match(/\b(\w+)\b/)) {
290 if (stream.match(/\b(\w+)\b/)) {
291 state.waitDot = true;
291 state.waitDot = true;
292 state.waitPipe = true; // A property can be followed by a filter
292 state.waitPipe = true; // A property can be followed by a filter
293 return "variable";
293 return "variable";
294 }
294 }
295
295
296 // If found closing tag reset
296 // If found closing tag reset
297 if (stream.match("%}")) {
297 if (stream.match("%}")) {
298 state.waitProperty = null;
298 state.waitProperty = null;
299 state.waitFilter = null;
299 state.waitFilter = null;
300 state.waitDot = null;
300 state.waitDot = null;
301 state.waitPipe = null;
301 state.waitPipe = null;
302 // If the tag that closes is a block comment tag, we want to mark the
302 // If the tag that closes is a block comment tag, we want to mark the
303 // following code as comment, until the tag closes.
303 // following code as comment, until the tag closes.
304 if (state.blockCommentTag) {
304 if (state.blockCommentTag) {
305 state.blockCommentTag = false; // Release the "lock"
305 state.blockCommentTag = false; // Release the "lock"
306 state.tokenize = inBlockComment;
306 state.tokenize = inBlockComment;
307 } else {
307 } else {
308 state.tokenize = tokenBase;
308 state.tokenize = tokenBase;
309 }
309 }
310 return "tag";
310 return "tag";
311 }
311 }
312
312
313 // If nothing was found, advance to the next character
313 // If nothing was found, advance to the next character
314 stream.next();
314 stream.next();
315 return "null";
315 return "null";
316 }
316 }
317
317
318 // Mark everything as comment inside the tag and the tag itself.
318 // Mark everything as comment inside the tag and the tag itself.
319 function inComment (stream, state) {
319 function inComment (stream, state) {
320 if (stream.match(/^.*?#\}/)) state.tokenize = tokenBase
320 if (stream.match(/^.*?#\}/)) state.tokenize = tokenBase
321 else stream.skipToEnd()
321 else stream.skipToEnd()
322 return "comment";
322 return "comment";
323 }
323 }
324
324
325 // Mark everything as a comment until the `blockcomment` tag closes.
325 // Mark everything as a comment until the `blockcomment` tag closes.
326 function inBlockComment (stream, state) {
326 function inBlockComment (stream, state) {
327 if (stream.match(/\{%\s*endcomment\s*%\}/, false)) {
327 if (stream.match(/\{%\s*endcomment\s*%\}/, false)) {
328 state.tokenize = inTag;
328 state.tokenize = inTag;
329 stream.match("{%");
329 stream.match("{%");
330 return "tag";
330 return "tag";
331 } else {
331 } else {
332 stream.next();
332 stream.next();
333 return "comment";
333 return "comment";
334 }
334 }
335 }
335 }
336
336
337 return {
337 return {
338 startState: function () {
338 startState: function () {
339 return {tokenize: tokenBase};
339 return {tokenize: tokenBase};
340 },
340 },
341 token: function (stream, state) {
341 token: function (stream, state) {
342 return state.tokenize(stream, state);
342 return state.tokenize(stream, state);
343 },
343 },
344 blockCommentStart: "{% comment %}",
344 blockCommentStart: "{% comment %}",
345 blockCommentEnd: "{% endcomment %}"
345 blockCommentEnd: "{% endcomment %}"
346 };
346 };
347 });
347 });
348
348
349 CodeMirror.defineMode("django", function(config) {
349 CodeMirror.defineMode("django", function(config) {
350 var htmlBase = CodeMirror.getMode(config, "text/html");
350 var htmlBase = CodeMirror.getMode(config, "text/html");
351 var djangoInner = CodeMirror.getMode(config, "django:inner");
351 var djangoInner = CodeMirror.getMode(config, "django:inner");
352 return CodeMirror.overlayMode(htmlBase, djangoInner);
352 return CodeMirror.overlayMode(htmlBase, djangoInner);
353 });
353 });
354
354
355 CodeMirror.defineMIME("text/x-django", "django");
355 CodeMirror.defineMIME("text/x-django", "django");
356 });
356 });
@@ -1,79 +1,211 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"), require("../../addon/mode/simple"));
6 mod(require("../../lib/codemirror"), require("../../addon/mode/simple"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
8 define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 var from = "from";
15 var fromRegex = new RegExp("^(\\s*)\\b(" + from + ")\\b", "i");
16
17 var shells = ["run", "cmd", "entrypoint", "shell"];
18 var shellsAsArrayRegex = new RegExp("^(\\s*)(" + shells.join('|') + ")(\\s+\\[)", "i");
19
20 var expose = "expose";
21 var exposeRegex = new RegExp("^(\\s*)(" + expose + ")(\\s+)", "i");
22
23 var others = [
24 "arg", "from", "maintainer", "label", "env",
25 "add", "copy", "volume", "user",
26 "workdir", "onbuild", "stopsignal", "healthcheck", "shell"
27 ];
28
14 // Collect all Dockerfile directives
29 // Collect all Dockerfile directives
15 var instructions = ["from", "maintainer", "run", "cmd", "expose", "env",
30 var instructions = [from, expose].concat(shells).concat(others),
16 "add", "copy", "entrypoint", "volume", "user",
17 "workdir", "onbuild"],
18 instructionRegex = "(" + instructions.join('|') + ")",
31 instructionRegex = "(" + instructions.join('|') + ")",
19 instructionOnlyLine = new RegExp(instructionRegex + "\\s*$", "i"),
32 instructionOnlyLine = new RegExp("^(\\s*)" + instructionRegex + "(\\s*)(#.*)?$", "i"),
20 instructionWithArguments = new RegExp(instructionRegex + "(\\s+)", "i");
33 instructionWithArguments = new RegExp("^(\\s*)" + instructionRegex + "(\\s+)", "i");
21
34
22 CodeMirror.defineSimpleMode("dockerfile", {
35 CodeMirror.defineSimpleMode("dockerfile", {
23 start: [
36 start: [
24 // Block comment: This is a line starting with a comment
37 // Block comment: This is a line starting with a comment
25 {
38 {
26 regex: /#.*$/,
39 regex: /^\s*#.*$/,
40 sol: true,
27 token: "comment"
41 token: "comment"
28 },
42 },
43 {
44 regex: fromRegex,
45 token: [null, "keyword"],
46 sol: true,
47 next: "from"
48 },
29 // Highlight an instruction without any arguments (for convenience)
49 // Highlight an instruction without any arguments (for convenience)
30 {
50 {
31 regex: instructionOnlyLine,
51 regex: instructionOnlyLine,
32 token: "variable-2"
52 token: [null, "keyword", null, "error"],
53 sol: true
54 },
55 {
56 regex: shellsAsArrayRegex,
57 token: [null, "keyword", null],
58 sol: true,
59 next: "array"
60 },
61 {
62 regex: exposeRegex,
63 token: [null, "keyword", null],
64 sol: true,
65 next: "expose"
33 },
66 },
34 // Highlight an instruction followed by arguments
67 // Highlight an instruction followed by arguments
35 {
68 {
36 regex: instructionWithArguments,
69 regex: instructionWithArguments,
37 token: ["variable-2", null],
70 token: [null, "keyword", null],
71 sol: true,
38 next: "arguments"
72 next: "arguments"
39 },
73 },
40 {
74 {
41 regex: /./,
75 regex: /./,
42 token: null
76 token: null
43 }
77 }
44 ],
78 ],
45 arguments: [
79 from: [
80 {
81 regex: /\s*$/,
82 token: null,
83 next: "start"
84 },
46 {
85 {
47 // Line comment without instruction arguments is an error
86 // Line comment without instruction arguments is an error
48 regex: /#.*$/,
87 regex: /(\s*)(#.*)$/,
49 token: "error",
88 token: [null, "error"],
50 next: "start"
89 next: "start"
51 },
90 },
52 {
91 {
53 regex: /[^#]+\\$/,
92 regex: /(\s*\S+\s+)(as)/i,
54 token: null
93 token: [null, "keyword"],
94 next: "start"
95 },
96 // Fail safe return to start
97 {
98 token: null,
99 next: "start"
100 }
101 ],
102 single: [
103 {
104 regex: /(?:[^\\']|\\.)/,
105 token: "string"
55 },
106 },
56 {
107 {
57 // Match everything except for the inline comment
108 regex: /'/,
58 regex: /[^#]+/,
109 token: "string",
110 pop: true
111 }
112 ],
113 double: [
114 {
115 regex: /(?:[^\\"]|\\.)/,
116 token: "string"
117 },
118 {
119 regex: /"/,
120 token: "string",
121 pop: true
122 }
123 ],
124 array: [
125 {
126 regex: /\]/,
59 token: null,
127 token: null,
60 next: "start"
128 next: "start"
61 },
129 },
62 {
130 {
63 regex: /$/,
131 regex: /"(?:[^\\"]|\\.)*"?/,
132 token: "string"
133 }
134 ],
135 expose: [
136 {
137 regex: /\d+$/,
138 token: "number",
139 next: "start"
140 },
141 {
142 regex: /[^\d]+$/,
143 token: null,
144 next: "start"
145 },
146 {
147 regex: /\d+/,
148 token: "number"
149 },
150 {
151 regex: /[^\d]+/,
152 token: null
153 },
154 // Fail safe return to start
155 {
64 token: null,
156 token: null,
65 next: "start"
157 next: "start"
158 }
159 ],
160 arguments: [
161 {
162 regex: /^\s*#.*$/,
163 sol: true,
164 token: "comment"
165 },
166 {
167 regex: /"(?:[^\\"]|\\.)*"?$/,
168 token: "string",
169 next: "start"
170 },
171 {
172 regex: /"/,
173 token: "string",
174 push: "double"
175 },
176 {
177 regex: /'(?:[^\\']|\\.)*'?$/,
178 token: "string",
179 next: "start"
180 },
181 {
182 regex: /'/,
183 token: "string",
184 push: "single"
185 },
186 {
187 regex: /[^#"']+[\\`]$/,
188 token: null
189 },
190 {
191 regex: /[^#"']+$/,
192 token: null,
193 next: "start"
194 },
195 {
196 regex: /[^#"']+/,
197 token: null
66 },
198 },
67 // Fail safe return to start
199 // Fail safe return to start
68 {
200 {
69 token: null,
201 token: null,
70 next: "start"
202 next: "start"
71 }
203 }
72 ],
204 ],
73 meta: {
205 meta: {
74 lineComment: "#"
206 lineComment: "#"
75 }
207 }
76 });
208 });
77
209
78 CodeMirror.defineMIME("text/x-dockerfile", "dockerfile");
210 CodeMirror.defineMIME("text/x-dockerfile", "dockerfile");
79 });
211 });
@@ -1,142 +1,142 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 /*
4 /*
5 DTD mode
5 DTD mode
6 Ported to CodeMirror by Peter Kroon <plakroon@gmail.com>
6 Ported to CodeMirror by Peter Kroon <plakroon@gmail.com>
7 Report bugs/issues here: https://github.com/codemirror/CodeMirror/issues
7 Report bugs/issues here: https://github.com/codemirror/CodeMirror/issues
8 GitHub: @peterkroon
8 GitHub: @peterkroon
9 */
9 */
10
10
11 (function(mod) {
11 (function(mod) {
12 if (typeof exports == "object" && typeof module == "object") // CommonJS
12 if (typeof exports == "object" && typeof module == "object") // CommonJS
13 mod(require("../../lib/codemirror"));
13 mod(require("../../lib/codemirror"));
14 else if (typeof define == "function" && define.amd) // AMD
14 else if (typeof define == "function" && define.amd) // AMD
15 define(["../../lib/codemirror"], mod);
15 define(["../../lib/codemirror"], mod);
16 else // Plain browser env
16 else // Plain browser env
17 mod(CodeMirror);
17 mod(CodeMirror);
18 })(function(CodeMirror) {
18 })(function(CodeMirror) {
19 "use strict";
19 "use strict";
20
20
21 CodeMirror.defineMode("dtd", function(config) {
21 CodeMirror.defineMode("dtd", function(config) {
22 var indentUnit = config.indentUnit, type;
22 var indentUnit = config.indentUnit, type;
23 function ret(style, tp) {type = tp; return style;}
23 function ret(style, tp) {type = tp; return style;}
24
24
25 function tokenBase(stream, state) {
25 function tokenBase(stream, state) {
26 var ch = stream.next();
26 var ch = stream.next();
27
27
28 if (ch == "<" && stream.eat("!") ) {
28 if (ch == "<" && stream.eat("!") ) {
29 if (stream.eatWhile(/[\-]/)) {
29 if (stream.eatWhile(/[\-]/)) {
30 state.tokenize = tokenSGMLComment;
30 state.tokenize = tokenSGMLComment;
31 return tokenSGMLComment(stream, state);
31 return tokenSGMLComment(stream, state);
32 } else if (stream.eatWhile(/[\w]/)) return ret("keyword", "doindent");
32 } else if (stream.eatWhile(/[\w]/)) return ret("keyword", "doindent");
33 } else if (ch == "<" && stream.eat("?")) { //xml declaration
33 } else if (ch == "<" && stream.eat("?")) { //xml declaration
34 state.tokenize = inBlock("meta", "?>");
34 state.tokenize = inBlock("meta", "?>");
35 return ret("meta", ch);
35 return ret("meta", ch);
36 } else if (ch == "#" && stream.eatWhile(/[\w]/)) return ret("atom", "tag");
36 } else if (ch == "#" && stream.eatWhile(/[\w]/)) return ret("atom", "tag");
37 else if (ch == "|") return ret("keyword", "seperator");
37 else if (ch == "|") return ret("keyword", "seperator");
38 else if (ch.match(/[\(\)\[\]\-\.,\+\?>]/)) return ret(null, ch);//if(ch === ">") return ret(null, "endtag"); else
38 else if (ch.match(/[\(\)\[\]\-\.,\+\?>]/)) return ret(null, ch);//if(ch === ">") return ret(null, "endtag"); else
39 else if (ch.match(/[\[\]]/)) return ret("rule", ch);
39 else if (ch.match(/[\[\]]/)) return ret("rule", ch);
40 else if (ch == "\"" || ch == "'") {
40 else if (ch == "\"" || ch == "'") {
41 state.tokenize = tokenString(ch);
41 state.tokenize = tokenString(ch);
42 return state.tokenize(stream, state);
42 return state.tokenize(stream, state);
43 } else if (stream.eatWhile(/[a-zA-Z\?\+\d]/)) {
43 } else if (stream.eatWhile(/[a-zA-Z\?\+\d]/)) {
44 var sc = stream.current();
44 var sc = stream.current();
45 if( sc.substr(sc.length-1,sc.length).match(/\?|\+/) !== null )stream.backUp(1);
45 if( sc.substr(sc.length-1,sc.length).match(/\?|\+/) !== null )stream.backUp(1);
46 return ret("tag", "tag");
46 return ret("tag", "tag");
47 } else if (ch == "%" || ch == "*" ) return ret("number", "number");
47 } else if (ch == "%" || ch == "*" ) return ret("number", "number");
48 else {
48 else {
49 stream.eatWhile(/[\w\\\-_%.{,]/);
49 stream.eatWhile(/[\w\\\-_%.{,]/);
50 return ret(null, null);
50 return ret(null, null);
51 }
51 }
52 }
52 }
53
53
54 function tokenSGMLComment(stream, state) {
54 function tokenSGMLComment(stream, state) {
55 var dashes = 0, ch;
55 var dashes = 0, ch;
56 while ((ch = stream.next()) != null) {
56 while ((ch = stream.next()) != null) {
57 if (dashes >= 2 && ch == ">") {
57 if (dashes >= 2 && ch == ">") {
58 state.tokenize = tokenBase;
58 state.tokenize = tokenBase;
59 break;
59 break;
60 }
60 }
61 dashes = (ch == "-") ? dashes + 1 : 0;
61 dashes = (ch == "-") ? dashes + 1 : 0;
62 }
62 }
63 return ret("comment", "comment");
63 return ret("comment", "comment");
64 }
64 }
65
65
66 function tokenString(quote) {
66 function tokenString(quote) {
67 return function(stream, state) {
67 return function(stream, state) {
68 var escaped = false, ch;
68 var escaped = false, ch;
69 while ((ch = stream.next()) != null) {
69 while ((ch = stream.next()) != null) {
70 if (ch == quote && !escaped) {
70 if (ch == quote && !escaped) {
71 state.tokenize = tokenBase;
71 state.tokenize = tokenBase;
72 break;
72 break;
73 }
73 }
74 escaped = !escaped && ch == "\\";
74 escaped = !escaped && ch == "\\";
75 }
75 }
76 return ret("string", "tag");
76 return ret("string", "tag");
77 };
77 };
78 }
78 }
79
79
80 function inBlock(style, terminator) {
80 function inBlock(style, terminator) {
81 return function(stream, state) {
81 return function(stream, state) {
82 while (!stream.eol()) {
82 while (!stream.eol()) {
83 if (stream.match(terminator)) {
83 if (stream.match(terminator)) {
84 state.tokenize = tokenBase;
84 state.tokenize = tokenBase;
85 break;
85 break;
86 }
86 }
87 stream.next();
87 stream.next();
88 }
88 }
89 return style;
89 return style;
90 };
90 };
91 }
91 }
92
92
93 return {
93 return {
94 startState: function(base) {
94 startState: function(base) {
95 return {tokenize: tokenBase,
95 return {tokenize: tokenBase,
96 baseIndent: base || 0,
96 baseIndent: base || 0,
97 stack: []};
97 stack: []};
98 },
98 },
99
99
100 token: function(stream, state) {
100 token: function(stream, state) {
101 if (stream.eatSpace()) return null;
101 if (stream.eatSpace()) return null;
102 var style = state.tokenize(stream, state);
102 var style = state.tokenize(stream, state);
103
103
104 var context = state.stack[state.stack.length-1];
104 var context = state.stack[state.stack.length-1];
105 if (stream.current() == "[" || type === "doindent" || type == "[") state.stack.push("rule");
105 if (stream.current() == "[" || type === "doindent" || type == "[") state.stack.push("rule");
106 else if (type === "endtag") state.stack[state.stack.length-1] = "endtag";
106 else if (type === "endtag") state.stack[state.stack.length-1] = "endtag";
107 else if (stream.current() == "]" || type == "]" || (type == ">" && context == "rule")) state.stack.pop();
107 else if (stream.current() == "]" || type == "]" || (type == ">" && context == "rule")) state.stack.pop();
108 else if (type == "[") state.stack.push("[");
108 else if (type == "[") state.stack.push("[");
109 return style;
109 return style;
110 },
110 },
111
111
112 indent: function(state, textAfter) {
112 indent: function(state, textAfter) {
113 var n = state.stack.length;
113 var n = state.stack.length;
114
114
115 if( textAfter.match(/\]\s+|\]/) )n=n-1;
115 if( textAfter.match(/\]\s+|\]/) )n=n-1;
116 else if(textAfter.substr(textAfter.length-1, textAfter.length) === ">"){
116 else if(textAfter.substr(textAfter.length-1, textAfter.length) === ">"){
117 if(textAfter.substr(0,1) === "<")n;
117 if(textAfter.substr(0,1) === "<") {}
118 else if( type == "doindent" && textAfter.length > 1 )n;
118 else if( type == "doindent" && textAfter.length > 1 ) {}
119 else if( type == "doindent")n--;
119 else if( type == "doindent")n--;
120 else if( type == ">" && textAfter.length > 1)n;
120 else if( type == ">" && textAfter.length > 1) {}
121 else if( type == "tag" && textAfter !== ">")n;
121 else if( type == "tag" && textAfter !== ">") {}
122 else if( type == "tag" && state.stack[state.stack.length-1] == "rule")n--;
122 else if( type == "tag" && state.stack[state.stack.length-1] == "rule")n--;
123 else if( type == "tag")n++;
123 else if( type == "tag")n++;
124 else if( textAfter === ">" && state.stack[state.stack.length-1] == "rule" && type === ">")n--;
124 else if( textAfter === ">" && state.stack[state.stack.length-1] == "rule" && type === ">")n--;
125 else if( textAfter === ">" && state.stack[state.stack.length-1] == "rule")n;
125 else if( textAfter === ">" && state.stack[state.stack.length-1] == "rule") {}
126 else if( textAfter.substr(0,1) !== "<" && textAfter.substr(0,1) === ">" )n=n-1;
126 else if( textAfter.substr(0,1) !== "<" && textAfter.substr(0,1) === ">" )n=n-1;
127 else if( textAfter === ">")n;
127 else if( textAfter === ">") {}
128 else n=n-1;
128 else n=n-1;
129 //over rule them all
129 //over rule them all
130 if(type == null || type == "]")n--;
130 if(type == null || type == "]")n--;
131 }
131 }
132
132
133 return state.baseIndent + n * indentUnit;
133 return state.baseIndent + n * indentUnit;
134 },
134 },
135
135
136 electricChars: "]>"
136 electricChars: "]>"
137 };
137 };
138 });
138 });
139
139
140 CodeMirror.defineMIME("application/xml-dtd", "dtd");
140 CodeMirror.defineMIME("application/xml-dtd", "dtd");
141
141
142 });
142 });
@@ -1,291 +1,352 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 function forEach(arr, f) {
15 for (var i = 0; i < arr.length; i++) f(arr[i], i)
16 }
17 function some(arr, f) {
18 for (var i = 0; i < arr.length; i++) if (f(arr[i], i)) return true
19 return false
20 }
21
14 CodeMirror.defineMode("dylan", function(_config) {
22 CodeMirror.defineMode("dylan", function(_config) {
15 // Words
23 // Words
16 var words = {
24 var words = {
17 // Words that introduce unnamed definitions like "define interface"
25 // Words that introduce unnamed definitions like "define interface"
18 unnamedDefinition: ["interface"],
26 unnamedDefinition: ["interface"],
19
27
20 // Words that introduce simple named definitions like "define library"
28 // Words that introduce simple named definitions like "define library"
21 namedDefinition: ["module", "library", "macro",
29 namedDefinition: ["module", "library", "macro",
22 "C-struct", "C-union",
30 "C-struct", "C-union",
23 "C-function", "C-callable-wrapper"
31 "C-function", "C-callable-wrapper"
24 ],
32 ],
25
33
26 // Words that introduce type definitions like "define class".
34 // Words that introduce type definitions like "define class".
27 // These are also parameterized like "define method" and are
35 // These are also parameterized like "define method" and are
28 // appended to otherParameterizedDefinitionWords
36 // appended to otherParameterizedDefinitionWords
29 typeParameterizedDefinition: ["class", "C-subtype", "C-mapped-subtype"],
37 typeParameterizedDefinition: ["class", "C-subtype", "C-mapped-subtype"],
30
38
31 // Words that introduce trickier definitions like "define method".
39 // Words that introduce trickier definitions like "define method".
32 // These require special definitions to be added to startExpressions
40 // These require special definitions to be added to startExpressions
33 otherParameterizedDefinition: ["method", "function",
41 otherParameterizedDefinition: ["method", "function",
34 "C-variable", "C-address"
42 "C-variable", "C-address"
35 ],
43 ],
36
44
37 // Words that introduce module constant definitions.
45 // Words that introduce module constant definitions.
38 // These must also be simple definitions and are
46 // These must also be simple definitions and are
39 // appended to otherSimpleDefinitionWords
47 // appended to otherSimpleDefinitionWords
40 constantSimpleDefinition: ["constant"],
48 constantSimpleDefinition: ["constant"],
41
49
42 // Words that introduce module variable definitions.
50 // Words that introduce module variable definitions.
43 // These must also be simple definitions and are
51 // These must also be simple definitions and are
44 // appended to otherSimpleDefinitionWords
52 // appended to otherSimpleDefinitionWords
45 variableSimpleDefinition: ["variable"],
53 variableSimpleDefinition: ["variable"],
46
54
47 // Other words that introduce simple definitions
55 // Other words that introduce simple definitions
48 // (without implicit bodies).
56 // (without implicit bodies).
49 otherSimpleDefinition: ["generic", "domain",
57 otherSimpleDefinition: ["generic", "domain",
50 "C-pointer-type",
58 "C-pointer-type",
51 "table"
59 "table"
52 ],
60 ],
53
61
54 // Words that begin statements with implicit bodies.
62 // Words that begin statements with implicit bodies.
55 statement: ["if", "block", "begin", "method", "case",
63 statement: ["if", "block", "begin", "method", "case",
56 "for", "select", "when", "unless", "until",
64 "for", "select", "when", "unless", "until",
57 "while", "iterate", "profiling", "dynamic-bind"
65 "while", "iterate", "profiling", "dynamic-bind"
58 ],
66 ],
59
67
60 // Patterns that act as separators in compound statements.
68 // Patterns that act as separators in compound statements.
61 // This may include any general pattern that must be indented
69 // This may include any general pattern that must be indented
62 // specially.
70 // specially.
63 separator: ["finally", "exception", "cleanup", "else",
71 separator: ["finally", "exception", "cleanup", "else",
64 "elseif", "afterwards"
72 "elseif", "afterwards"
65 ],
73 ],
66
74
67 // Keywords that do not require special indentation handling,
75 // Keywords that do not require special indentation handling,
68 // but which should be highlighted
76 // but which should be highlighted
69 other: ["above", "below", "by", "from", "handler", "in",
77 other: ["above", "below", "by", "from", "handler", "in",
70 "instance", "let", "local", "otherwise", "slot",
78 "instance", "let", "local", "otherwise", "slot",
71 "subclass", "then", "to", "keyed-by", "virtual"
79 "subclass", "then", "to", "keyed-by", "virtual"
72 ],
80 ],
73
81
74 // Condition signaling function calls
82 // Condition signaling function calls
75 signalingCalls: ["signal", "error", "cerror",
83 signalingCalls: ["signal", "error", "cerror",
76 "break", "check-type", "abort"
84 "break", "check-type", "abort"
77 ]
85 ]
78 };
86 };
79
87
80 words["otherDefinition"] =
88 words["otherDefinition"] =
81 words["unnamedDefinition"]
89 words["unnamedDefinition"]
82 .concat(words["namedDefinition"])
90 .concat(words["namedDefinition"])
83 .concat(words["otherParameterizedDefinition"]);
91 .concat(words["otherParameterizedDefinition"]);
84
92
85 words["definition"] =
93 words["definition"] =
86 words["typeParameterizedDefinition"]
94 words["typeParameterizedDefinition"]
87 .concat(words["otherDefinition"]);
95 .concat(words["otherDefinition"]);
88
96
89 words["parameterizedDefinition"] =
97 words["parameterizedDefinition"] =
90 words["typeParameterizedDefinition"]
98 words["typeParameterizedDefinition"]
91 .concat(words["otherParameterizedDefinition"]);
99 .concat(words["otherParameterizedDefinition"]);
92
100
93 words["simpleDefinition"] =
101 words["simpleDefinition"] =
94 words["constantSimpleDefinition"]
102 words["constantSimpleDefinition"]
95 .concat(words["variableSimpleDefinition"])
103 .concat(words["variableSimpleDefinition"])
96 .concat(words["otherSimpleDefinition"]);
104 .concat(words["otherSimpleDefinition"]);
97
105
98 words["keyword"] =
106 words["keyword"] =
99 words["statement"]
107 words["statement"]
100 .concat(words["separator"])
108 .concat(words["separator"])
101 .concat(words["other"]);
109 .concat(words["other"]);
102
110
103 // Patterns
111 // Patterns
104 var symbolPattern = "[-_a-zA-Z?!*@<>$%]+";
112 var symbolPattern = "[-_a-zA-Z?!*@<>$%]+";
105 var symbol = new RegExp("^" + symbolPattern);
113 var symbol = new RegExp("^" + symbolPattern);
106 var patterns = {
114 var patterns = {
107 // Symbols with special syntax
115 // Symbols with special syntax
108 symbolKeyword: symbolPattern + ":",
116 symbolKeyword: symbolPattern + ":",
109 symbolClass: "<" + symbolPattern + ">",
117 symbolClass: "<" + symbolPattern + ">",
110 symbolGlobal: "\\*" + symbolPattern + "\\*",
118 symbolGlobal: "\\*" + symbolPattern + "\\*",
111 symbolConstant: "\\$" + symbolPattern
119 symbolConstant: "\\$" + symbolPattern
112 };
120 };
113 var patternStyles = {
121 var patternStyles = {
114 symbolKeyword: "atom",
122 symbolKeyword: "atom",
115 symbolClass: "tag",
123 symbolClass: "tag",
116 symbolGlobal: "variable-2",
124 symbolGlobal: "variable-2",
117 symbolConstant: "variable-3"
125 symbolConstant: "variable-3"
118 };
126 };
119
127
120 // Compile all patterns to regular expressions
128 // Compile all patterns to regular expressions
121 for (var patternName in patterns)
129 for (var patternName in patterns)
122 if (patterns.hasOwnProperty(patternName))
130 if (patterns.hasOwnProperty(patternName))
123 patterns[patternName] = new RegExp("^" + patterns[patternName]);
131 patterns[patternName] = new RegExp("^" + patterns[patternName]);
124
132
125 // Names beginning "with-" and "without-" are commonly
133 // Names beginning "with-" and "without-" are commonly
126 // used as statement macro
134 // used as statement macro
127 patterns["keyword"] = [/^with(?:out)?-[-_a-zA-Z?!*@<>$%]+/];
135 patterns["keyword"] = [/^with(?:out)?-[-_a-zA-Z?!*@<>$%]+/];
128
136
129 var styles = {};
137 var styles = {};
130 styles["keyword"] = "keyword";
138 styles["keyword"] = "keyword";
131 styles["definition"] = "def";
139 styles["definition"] = "def";
132 styles["simpleDefinition"] = "def";
140 styles["simpleDefinition"] = "def";
133 styles["signalingCalls"] = "builtin";
141 styles["signalingCalls"] = "builtin";
134
142
135 // protected words lookup table
143 // protected words lookup table
136 var wordLookup = {};
144 var wordLookup = {};
137 var styleLookup = {};
145 var styleLookup = {};
138
146
139 [
147 forEach([
140 "keyword",
148 "keyword",
141 "definition",
149 "definition",
142 "simpleDefinition",
150 "simpleDefinition",
143 "signalingCalls"
151 "signalingCalls"
144 ].forEach(function(type) {
152 ], function(type) {
145 words[type].forEach(function(word) {
153 forEach(words[type], function(word) {
146 wordLookup[word] = type;
154 wordLookup[word] = type;
147 styleLookup[word] = styles[type];
155 styleLookup[word] = styles[type];
148 });
156 });
149 });
157 });
150
158
151
159
152 function chain(stream, state, f) {
160 function chain(stream, state, f) {
153 state.tokenize = f;
161 state.tokenize = f;
154 return f(stream, state);
162 return f(stream, state);
155 }
163 }
156
164
157 function tokenBase(stream, state) {
165 function tokenBase(stream, state) {
158 // String
166 // String
159 var ch = stream.peek();
167 var ch = stream.peek();
160 if (ch == "'" || ch == '"') {
168 if (ch == "'" || ch == '"') {
161 stream.next();
169 stream.next();
162 return chain(stream, state, tokenString(ch, "string"));
170 return chain(stream, state, tokenString(ch, "string"));
163 }
171 }
164 // Comment
172 // Comment
165 else if (ch == "/") {
173 else if (ch == "/") {
166 stream.next();
174 stream.next();
167 if (stream.eat("*")) {
175 if (stream.eat("*")) {
168 return chain(stream, state, tokenComment);
176 return chain(stream, state, tokenComment);
169 } else if (stream.eat("/")) {
177 } else if (stream.eat("/")) {
170 stream.skipToEnd();
178 stream.skipToEnd();
171 return "comment";
179 return "comment";
172 } else {
173 stream.skipTo(" ");
174 return "operator";
175 }
180 }
181 stream.backUp(1);
176 }
182 }
177 // Decimal
183 // Decimal
178 else if (/\d/.test(ch)) {
184 else if (/[+\-\d\.]/.test(ch)) {
179 stream.match(/^\d*(?:\.\d*)?(?:e[+\-]?\d+)?/);
185 if (stream.match(/^[+-]?[0-9]*\.[0-9]*([esdx][+-]?[0-9]+)?/i) ||
186 stream.match(/^[+-]?[0-9]+([esdx][+-]?[0-9]+)/i) ||
187 stream.match(/^[+-]?\d+/)) {
180 return "number";
188 return "number";
181 }
189 }
190 }
182 // Hash
191 // Hash
183 else if (ch == "#") {
192 else if (ch == "#") {
184 stream.next();
193 stream.next();
185 // Symbol with string syntax
194 // Symbol with string syntax
186 ch = stream.peek();
195 ch = stream.peek();
187 if (ch == '"') {
196 if (ch == '"') {
188 stream.next();
197 stream.next();
189 return chain(stream, state, tokenString('"', "string-2"));
198 return chain(stream, state, tokenString('"', "string"));
190 }
199 }
191 // Binary number
200 // Binary number
192 else if (ch == "b") {
201 else if (ch == "b") {
193 stream.next();
202 stream.next();
194 stream.eatWhile(/[01]/);
203 stream.eatWhile(/[01]/);
195 return "number";
204 return "number";
196 }
205 }
197 // Hex number
206 // Hex number
198 else if (ch == "x") {
207 else if (ch == "x") {
199 stream.next();
208 stream.next();
200 stream.eatWhile(/[\da-f]/i);
209 stream.eatWhile(/[\da-f]/i);
201 return "number";
210 return "number";
202 }
211 }
203 // Octal number
212 // Octal number
204 else if (ch == "o") {
213 else if (ch == "o") {
205 stream.next();
214 stream.next();
206 stream.eatWhile(/[0-7]/);
215 stream.eatWhile(/[0-7]/);
207 return "number";
216 return "number";
208 }
217 }
218 // Token concatenation in macros
219 else if (ch == '#') {
220 stream.next();
221 return "punctuation";
222 }
223 // Sequence literals
224 else if ((ch == '[') || (ch == '(')) {
225 stream.next();
226 return "bracket";
209 // Hash symbol
227 // Hash symbol
210 else {
228 } else if (stream.match(/f|t|all-keys|include|key|next|rest/i)) {
229 return "atom";
230 } else {
211 stream.eatWhile(/[-a-zA-Z]/);
231 stream.eatWhile(/[-a-zA-Z]/);
212 return "keyword";
232 return "error";
233 }
234 } else if (ch == "~") {
235 stream.next();
236 ch = stream.peek();
237 if (ch == "=") {
238 stream.next();
239 ch = stream.peek();
240 if (ch == "=") {
241 stream.next();
242 return "operator";
243 }
244 return "operator";
213 }
245 }
246 return "operator";
247 } else if (ch == ":") {
248 stream.next();
249 ch = stream.peek();
250 if (ch == "=") {
251 stream.next();
252 return "operator";
253 } else if (ch == ":") {
254 stream.next();
255 return "punctuation";
256 }
257 } else if ("[](){}".indexOf(ch) != -1) {
258 stream.next();
259 return "bracket";
260 } else if (".,".indexOf(ch) != -1) {
261 stream.next();
262 return "punctuation";
214 } else if (stream.match("end")) {
263 } else if (stream.match("end")) {
215 return "keyword";
264 return "keyword";
216 }
265 }
217 for (var name in patterns) {
266 for (var name in patterns) {
218 if (patterns.hasOwnProperty(name)) {
267 if (patterns.hasOwnProperty(name)) {
219 var pattern = patterns[name];
268 var pattern = patterns[name];
220 if ((pattern instanceof Array && pattern.some(function(p) {
269 if ((pattern instanceof Array && some(pattern, function(p) {
221 return stream.match(p);
270 return stream.match(p);
222 })) || stream.match(pattern))
271 })) || stream.match(pattern))
223 return patternStyles[name];
272 return patternStyles[name];
224 }
273 }
225 }
274 }
275 if (/[+\-*\/^=<>&|]/.test(ch)) {
276 stream.next();
277 return "operator";
278 }
226 if (stream.match("define")) {
279 if (stream.match("define")) {
227 return "def";
280 return "def";
228 } else {
281 } else {
229 stream.eatWhile(/[\w\-]/);
282 stream.eatWhile(/[\w\-]/);
230 // Keyword
283 // Keyword
231 if (wordLookup[stream.current()]) {
284 if (wordLookup.hasOwnProperty(stream.current())) {
232 return styleLookup[stream.current()];
285 return styleLookup[stream.current()];
233 } else if (stream.current().match(symbol)) {
286 } else if (stream.current().match(symbol)) {
234 return "variable";
287 return "variable";
235 } else {
288 } else {
236 stream.next();
289 stream.next();
237 return "variable-2";
290 return "variable-2";
238 }
291 }
239 }
292 }
240 }
293 }
241
294
242 function tokenComment(stream, state) {
295 function tokenComment(stream, state) {
243 var maybeEnd = false,
296 var maybeEnd = false, maybeNested = false, nestedCount = 0, ch;
244 ch;
245 while ((ch = stream.next())) {
297 while ((ch = stream.next())) {
246 if (ch == "/" && maybeEnd) {
298 if (ch == "/" && maybeEnd) {
299 if (nestedCount > 0) {
300 nestedCount--;
301 } else {
247 state.tokenize = tokenBase;
302 state.tokenize = tokenBase;
248 break;
303 break;
249 }
304 }
305 } else if (ch == "*" && maybeNested) {
306 nestedCount++;
307 }
250 maybeEnd = (ch == "*");
308 maybeEnd = (ch == "*");
309 maybeNested = (ch == "/");
251 }
310 }
252 return "comment";
311 return "comment";
253 }
312 }
254
313
255 function tokenString(quote, style) {
314 function tokenString(quote, style) {
256 return function(stream, state) {
315 return function(stream, state) {
257 var next, end = false;
316 var escaped = false, next, end = false;
258 while ((next = stream.next()) != null) {
317 while ((next = stream.next()) != null) {
259 if (next == quote) {
318 if (next == quote && !escaped) {
260 end = true;
319 end = true;
261 break;
320 break;
262 }
321 }
322 escaped = !escaped && next == "\\";
263 }
323 }
264 if (end)
324 if (end || !escaped) {
265 state.tokenize = tokenBase;
325 state.tokenize = tokenBase;
326 }
266 return style;
327 return style;
267 };
328 };
268 }
329 }
269
330
270 // Interface
331 // Interface
271 return {
332 return {
272 startState: function() {
333 startState: function() {
273 return {
334 return {
274 tokenize: tokenBase,
335 tokenize: tokenBase,
275 currentIndent: 0
336 currentIndent: 0
276 };
337 };
277 },
338 },
278 token: function(stream, state) {
339 token: function(stream, state) {
279 if (stream.eatSpace())
340 if (stream.eatSpace())
280 return null;
341 return null;
281 var style = state.tokenize(stream, state);
342 var style = state.tokenize(stream, state);
282 return style;
343 return style;
283 },
344 },
284 blockCommentStart: "/*",
345 blockCommentStart: "/*",
285 blockCommentEnd: "*/"
346 blockCommentEnd: "*/"
286 };
347 };
287 });
348 });
288
349
289 CodeMirror.defineMIME("text/x-dylan", "dylan");
350 CodeMirror.defineMIME("text/x-dylan", "dylan");
290
351
291 });
352 });
@@ -1,195 +1,195 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("ebnf", function (config) {
14 CodeMirror.defineMode("ebnf", function (config) {
15 var commentType = {slash: 0, parenthesis: 1};
15 var commentType = {slash: 0, parenthesis: 1};
16 var stateType = {comment: 0, _string: 1, characterClass: 2};
16 var stateType = {comment: 0, _string: 1, characterClass: 2};
17 var bracesMode = null;
17 var bracesMode = null;
18
18
19 if (config.bracesMode)
19 if (config.bracesMode)
20 bracesMode = CodeMirror.getMode(config, config.bracesMode);
20 bracesMode = CodeMirror.getMode(config, config.bracesMode);
21
21
22 return {
22 return {
23 startState: function () {
23 startState: function () {
24 return {
24 return {
25 stringType: null,
25 stringType: null,
26 commentType: null,
26 commentType: null,
27 braced: 0,
27 braced: 0,
28 lhs: true,
28 lhs: true,
29 localState: null,
29 localState: null,
30 stack: [],
30 stack: [],
31 inDefinition: false
31 inDefinition: false
32 };
32 };
33 },
33 },
34 token: function (stream, state) {
34 token: function (stream, state) {
35 if (!stream) return;
35 if (!stream) return;
36
36
37 //check for state changes
37 //check for state changes
38 if (state.stack.length === 0) {
38 if (state.stack.length === 0) {
39 //strings
39 //strings
40 if ((stream.peek() == '"') || (stream.peek() == "'")) {
40 if ((stream.peek() == '"') || (stream.peek() == "'")) {
41 state.stringType = stream.peek();
41 state.stringType = stream.peek();
42 stream.next(); // Skip quote
42 stream.next(); // Skip quote
43 state.stack.unshift(stateType._string);
43 state.stack.unshift(stateType._string);
44 } else if (stream.match(/^\/\*/)) { //comments starting with /*
44 } else if (stream.match(/^\/\*/)) { //comments starting with /*
45 state.stack.unshift(stateType.comment);
45 state.stack.unshift(stateType.comment);
46 state.commentType = commentType.slash;
46 state.commentType = commentType.slash;
47 } else if (stream.match(/^\(\*/)) { //comments starting with (*
47 } else if (stream.match(/^\(\*/)) { //comments starting with (*
48 state.stack.unshift(stateType.comment);
48 state.stack.unshift(stateType.comment);
49 state.commentType = commentType.parenthesis;
49 state.commentType = commentType.parenthesis;
50 }
50 }
51 }
51 }
52
52
53 //return state
53 //return state
54 //stack has
54 //stack has
55 switch (state.stack[0]) {
55 switch (state.stack[0]) {
56 case stateType._string:
56 case stateType._string:
57 while (state.stack[0] === stateType._string && !stream.eol()) {
57 while (state.stack[0] === stateType._string && !stream.eol()) {
58 if (stream.peek() === state.stringType) {
58 if (stream.peek() === state.stringType) {
59 stream.next(); // Skip quote
59 stream.next(); // Skip quote
60 state.stack.shift(); // Clear flag
60 state.stack.shift(); // Clear flag
61 } else if (stream.peek() === "\\") {
61 } else if (stream.peek() === "\\") {
62 stream.next();
62 stream.next();
63 stream.next();
63 stream.next();
64 } else {
64 } else {
65 stream.match(/^.[^\\\"\']*/);
65 stream.match(/^.[^\\\"\']*/);
66 }
66 }
67 }
67 }
68 return state.lhs ? "property string" : "string"; // Token style
68 return state.lhs ? "property string" : "string"; // Token style
69
69
70 case stateType.comment:
70 case stateType.comment:
71 while (state.stack[0] === stateType.comment && !stream.eol()) {
71 while (state.stack[0] === stateType.comment && !stream.eol()) {
72 if (state.commentType === commentType.slash && stream.match(/\*\//)) {
72 if (state.commentType === commentType.slash && stream.match(/\*\//)) {
73 state.stack.shift(); // Clear flag
73 state.stack.shift(); // Clear flag
74 state.commentType = null;
74 state.commentType = null;
75 } else if (state.commentType === commentType.parenthesis && stream.match(/\*\)/)) {
75 } else if (state.commentType === commentType.parenthesis && stream.match(/\*\)/)) {
76 state.stack.shift(); // Clear flag
76 state.stack.shift(); // Clear flag
77 state.commentType = null;
77 state.commentType = null;
78 } else {
78 } else {
79 stream.match(/^.[^\*]*/);
79 stream.match(/^.[^\*]*/);
80 }
80 }
81 }
81 }
82 return "comment";
82 return "comment";
83
83
84 case stateType.characterClass:
84 case stateType.characterClass:
85 while (state.stack[0] === stateType.characterClass && !stream.eol()) {
85 while (state.stack[0] === stateType.characterClass && !stream.eol()) {
86 if (!(stream.match(/^[^\]\\]+/) || stream.match(/^\\./))) {
86 if (!(stream.match(/^[^\]\\]+/) || stream.match(/^\\./))) {
87 state.stack.shift();
87 state.stack.shift();
88 }
88 }
89 }
89 }
90 return "operator";
90 return "operator";
91 }
91 }
92
92
93 var peek = stream.peek();
93 var peek = stream.peek();
94
94
95 if (bracesMode !== null && (state.braced || peek === "{")) {
95 if (bracesMode !== null && (state.braced || peek === "{")) {
96 if (state.localState === null)
96 if (state.localState === null)
97 state.localState = bracesMode.startState();
97 state.localState = CodeMirror.startState(bracesMode);
98
98
99 var token = bracesMode.token(stream, state.localState),
99 var token = bracesMode.token(stream, state.localState),
100 text = stream.current();
100 text = stream.current();
101
101
102 if (!token) {
102 if (!token) {
103 for (var i = 0; i < text.length; i++) {
103 for (var i = 0; i < text.length; i++) {
104 if (text[i] === "{") {
104 if (text[i] === "{") {
105 if (state.braced === 0) {
105 if (state.braced === 0) {
106 token = "matchingbracket";
106 token = "matchingbracket";
107 }
107 }
108 state.braced++;
108 state.braced++;
109 } else if (text[i] === "}") {
109 } else if (text[i] === "}") {
110 state.braced--;
110 state.braced--;
111 if (state.braced === 0) {
111 if (state.braced === 0) {
112 token = "matchingbracket";
112 token = "matchingbracket";
113 }
113 }
114 }
114 }
115 }
115 }
116 }
116 }
117 return token;
117 return token;
118 }
118 }
119
119
120 //no stack
120 //no stack
121 switch (peek) {
121 switch (peek) {
122 case "[":
122 case "[":
123 stream.next();
123 stream.next();
124 state.stack.unshift(stateType.characterClass);
124 state.stack.unshift(stateType.characterClass);
125 return "bracket";
125 return "bracket";
126 case ":":
126 case ":":
127 case "|":
127 case "|":
128 case ";":
128 case ";":
129 stream.next();
129 stream.next();
130 return "operator";
130 return "operator";
131 case "%":
131 case "%":
132 if (stream.match("%%")) {
132 if (stream.match("%%")) {
133 return "header";
133 return "header";
134 } else if (stream.match(/[%][A-Za-z]+/)) {
134 } else if (stream.match(/[%][A-Za-z]+/)) {
135 return "keyword";
135 return "keyword";
136 } else if (stream.match(/[%][}]/)) {
136 } else if (stream.match(/[%][}]/)) {
137 return "matchingbracket";
137 return "matchingbracket";
138 }
138 }
139 break;
139 break;
140 case "/":
140 case "/":
141 if (stream.match(/[\/][A-Za-z]+/)) {
141 if (stream.match(/[\/][A-Za-z]+/)) {
142 return "keyword";
142 return "keyword";
143 }
143 }
144 case "\\":
144 case "\\":
145 if (stream.match(/[\][a-z]+/)) {
145 if (stream.match(/[\][a-z]+/)) {
146 return "string-2";
146 return "string-2";
147 }
147 }
148 case ".":
148 case ".":
149 if (stream.match(".")) {
149 if (stream.match(".")) {
150 return "atom";
150 return "atom";
151 }
151 }
152 case "*":
152 case "*":
153 case "-":
153 case "-":
154 case "+":
154 case "+":
155 case "^":
155 case "^":
156 if (stream.match(peek)) {
156 if (stream.match(peek)) {
157 return "atom";
157 return "atom";
158 }
158 }
159 case "$":
159 case "$":
160 if (stream.match("$$")) {
160 if (stream.match("$$")) {
161 return "builtin";
161 return "builtin";
162 } else if (stream.match(/[$][0-9]+/)) {
162 } else if (stream.match(/[$][0-9]+/)) {
163 return "variable-3";
163 return "variable-3";
164 }
164 }
165 case "<":
165 case "<":
166 if (stream.match(/<<[a-zA-Z_]+>>/)) {
166 if (stream.match(/<<[a-zA-Z_]+>>/)) {
167 return "builtin";
167 return "builtin";
168 }
168 }
169 }
169 }
170
170
171 if (stream.match(/^\/\//)) {
171 if (stream.match(/^\/\//)) {
172 stream.skipToEnd();
172 stream.skipToEnd();
173 return "comment";
173 return "comment";
174 } else if (stream.match(/return/)) {
174 } else if (stream.match(/return/)) {
175 return "operator";
175 return "operator";
176 } else if (stream.match(/^[a-zA-Z_][a-zA-Z0-9_]*/)) {
176 } else if (stream.match(/^[a-zA-Z_][a-zA-Z0-9_]*/)) {
177 if (stream.match(/(?=[\(.])/)) {
177 if (stream.match(/(?=[\(.])/)) {
178 return "variable";
178 return "variable";
179 } else if (stream.match(/(?=[\s\n]*[:=])/)) {
179 } else if (stream.match(/(?=[\s\n]*[:=])/)) {
180 return "def";
180 return "def";
181 }
181 }
182 return "variable-2";
182 return "variable-2";
183 } else if (["[", "]", "(", ")"].indexOf(stream.peek()) != -1) {
183 } else if (["[", "]", "(", ")"].indexOf(stream.peek()) != -1) {
184 stream.next();
184 stream.next();
185 return "bracket";
185 return "bracket";
186 } else if (!stream.eatSpace()) {
186 } else if (!stream.eatSpace()) {
187 stream.next();
187 stream.next();
188 }
188 }
189 return null;
189 return null;
190 }
190 }
191 };
191 };
192 });
192 });
193
193
194 CodeMirror.defineMIME("text/x-ebnf", "ebnf");
194 CodeMirror.defineMIME("text/x-ebnf", "ebnf");
195 });
195 });
@@ -1,206 +1,206 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("ecl", function(config) {
14 CodeMirror.defineMode("ecl", function(config) {
15
15
16 function words(str) {
16 function words(str) {
17 var obj = {}, words = str.split(" ");
17 var obj = {}, words = str.split(" ");
18 for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
18 for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
19 return obj;
19 return obj;
20 }
20 }
21
21
22 function metaHook(stream, state) {
22 function metaHook(stream, state) {
23 if (!state.startOfLine) return false;
23 if (!state.startOfLine) return false;
24 stream.skipToEnd();
24 stream.skipToEnd();
25 return "meta";
25 return "meta";
26 }
26 }
27
27
28 var indentUnit = config.indentUnit;
28 var indentUnit = config.indentUnit;
29 var keyword = words("abs acos allnodes ascii asin asstring atan atan2 ave case choose choosen choosesets clustersize combine correlation cos cosh count covariance cron dataset dedup define denormalize distribute distributed distribution ebcdic enth error evaluate event eventextra eventname exists exp failcode failmessage fetch fromunicode getisvalid global graph group hash hash32 hash64 hashcrc hashmd5 having if index intformat isvalid iterate join keyunicode length library limit ln local log loop map matched matchlength matchposition matchtext matchunicode max merge mergejoin min nolocal nonempty normalize parse pipe power preload process project pull random range rank ranked realformat recordof regexfind regexreplace regroup rejected rollup round roundup row rowdiff sample set sin sinh sizeof soapcall sort sorted sqrt stepped stored sum table tan tanh thisnode topn tounicode transfer trim truncate typeof ungroup unicodeorder variance which workunit xmldecode xmlencode xmltext xmlunicode");
29 var keyword = words("abs acos allnodes ascii asin asstring atan atan2 ave case choose choosen choosesets clustersize combine correlation cos cosh count covariance cron dataset dedup define denormalize distribute distributed distribution ebcdic enth error evaluate event eventextra eventname exists exp failcode failmessage fetch fromunicode getisvalid global graph group hash hash32 hash64 hashcrc hashmd5 having if index intformat isvalid iterate join keyunicode length library limit ln local log loop map matched matchlength matchposition matchtext matchunicode max merge mergejoin min nolocal nonempty normalize parse pipe power preload process project pull random range rank ranked realformat recordof regexfind regexreplace regroup rejected rollup round roundup row rowdiff sample set sin sinh sizeof soapcall sort sorted sqrt stepped stored sum table tan tanh thisnode topn tounicode transfer trim truncate typeof ungroup unicodeorder variance which workunit xmldecode xmlencode xmltext xmlunicode");
30 var variable = words("apply assert build buildindex evaluate fail keydiff keypatch loadxml nothor notify output parallel sequential soapcall wait");
30 var variable = words("apply assert build buildindex evaluate fail keydiff keypatch loadxml nothor notify output parallel sequential soapcall wait");
31 var variable_2 = words("__compressed__ all and any as atmost before beginc++ best between case const counter csv descend encrypt end endc++ endmacro except exclusive expire export extend false few first flat from full function group header heading hole ifblock import in interface joined keep keyed last left limit load local locale lookup macro many maxcount maxlength min skew module named nocase noroot noscan nosort not of only opt or outer overwrite packed partition penalty physicallength pipe quote record relationship repeat return right scan self separator service shared skew skip sql store terminator thor threshold token transform trim true type unicodeorder unsorted validate virtual whole wild within xml xpath");
31 var variable_2 = words("__compressed__ all and any as atmost before beginc++ best between case const counter csv descend encrypt end endc++ endmacro except exclusive expire export extend false few first flat from full function group header heading hole ifblock import in interface joined keep keyed last left limit load local locale lookup macro many maxcount maxlength min skew module named nocase noroot noscan nosort not of only opt or outer overwrite packed partition penalty physicallength pipe quote record relationship repeat return right scan self separator service shared skew skip sql store terminator thor threshold token transform trim true type unicodeorder unsorted validate virtual whole wild within xml xpath");
32 var variable_3 = words("ascii big_endian boolean data decimal ebcdic integer pattern qstring real record rule set of string token udecimal unicode unsigned varstring varunicode");
32 var variable_3 = words("ascii big_endian boolean data decimal ebcdic integer pattern qstring real record rule set of string token udecimal unicode unsigned varstring varunicode");
33 var builtin = words("checkpoint deprecated failcode failmessage failure global independent onwarning persist priority recovery stored success wait when");
33 var builtin = words("checkpoint deprecated failcode failmessage failure global independent onwarning persist priority recovery stored success wait when");
34 var blockKeywords = words("catch class do else finally for if switch try while");
34 var blockKeywords = words("catch class do else finally for if switch try while");
35 var atoms = words("true false null");
35 var atoms = words("true false null");
36 var hooks = {"#": metaHook};
36 var hooks = {"#": metaHook};
37 var isOperatorChar = /[+\-*&%=<>!?|\/]/;
37 var isOperatorChar = /[+\-*&%=<>!?|\/]/;
38
38
39 var curPunc;
39 var curPunc;
40
40
41 function tokenBase(stream, state) {
41 function tokenBase(stream, state) {
42 var ch = stream.next();
42 var ch = stream.next();
43 if (hooks[ch]) {
43 if (hooks[ch]) {
44 var result = hooks[ch](stream, state);
44 var result = hooks[ch](stream, state);
45 if (result !== false) return result;
45 if (result !== false) return result;
46 }
46 }
47 if (ch == '"' || ch == "'") {
47 if (ch == '"' || ch == "'") {
48 state.tokenize = tokenString(ch);
48 state.tokenize = tokenString(ch);
49 return state.tokenize(stream, state);
49 return state.tokenize(stream, state);
50 }
50 }
51 if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
51 if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
52 curPunc = ch;
52 curPunc = ch;
53 return null;
53 return null;
54 }
54 }
55 if (/\d/.test(ch)) {
55 if (/\d/.test(ch)) {
56 stream.eatWhile(/[\w\.]/);
56 stream.eatWhile(/[\w\.]/);
57 return "number";
57 return "number";
58 }
58 }
59 if (ch == "/") {
59 if (ch == "/") {
60 if (stream.eat("*")) {
60 if (stream.eat("*")) {
61 state.tokenize = tokenComment;
61 state.tokenize = tokenComment;
62 return tokenComment(stream, state);
62 return tokenComment(stream, state);
63 }
63 }
64 if (stream.eat("/")) {
64 if (stream.eat("/")) {
65 stream.skipToEnd();
65 stream.skipToEnd();
66 return "comment";
66 return "comment";
67 }
67 }
68 }
68 }
69 if (isOperatorChar.test(ch)) {
69 if (isOperatorChar.test(ch)) {
70 stream.eatWhile(isOperatorChar);
70 stream.eatWhile(isOperatorChar);
71 return "operator";
71 return "operator";
72 }
72 }
73 stream.eatWhile(/[\w\$_]/);
73 stream.eatWhile(/[\w\$_]/);
74 var cur = stream.current().toLowerCase();
74 var cur = stream.current().toLowerCase();
75 if (keyword.propertyIsEnumerable(cur)) {
75 if (keyword.propertyIsEnumerable(cur)) {
76 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
76 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
77 return "keyword";
77 return "keyword";
78 } else if (variable.propertyIsEnumerable(cur)) {
78 } else if (variable.propertyIsEnumerable(cur)) {
79 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
79 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
80 return "variable";
80 return "variable";
81 } else if (variable_2.propertyIsEnumerable(cur)) {
81 } else if (variable_2.propertyIsEnumerable(cur)) {
82 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
82 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
83 return "variable-2";
83 return "variable-2";
84 } else if (variable_3.propertyIsEnumerable(cur)) {
84 } else if (variable_3.propertyIsEnumerable(cur)) {
85 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
85 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
86 return "variable-3";
86 return "variable-3";
87 } else if (builtin.propertyIsEnumerable(cur)) {
87 } else if (builtin.propertyIsEnumerable(cur)) {
88 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
88 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
89 return "builtin";
89 return "builtin";
90 } else { //Data types are of from KEYWORD##
90 } else { //Data types are of from KEYWORD##
91 var i = cur.length - 1;
91 var i = cur.length - 1;
92 while(i >= 0 && (!isNaN(cur[i]) || cur[i] == '_'))
92 while(i >= 0 && (!isNaN(cur[i]) || cur[i] == '_'))
93 --i;
93 --i;
94
94
95 if (i > 0) {
95 if (i > 0) {
96 var cur2 = cur.substr(0, i + 1);
96 var cur2 = cur.substr(0, i + 1);
97 if (variable_3.propertyIsEnumerable(cur2)) {
97 if (variable_3.propertyIsEnumerable(cur2)) {
98 if (blockKeywords.propertyIsEnumerable(cur2)) curPunc = "newstatement";
98 if (blockKeywords.propertyIsEnumerable(cur2)) curPunc = "newstatement";
99 return "variable-3";
99 return "variable-3";
100 }
100 }
101 }
101 }
102 }
102 }
103 if (atoms.propertyIsEnumerable(cur)) return "atom";
103 if (atoms.propertyIsEnumerable(cur)) return "atom";
104 return null;
104 return null;
105 }
105 }
106
106
107 function tokenString(quote) {
107 function tokenString(quote) {
108 return function(stream, state) {
108 return function(stream, state) {
109 var escaped = false, next, end = false;
109 var escaped = false, next, end = false;
110 while ((next = stream.next()) != null) {
110 while ((next = stream.next()) != null) {
111 if (next == quote && !escaped) {end = true; break;}
111 if (next == quote && !escaped) {end = true; break;}
112 escaped = !escaped && next == "\\";
112 escaped = !escaped && next == "\\";
113 }
113 }
114 if (end || !escaped)
114 if (end || !escaped)
115 state.tokenize = tokenBase;
115 state.tokenize = tokenBase;
116 return "string";
116 return "string";
117 };
117 };
118 }
118 }
119
119
120 function tokenComment(stream, state) {
120 function tokenComment(stream, state) {
121 var maybeEnd = false, ch;
121 var maybeEnd = false, ch;
122 while (ch = stream.next()) {
122 while (ch = stream.next()) {
123 if (ch == "/" && maybeEnd) {
123 if (ch == "/" && maybeEnd) {
124 state.tokenize = tokenBase;
124 state.tokenize = tokenBase;
125 break;
125 break;
126 }
126 }
127 maybeEnd = (ch == "*");
127 maybeEnd = (ch == "*");
128 }
128 }
129 return "comment";
129 return "comment";
130 }
130 }
131
131
132 function Context(indented, column, type, align, prev) {
132 function Context(indented, column, type, align, prev) {
133 this.indented = indented;
133 this.indented = indented;
134 this.column = column;
134 this.column = column;
135 this.type = type;
135 this.type = type;
136 this.align = align;
136 this.align = align;
137 this.prev = prev;
137 this.prev = prev;
138 }
138 }
139 function pushContext(state, col, type) {
139 function pushContext(state, col, type) {
140 return state.context = new Context(state.indented, col, type, null, state.context);
140 return state.context = new Context(state.indented, col, type, null, state.context);
141 }
141 }
142 function popContext(state) {
142 function popContext(state) {
143 var t = state.context.type;
143 var t = state.context.type;
144 if (t == ")" || t == "]" || t == "}")
144 if (t == ")" || t == "]" || t == "}")
145 state.indented = state.context.indented;
145 state.indented = state.context.indented;
146 return state.context = state.context.prev;
146 return state.context = state.context.prev;
147 }
147 }
148
148
149 // Interface
149 // Interface
150
150
151 return {
151 return {
152 startState: function(basecolumn) {
152 startState: function(basecolumn) {
153 return {
153 return {
154 tokenize: null,
154 tokenize: null,
155 context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
155 context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
156 indented: 0,
156 indented: 0,
157 startOfLine: true
157 startOfLine: true
158 };
158 };
159 },
159 },
160
160
161 token: function(stream, state) {
161 token: function(stream, state) {
162 var ctx = state.context;
162 var ctx = state.context;
163 if (stream.sol()) {
163 if (stream.sol()) {
164 if (ctx.align == null) ctx.align = false;
164 if (ctx.align == null) ctx.align = false;
165 state.indented = stream.indentation();
165 state.indented = stream.indentation();
166 state.startOfLine = true;
166 state.startOfLine = true;
167 }
167 }
168 if (stream.eatSpace()) return null;
168 if (stream.eatSpace()) return null;
169 curPunc = null;
169 curPunc = null;
170 var style = (state.tokenize || tokenBase)(stream, state);
170 var style = (state.tokenize || tokenBase)(stream, state);
171 if (style == "comment" || style == "meta") return style;
171 if (style == "comment" || style == "meta") return style;
172 if (ctx.align == null) ctx.align = true;
172 if (ctx.align == null) ctx.align = true;
173
173
174 if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
174 if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
175 else if (curPunc == "{") pushContext(state, stream.column(), "}");
175 else if (curPunc == "{") pushContext(state, stream.column(), "}");
176 else if (curPunc == "[") pushContext(state, stream.column(), "]");
176 else if (curPunc == "[") pushContext(state, stream.column(), "]");
177 else if (curPunc == "(") pushContext(state, stream.column(), ")");
177 else if (curPunc == "(") pushContext(state, stream.column(), ")");
178 else if (curPunc == "}") {
178 else if (curPunc == "}") {
179 while (ctx.type == "statement") ctx = popContext(state);
179 while (ctx.type == "statement") ctx = popContext(state);
180 if (ctx.type == "}") ctx = popContext(state);
180 if (ctx.type == "}") ctx = popContext(state);
181 while (ctx.type == "statement") ctx = popContext(state);
181 while (ctx.type == "statement") ctx = popContext(state);
182 }
182 }
183 else if (curPunc == ctx.type) popContext(state);
183 else if (curPunc == ctx.type) popContext(state);
184 else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
184 else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
185 pushContext(state, stream.column(), "statement");
185 pushContext(state, stream.column(), "statement");
186 state.startOfLine = false;
186 state.startOfLine = false;
187 return style;
187 return style;
188 },
188 },
189
189
190 indent: function(state, textAfter) {
190 indent: function(state, textAfter) {
191 if (state.tokenize != tokenBase && state.tokenize != null) return 0;
191 if (state.tokenize != tokenBase && state.tokenize != null) return 0;
192 var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
192 var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
193 if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
193 if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
194 var closing = firstChar == ctx.type;
194 var closing = firstChar == ctx.type;
195 if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
195 if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
196 else if (ctx.align) return ctx.column + (closing ? 0 : 1);
196 else if (ctx.align) return ctx.column + (closing ? 0 : 1);
197 else return ctx.indented + (closing ? 0 : indentUnit);
197 else return ctx.indented + (closing ? 0 : indentUnit);
198 },
198 },
199
199
200 electricChars: "{}"
200 electricChars: "{}"
201 };
201 };
202 });
202 });
203
203
204 CodeMirror.defineMIME("text/x-ecl", "ecl");
204 CodeMirror.defineMIME("text/x-ecl", "ecl");
205
205
206 });
206 });
@@ -1,160 +1,160 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("eiffel", function() {
14 CodeMirror.defineMode("eiffel", function() {
15 function wordObj(words) {
15 function wordObj(words) {
16 var o = {};
16 var o = {};
17 for (var i = 0, e = words.length; i < e; ++i) o[words[i]] = true;
17 for (var i = 0, e = words.length; i < e; ++i) o[words[i]] = true;
18 return o;
18 return o;
19 }
19 }
20 var keywords = wordObj([
20 var keywords = wordObj([
21 'note',
21 'note',
22 'across',
22 'across',
23 'when',
23 'when',
24 'variant',
24 'variant',
25 'until',
25 'until',
26 'unique',
26 'unique',
27 'undefine',
27 'undefine',
28 'then',
28 'then',
29 'strip',
29 'strip',
30 'select',
30 'select',
31 'retry',
31 'retry',
32 'rescue',
32 'rescue',
33 'require',
33 'require',
34 'rename',
34 'rename',
35 'reference',
35 'reference',
36 'redefine',
36 'redefine',
37 'prefix',
37 'prefix',
38 'once',
38 'once',
39 'old',
39 'old',
40 'obsolete',
40 'obsolete',
41 'loop',
41 'loop',
42 'local',
42 'local',
43 'like',
43 'like',
44 'is',
44 'is',
45 'inspect',
45 'inspect',
46 'infix',
46 'infix',
47 'include',
47 'include',
48 'if',
48 'if',
49 'frozen',
49 'frozen',
50 'from',
50 'from',
51 'external',
51 'external',
52 'export',
52 'export',
53 'ensure',
53 'ensure',
54 'end',
54 'end',
55 'elseif',
55 'elseif',
56 'else',
56 'else',
57 'do',
57 'do',
58 'creation',
58 'creation',
59 'create',
59 'create',
60 'check',
60 'check',
61 'alias',
61 'alias',
62 'agent',
62 'agent',
63 'separate',
63 'separate',
64 'invariant',
64 'invariant',
65 'inherit',
65 'inherit',
66 'indexing',
66 'indexing',
67 'feature',
67 'feature',
68 'expanded',
68 'expanded',
69 'deferred',
69 'deferred',
70 'class',
70 'class',
71 'Void',
71 'Void',
72 'True',
72 'True',
73 'Result',
73 'Result',
74 'Precursor',
74 'Precursor',
75 'False',
75 'False',
76 'Current',
76 'Current',
77 'create',
77 'create',
78 'attached',
78 'attached',
79 'detachable',
79 'detachable',
80 'as',
80 'as',
81 'and',
81 'and',
82 'implies',
82 'implies',
83 'not',
83 'not',
84 'or'
84 'or'
85 ]);
85 ]);
86 var operators = wordObj([":=", "and then","and", "or","<<",">>"]);
86 var operators = wordObj([":=", "and then","and", "or","<<",">>"]);
87
87
88 function chain(newtok, stream, state) {
88 function chain(newtok, stream, state) {
89 state.tokenize.push(newtok);
89 state.tokenize.push(newtok);
90 return newtok(stream, state);
90 return newtok(stream, state);
91 }
91 }
92
92
93 function tokenBase(stream, state) {
93 function tokenBase(stream, state) {
94 if (stream.eatSpace()) return null;
94 if (stream.eatSpace()) return null;
95 var ch = stream.next();
95 var ch = stream.next();
96 if (ch == '"'||ch == "'") {
96 if (ch == '"'||ch == "'") {
97 return chain(readQuoted(ch, "string"), stream, state);
97 return chain(readQuoted(ch, "string"), stream, state);
98 } else if (ch == "-"&&stream.eat("-")) {
98 } else if (ch == "-"&&stream.eat("-")) {
99 stream.skipToEnd();
99 stream.skipToEnd();
100 return "comment";
100 return "comment";
101 } else if (ch == ":"&&stream.eat("=")) {
101 } else if (ch == ":"&&stream.eat("=")) {
102 return "operator";
102 return "operator";
103 } else if (/[0-9]/.test(ch)) {
103 } else if (/[0-9]/.test(ch)) {
104 stream.eatWhile(/[xXbBCc0-9\.]/);
104 stream.eatWhile(/[xXbBCc0-9\.]/);
105 stream.eat(/[\?\!]/);
105 stream.eat(/[\?\!]/);
106 return "ident";
106 return "ident";
107 } else if (/[a-zA-Z_0-9]/.test(ch)) {
107 } else if (/[a-zA-Z_0-9]/.test(ch)) {
108 stream.eatWhile(/[a-zA-Z_0-9]/);
108 stream.eatWhile(/[a-zA-Z_0-9]/);
109 stream.eat(/[\?\!]/);
109 stream.eat(/[\?\!]/);
110 return "ident";
110 return "ident";
111 } else if (/[=+\-\/*^%<>~]/.test(ch)) {
111 } else if (/[=+\-\/*^%<>~]/.test(ch)) {
112 stream.eatWhile(/[=+\-\/*^%<>~]/);
112 stream.eatWhile(/[=+\-\/*^%<>~]/);
113 return "operator";
113 return "operator";
114 } else {
114 } else {
115 return null;
115 return null;
116 }
116 }
117 }
117 }
118
118
119 function readQuoted(quote, style, unescaped) {
119 function readQuoted(quote, style, unescaped) {
120 return function(stream, state) {
120 return function(stream, state) {
121 var escaped = false, ch;
121 var escaped = false, ch;
122 while ((ch = stream.next()) != null) {
122 while ((ch = stream.next()) != null) {
123 if (ch == quote && (unescaped || !escaped)) {
123 if (ch == quote && (unescaped || !escaped)) {
124 state.tokenize.pop();
124 state.tokenize.pop();
125 break;
125 break;
126 }
126 }
127 escaped = !escaped && ch == "%";
127 escaped = !escaped && ch == "%";
128 }
128 }
129 return style;
129 return style;
130 };
130 };
131 }
131 }
132
132
133 return {
133 return {
134 startState: function() {
134 startState: function() {
135 return {tokenize: [tokenBase]};
135 return {tokenize: [tokenBase]};
136 },
136 },
137
137
138 token: function(stream, state) {
138 token: function(stream, state) {
139 var style = state.tokenize[state.tokenize.length-1](stream, state);
139 var style = state.tokenize[state.tokenize.length-1](stream, state);
140 if (style == "ident") {
140 if (style == "ident") {
141 var word = stream.current();
141 var word = stream.current();
142 style = keywords.propertyIsEnumerable(stream.current()) ? "keyword"
142 style = keywords.propertyIsEnumerable(stream.current()) ? "keyword"
143 : operators.propertyIsEnumerable(stream.current()) ? "operator"
143 : operators.propertyIsEnumerable(stream.current()) ? "operator"
144 : /^[A-Z][A-Z_0-9]*$/g.test(word) ? "tag"
144 : /^[A-Z][A-Z_0-9]*$/g.test(word) ? "tag"
145 : /^0[bB][0-1]+$/g.test(word) ? "number"
145 : /^0[bB][0-1]+$/g.test(word) ? "number"
146 : /^0[cC][0-7]+$/g.test(word) ? "number"
146 : /^0[cC][0-7]+$/g.test(word) ? "number"
147 : /^0[xX][a-fA-F0-9]+$/g.test(word) ? "number"
147 : /^0[xX][a-fA-F0-9]+$/g.test(word) ? "number"
148 : /^([0-9]+\.[0-9]*)|([0-9]*\.[0-9]+)$/g.test(word) ? "number"
148 : /^([0-9]+\.[0-9]*)|([0-9]*\.[0-9]+)$/g.test(word) ? "number"
149 : /^[0-9]+$/g.test(word) ? "number"
149 : /^[0-9]+$/g.test(word) ? "number"
150 : "variable";
150 : "variable";
151 }
151 }
152 return style;
152 return style;
153 },
153 },
154 lineComment: "--"
154 lineComment: "--"
155 };
155 };
156 });
156 });
157
157
158 CodeMirror.defineMIME("text/x-eiffel", "eiffel");
158 CodeMirror.defineMIME("text/x-eiffel", "eiffel");
159
159
160 });
160 });
@@ -1,205 +1,205 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("elm", function() {
14 CodeMirror.defineMode("elm", function() {
15
15
16 function switchState(source, setState, f) {
16 function switchState(source, setState, f) {
17 setState(f);
17 setState(f);
18 return f(source, setState);
18 return f(source, setState);
19 }
19 }
20
20
21 // These should all be Unicode extended, as per the Haskell 2010 report
21 // These should all be Unicode extended, as per the Haskell 2010 report
22 var smallRE = /[a-z_]/;
22 var smallRE = /[a-z_]/;
23 var largeRE = /[A-Z]/;
23 var largeRE = /[A-Z]/;
24 var digitRE = /[0-9]/;
24 var digitRE = /[0-9]/;
25 var hexitRE = /[0-9A-Fa-f]/;
25 var hexitRE = /[0-9A-Fa-f]/;
26 var octitRE = /[0-7]/;
26 var octitRE = /[0-7]/;
27 var idRE = /[a-z_A-Z0-9\']/;
27 var idRE = /[a-z_A-Z0-9\']/;
28 var symbolRE = /[-!#$%&*+.\/<=>?@\\^|~:\u03BB\u2192]/;
28 var symbolRE = /[-!#$%&*+.\/<=>?@\\^|~:\u03BB\u2192]/;
29 var specialRE = /[(),;[\]`{}]/;
29 var specialRE = /[(),;[\]`{}]/;
30 var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer
30 var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer
31
31
32 function normal() {
32 function normal() {
33 return function (source, setState) {
33 return function (source, setState) {
34 if (source.eatWhile(whiteCharRE)) {
34 if (source.eatWhile(whiteCharRE)) {
35 return null;
35 return null;
36 }
36 }
37
37
38 var ch = source.next();
38 var ch = source.next();
39 if (specialRE.test(ch)) {
39 if (specialRE.test(ch)) {
40 if (ch == '{' && source.eat('-')) {
40 if (ch == '{' && source.eat('-')) {
41 var t = "comment";
41 var t = "comment";
42 if (source.eat('#')) t = "meta";
42 if (source.eat('#')) t = "meta";
43 return switchState(source, setState, ncomment(t, 1));
43 return switchState(source, setState, ncomment(t, 1));
44 }
44 }
45 return null;
45 return null;
46 }
46 }
47
47
48 if (ch == '\'') {
48 if (ch == '\'') {
49 if (source.eat('\\'))
49 if (source.eat('\\'))
50 source.next(); // should handle other escapes here
50 source.next(); // should handle other escapes here
51 else
51 else
52 source.next();
52 source.next();
53
53
54 if (source.eat('\''))
54 if (source.eat('\''))
55 return "string";
55 return "string";
56 return "error";
56 return "error";
57 }
57 }
58
58
59 if (ch == '"') {
59 if (ch == '"') {
60 return switchState(source, setState, stringLiteral);
60 return switchState(source, setState, stringLiteral);
61 }
61 }
62
62
63 if (largeRE.test(ch)) {
63 if (largeRE.test(ch)) {
64 source.eatWhile(idRE);
64 source.eatWhile(idRE);
65 if (source.eat('.'))
65 if (source.eat('.'))
66 return "qualifier";
66 return "qualifier";
67 return "variable-2";
67 return "variable-2";
68 }
68 }
69
69
70 if (smallRE.test(ch)) {
70 if (smallRE.test(ch)) {
71 var isDef = source.pos === 1;
71 var isDef = source.pos === 1;
72 source.eatWhile(idRE);
72 source.eatWhile(idRE);
73 return isDef ? "variable-3" : "variable";
73 return isDef ? "type" : "variable";
74 }
74 }
75
75
76 if (digitRE.test(ch)) {
76 if (digitRE.test(ch)) {
77 if (ch == '0') {
77 if (ch == '0') {
78 if (source.eat(/[xX]/)) {
78 if (source.eat(/[xX]/)) {
79 source.eatWhile(hexitRE); // should require at least 1
79 source.eatWhile(hexitRE); // should require at least 1
80 return "integer";
80 return "integer";
81 }
81 }
82 if (source.eat(/[oO]/)) {
82 if (source.eat(/[oO]/)) {
83 source.eatWhile(octitRE); // should require at least 1
83 source.eatWhile(octitRE); // should require at least 1
84 return "number";
84 return "number";
85 }
85 }
86 }
86 }
87 source.eatWhile(digitRE);
87 source.eatWhile(digitRE);
88 var t = "number";
88 var t = "number";
89 if (source.eat('.')) {
89 if (source.eat('.')) {
90 t = "number";
90 t = "number";
91 source.eatWhile(digitRE); // should require at least 1
91 source.eatWhile(digitRE); // should require at least 1
92 }
92 }
93 if (source.eat(/[eE]/)) {
93 if (source.eat(/[eE]/)) {
94 t = "number";
94 t = "number";
95 source.eat(/[-+]/);
95 source.eat(/[-+]/);
96 source.eatWhile(digitRE); // should require at least 1
96 source.eatWhile(digitRE); // should require at least 1
97 }
97 }
98 return t;
98 return t;
99 }
99 }
100
100
101 if (symbolRE.test(ch)) {
101 if (symbolRE.test(ch)) {
102 if (ch == '-' && source.eat(/-/)) {
102 if (ch == '-' && source.eat(/-/)) {
103 source.eatWhile(/-/);
103 source.eatWhile(/-/);
104 if (!source.eat(symbolRE)) {
104 if (!source.eat(symbolRE)) {
105 source.skipToEnd();
105 source.skipToEnd();
106 return "comment";
106 return "comment";
107 }
107 }
108 }
108 }
109 source.eatWhile(symbolRE);
109 source.eatWhile(symbolRE);
110 return "builtin";
110 return "builtin";
111 }
111 }
112
112
113 return "error";
113 return "error";
114 }
114 }
115 }
115 }
116
116
117 function ncomment(type, nest) {
117 function ncomment(type, nest) {
118 if (nest == 0) {
118 if (nest == 0) {
119 return normal();
119 return normal();
120 }
120 }
121 return function(source, setState) {
121 return function(source, setState) {
122 var currNest = nest;
122 var currNest = nest;
123 while (!source.eol()) {
123 while (!source.eol()) {
124 var ch = source.next();
124 var ch = source.next();
125 if (ch == '{' && source.eat('-')) {
125 if (ch == '{' && source.eat('-')) {
126 ++currNest;
126 ++currNest;
127 } else if (ch == '-' && source.eat('}')) {
127 } else if (ch == '-' && source.eat('}')) {
128 --currNest;
128 --currNest;
129 if (currNest == 0) {
129 if (currNest == 0) {
130 setState(normal());
130 setState(normal());
131 return type;
131 return type;
132 }
132 }
133 }
133 }
134 }
134 }
135 setState(ncomment(type, currNest));
135 setState(ncomment(type, currNest));
136 return type;
136 return type;
137 }
137 }
138 }
138 }
139
139
140 function stringLiteral(source, setState) {
140 function stringLiteral(source, setState) {
141 while (!source.eol()) {
141 while (!source.eol()) {
142 var ch = source.next();
142 var ch = source.next();
143 if (ch == '"') {
143 if (ch == '"') {
144 setState(normal());
144 setState(normal());
145 return "string";
145 return "string";
146 }
146 }
147 if (ch == '\\') {
147 if (ch == '\\') {
148 if (source.eol() || source.eat(whiteCharRE)) {
148 if (source.eol() || source.eat(whiteCharRE)) {
149 setState(stringGap);
149 setState(stringGap);
150 return "string";
150 return "string";
151 }
151 }
152 if (!source.eat('&')) source.next(); // should handle other escapes here
152 if (!source.eat('&')) source.next(); // should handle other escapes here
153 }
153 }
154 }
154 }
155 setState(normal());
155 setState(normal());
156 return "error";
156 return "error";
157 }
157 }
158
158
159 function stringGap(source, setState) {
159 function stringGap(source, setState) {
160 if (source.eat('\\')) {
160 if (source.eat('\\')) {
161 return switchState(source, setState, stringLiteral);
161 return switchState(source, setState, stringLiteral);
162 }
162 }
163 source.next();
163 source.next();
164 setState(normal());
164 setState(normal());
165 return "error";
165 return "error";
166 }
166 }
167
167
168
168
169 var wellKnownWords = (function() {
169 var wellKnownWords = (function() {
170 var wkw = {};
170 var wkw = {};
171
171
172 var keywords = [
172 var keywords = [
173 "case", "of", "as",
173 "case", "of", "as",
174 "if", "then", "else",
174 "if", "then", "else",
175 "let", "in",
175 "let", "in",
176 "infix", "infixl", "infixr",
176 "infix", "infixl", "infixr",
177 "type", "alias",
177 "type", "alias",
178 "input", "output", "foreign", "loopback",
178 "input", "output", "foreign", "loopback",
179 "module", "where", "import", "exposing",
179 "module", "where", "import", "exposing",
180 "_", "..", "|", ":", "=", "\\", "\"", "->", "<-"
180 "_", "..", "|", ":", "=", "\\", "\"", "->", "<-"
181 ];
181 ];
182
182
183 for (var i = keywords.length; i--;)
183 for (var i = keywords.length; i--;)
184 wkw[keywords[i]] = "keyword";
184 wkw[keywords[i]] = "keyword";
185
185
186 return wkw;
186 return wkw;
187 })();
187 })();
188
188
189
189
190
190
191 return {
191 return {
192 startState: function () { return { f: normal() }; },
192 startState: function () { return { f: normal() }; },
193 copyState: function (s) { return { f: s.f }; },
193 copyState: function (s) { return { f: s.f }; },
194
194
195 token: function(stream, state) {
195 token: function(stream, state) {
196 var t = state.f(stream, function(s) { state.f = s; });
196 var t = state.f(stream, function(s) { state.f = s; });
197 var w = stream.current();
197 var w = stream.current();
198 return (wellKnownWords.hasOwnProperty(w)) ? wellKnownWords[w] : t;
198 return (wellKnownWords.hasOwnProperty(w)) ? wellKnownWords[w] : t;
199 }
199 }
200 };
200 };
201
201
202 });
202 });
203
203
204 CodeMirror.defineMIME("text/x-elm", "elm");
204 CodeMirror.defineMIME("text/x-elm", "elm");
205 });
205 });
@@ -1,618 +1,619 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 /*jshint unused:true, eqnull:true, curly:true, bitwise:true */
4 /*jshint unused:true, eqnull:true, curly:true, bitwise:true */
5 /*jshint undef:true, latedef:true, trailing:true */
5 /*jshint undef:true, latedef:true, trailing:true */
6 /*global CodeMirror:true */
6 /*global CodeMirror:true */
7
7
8 // erlang mode.
8 // erlang mode.
9 // tokenizer -> token types -> CodeMirror styles
9 // tokenizer -> token types -> CodeMirror styles
10 // tokenizer maintains a parse stack
10 // tokenizer maintains a parse stack
11 // indenter uses the parse stack
11 // indenter uses the parse stack
12
12
13 // TODO indenter:
13 // TODO indenter:
14 // bit syntax
14 // bit syntax
15 // old guard/bif/conversion clashes (e.g. "float/1")
15 // old guard/bif/conversion clashes (e.g. "float/1")
16 // type/spec/opaque
16 // type/spec/opaque
17
17
18 (function(mod) {
18 (function(mod) {
19 if (typeof exports == "object" && typeof module == "object") // CommonJS
19 if (typeof exports == "object" && typeof module == "object") // CommonJS
20 mod(require("../../lib/codemirror"));
20 mod(require("../../lib/codemirror"));
21 else if (typeof define == "function" && define.amd) // AMD
21 else if (typeof define == "function" && define.amd) // AMD
22 define(["../../lib/codemirror"], mod);
22 define(["../../lib/codemirror"], mod);
23 else // Plain browser env
23 else // Plain browser env
24 mod(CodeMirror);
24 mod(CodeMirror);
25 })(function(CodeMirror) {
25 })(function(CodeMirror) {
26 "use strict";
26 "use strict";
27
27
28 CodeMirror.defineMIME("text/x-erlang", "erlang");
28 CodeMirror.defineMIME("text/x-erlang", "erlang");
29
29
30 CodeMirror.defineMode("erlang", function(cmCfg) {
30 CodeMirror.defineMode("erlang", function(cmCfg) {
31 "use strict";
31 "use strict";
32
32
33 /////////////////////////////////////////////////////////////////////////////
33 /////////////////////////////////////////////////////////////////////////////
34 // constants
34 // constants
35
35
36 var typeWords = [
36 var typeWords = [
37 "-type", "-spec", "-export_type", "-opaque"];
37 "-type", "-spec", "-export_type", "-opaque"];
38
38
39 var keywordWords = [
39 var keywordWords = [
40 "after","begin","catch","case","cond","end","fun","if",
40 "after","begin","catch","case","cond","end","fun","if",
41 "let","of","query","receive","try","when"];
41 "let","of","query","receive","try","when"];
42
42
43 var separatorRE = /[\->,;]/;
43 var separatorRE = /[\->,;]/;
44 var separatorWords = [
44 var separatorWords = [
45 "->",";",","];
45 "->",";",","];
46
46
47 var operatorAtomWords = [
47 var operatorAtomWords = [
48 "and","andalso","band","bnot","bor","bsl","bsr","bxor",
48 "and","andalso","band","bnot","bor","bsl","bsr","bxor",
49 "div","not","or","orelse","rem","xor"];
49 "div","not","or","orelse","rem","xor"];
50
50
51 var operatorSymbolRE = /[\+\-\*\/<>=\|:!]/;
51 var operatorSymbolRE = /[\+\-\*\/<>=\|:!]/;
52 var operatorSymbolWords = [
52 var operatorSymbolWords = [
53 "=","+","-","*","/",">",">=","<","=<","=:=","==","=/=","/=","||","<-","!"];
53 "=","+","-","*","/",">",">=","<","=<","=:=","==","=/=","/=","||","<-","!"];
54
54
55 var openParenRE = /[<\(\[\{]/;
55 var openParenRE = /[<\(\[\{]/;
56 var openParenWords = [
56 var openParenWords = [
57 "<<","(","[","{"];
57 "<<","(","[","{"];
58
58
59 var closeParenRE = /[>\)\]\}]/;
59 var closeParenRE = /[>\)\]\}]/;
60 var closeParenWords = [
60 var closeParenWords = [
61 "}","]",")",">>"];
61 "}","]",")",">>"];
62
62
63 var guardWords = [
63 var guardWords = [
64 "is_atom","is_binary","is_bitstring","is_boolean","is_float",
64 "is_atom","is_binary","is_bitstring","is_boolean","is_float",
65 "is_function","is_integer","is_list","is_number","is_pid",
65 "is_function","is_integer","is_list","is_number","is_pid",
66 "is_port","is_record","is_reference","is_tuple",
66 "is_port","is_record","is_reference","is_tuple",
67 "atom","binary","bitstring","boolean","function","integer","list",
67 "atom","binary","bitstring","boolean","function","integer","list",
68 "number","pid","port","record","reference","tuple"];
68 "number","pid","port","record","reference","tuple"];
69
69
70 var bifWords = [
70 var bifWords = [
71 "abs","adler32","adler32_combine","alive","apply","atom_to_binary",
71 "abs","adler32","adler32_combine","alive","apply","atom_to_binary",
72 "atom_to_list","binary_to_atom","binary_to_existing_atom",
72 "atom_to_list","binary_to_atom","binary_to_existing_atom",
73 "binary_to_list","binary_to_term","bit_size","bitstring_to_list",
73 "binary_to_list","binary_to_term","bit_size","bitstring_to_list",
74 "byte_size","check_process_code","contact_binary","crc32",
74 "byte_size","check_process_code","contact_binary","crc32",
75 "crc32_combine","date","decode_packet","delete_module",
75 "crc32_combine","date","decode_packet","delete_module",
76 "disconnect_node","element","erase","exit","float","float_to_list",
76 "disconnect_node","element","erase","exit","float","float_to_list",
77 "garbage_collect","get","get_keys","group_leader","halt","hd",
77 "garbage_collect","get","get_keys","group_leader","halt","hd",
78 "integer_to_list","internal_bif","iolist_size","iolist_to_binary",
78 "integer_to_list","internal_bif","iolist_size","iolist_to_binary",
79 "is_alive","is_atom","is_binary","is_bitstring","is_boolean",
79 "is_alive","is_atom","is_binary","is_bitstring","is_boolean",
80 "is_float","is_function","is_integer","is_list","is_number","is_pid",
80 "is_float","is_function","is_integer","is_list","is_number","is_pid",
81 "is_port","is_process_alive","is_record","is_reference","is_tuple",
81 "is_port","is_process_alive","is_record","is_reference","is_tuple",
82 "length","link","list_to_atom","list_to_binary","list_to_bitstring",
82 "length","link","list_to_atom","list_to_binary","list_to_bitstring",
83 "list_to_existing_atom","list_to_float","list_to_integer",
83 "list_to_existing_atom","list_to_float","list_to_integer",
84 "list_to_pid","list_to_tuple","load_module","make_ref","module_loaded",
84 "list_to_pid","list_to_tuple","load_module","make_ref","module_loaded",
85 "monitor_node","node","node_link","node_unlink","nodes","notalive",
85 "monitor_node","node","node_link","node_unlink","nodes","notalive",
86 "now","open_port","pid_to_list","port_close","port_command",
86 "now","open_port","pid_to_list","port_close","port_command",
87 "port_connect","port_control","pre_loaded","process_flag",
87 "port_connect","port_control","pre_loaded","process_flag",
88 "process_info","processes","purge_module","put","register",
88 "process_info","processes","purge_module","put","register",
89 "registered","round","self","setelement","size","spawn","spawn_link",
89 "registered","round","self","setelement","size","spawn","spawn_link",
90 "spawn_monitor","spawn_opt","split_binary","statistics",
90 "spawn_monitor","spawn_opt","split_binary","statistics",
91 "term_to_binary","time","throw","tl","trunc","tuple_size",
91 "term_to_binary","time","throw","tl","trunc","tuple_size",
92 "tuple_to_list","unlink","unregister","whereis"];
92 "tuple_to_list","unlink","unregister","whereis"];
93
93
94 // upper case: [A-Z] [Ø-Þ] [À-Ö]
94 // upper case: [A-Z] [Ø-Þ] [À-Ö]
95 // lower case: [a-z] [ß-ö] [ø-ÿ]
95 // lower case: [a-z] [ß-ö] [ø-ÿ]
96 var anumRE = /[\w@Ø-ÞÀ-Öß-öø-ÿ]/;
96 var anumRE = /[\w@Ø-ÞÀ-Öß-öø-ÿ]/;
97 var escapesRE =
97 var escapesRE =
98 /[0-7]{1,3}|[bdefnrstv\\"']|\^[a-zA-Z]|x[0-9a-zA-Z]{2}|x{[0-9a-zA-Z]+}/;
98 /[0-7]{1,3}|[bdefnrstv\\"']|\^[a-zA-Z]|x[0-9a-zA-Z]{2}|x{[0-9a-zA-Z]+}/;
99
99
100 /////////////////////////////////////////////////////////////////////////////
100 /////////////////////////////////////////////////////////////////////////////
101 // tokenizer
101 // tokenizer
102
102
103 function tokenizer(stream,state) {
103 function tokenizer(stream,state) {
104 // in multi-line string
104 // in multi-line string
105 if (state.in_string) {
105 if (state.in_string) {
106 state.in_string = (!doubleQuote(stream));
106 state.in_string = (!doubleQuote(stream));
107 return rval(state,stream,"string");
107 return rval(state,stream,"string");
108 }
108 }
109
109
110 // in multi-line atom
110 // in multi-line atom
111 if (state.in_atom) {
111 if (state.in_atom) {
112 state.in_atom = (!singleQuote(stream));
112 state.in_atom = (!singleQuote(stream));
113 return rval(state,stream,"atom");
113 return rval(state,stream,"atom");
114 }
114 }
115
115
116 // whitespace
116 // whitespace
117 if (stream.eatSpace()) {
117 if (stream.eatSpace()) {
118 return rval(state,stream,"whitespace");
118 return rval(state,stream,"whitespace");
119 }
119 }
120
120
121 // attributes and type specs
121 // attributes and type specs
122 if (!peekToken(state) &&
122 if (!peekToken(state) &&
123 stream.match(/-\s*[a-zß-öø-ÿ][\wØ-ÞÀ-Öß-öø-ÿ]*/)) {
123 stream.match(/-\s*[a-zß-öø-ÿ][\wØ-ÞÀ-Öß-öø-ÿ]*/)) {
124 if (is_member(stream.current(),typeWords)) {
124 if (is_member(stream.current(),typeWords)) {
125 return rval(state,stream,"type");
125 return rval(state,stream,"type");
126 }else{
126 }else{
127 return rval(state,stream,"attribute");
127 return rval(state,stream,"attribute");
128 }
128 }
129 }
129 }
130
130
131 var ch = stream.next();
131 var ch = stream.next();
132
132
133 // comment
133 // comment
134 if (ch == '%') {
134 if (ch == '%') {
135 stream.skipToEnd();
135 stream.skipToEnd();
136 return rval(state,stream,"comment");
136 return rval(state,stream,"comment");
137 }
137 }
138
138
139 // colon
139 // colon
140 if (ch == ":") {
140 if (ch == ":") {
141 return rval(state,stream,"colon");
141 return rval(state,stream,"colon");
142 }
142 }
143
143
144 // macro
144 // macro
145 if (ch == '?') {
145 if (ch == '?') {
146 stream.eatSpace();
146 stream.eatSpace();
147 stream.eatWhile(anumRE);
147 stream.eatWhile(anumRE);
148 return rval(state,stream,"macro");
148 return rval(state,stream,"macro");
149 }
149 }
150
150
151 // record
151 // record
152 if (ch == "#") {
152 if (ch == "#") {
153 stream.eatSpace();
153 stream.eatSpace();
154 stream.eatWhile(anumRE);
154 stream.eatWhile(anumRE);
155 return rval(state,stream,"record");
155 return rval(state,stream,"record");
156 }
156 }
157
157
158 // dollar escape
158 // dollar escape
159 if (ch == "$") {
159 if (ch == "$") {
160 if (stream.next() == "\\" && !stream.match(escapesRE)) {
160 if (stream.next() == "\\" && !stream.match(escapesRE)) {
161 return rval(state,stream,"error");
161 return rval(state,stream,"error");
162 }
162 }
163 return rval(state,stream,"number");
163 return rval(state,stream,"number");
164 }
164 }
165
165
166 // dot
166 // dot
167 if (ch == ".") {
167 if (ch == ".") {
168 return rval(state,stream,"dot");
168 return rval(state,stream,"dot");
169 }
169 }
170
170
171 // quoted atom
171 // quoted atom
172 if (ch == '\'') {
172 if (ch == '\'') {
173 if (!(state.in_atom = (!singleQuote(stream)))) {
173 if (!(state.in_atom = (!singleQuote(stream)))) {
174 if (stream.match(/\s*\/\s*[0-9]/,false)) {
174 if (stream.match(/\s*\/\s*[0-9]/,false)) {
175 stream.match(/\s*\/\s*[0-9]/,true);
175 stream.match(/\s*\/\s*[0-9]/,true);
176 return rval(state,stream,"fun"); // 'f'/0 style fun
176 return rval(state,stream,"fun"); // 'f'/0 style fun
177 }
177 }
178 if (stream.match(/\s*\(/,false) || stream.match(/\s*:/,false)) {
178 if (stream.match(/\s*\(/,false) || stream.match(/\s*:/,false)) {
179 return rval(state,stream,"function");
179 return rval(state,stream,"function");
180 }
180 }
181 }
181 }
182 return rval(state,stream,"atom");
182 return rval(state,stream,"atom");
183 }
183 }
184
184
185 // string
185 // string
186 if (ch == '"') {
186 if (ch == '"') {
187 state.in_string = (!doubleQuote(stream));
187 state.in_string = (!doubleQuote(stream));
188 return rval(state,stream,"string");
188 return rval(state,stream,"string");
189 }
189 }
190
190
191 // variable
191 // variable
192 if (/[A-Z_Ø-ÞÀ-Ö]/.test(ch)) {
192 if (/[A-Z_Ø-ÞÀ-Ö]/.test(ch)) {
193 stream.eatWhile(anumRE);
193 stream.eatWhile(anumRE);
194 return rval(state,stream,"variable");
194 return rval(state,stream,"variable");
195 }
195 }
196
196
197 // atom/keyword/BIF/function
197 // atom/keyword/BIF/function
198 if (/[a-z_ß-öø-ÿ]/.test(ch)) {
198 if (/[a-z_ß-öø-ÿ]/.test(ch)) {
199 stream.eatWhile(anumRE);
199 stream.eatWhile(anumRE);
200
200
201 if (stream.match(/\s*\/\s*[0-9]/,false)) {
201 if (stream.match(/\s*\/\s*[0-9]/,false)) {
202 stream.match(/\s*\/\s*[0-9]/,true);
202 stream.match(/\s*\/\s*[0-9]/,true);
203 return rval(state,stream,"fun"); // f/0 style fun
203 return rval(state,stream,"fun"); // f/0 style fun
204 }
204 }
205
205
206 var w = stream.current();
206 var w = stream.current();
207
207
208 if (is_member(w,keywordWords)) {
208 if (is_member(w,keywordWords)) {
209 return rval(state,stream,"keyword");
209 return rval(state,stream,"keyword");
210 }else if (is_member(w,operatorAtomWords)) {
210 }else if (is_member(w,operatorAtomWords)) {
211 return rval(state,stream,"operator");
211 return rval(state,stream,"operator");
212 }else if (stream.match(/\s*\(/,false)) {
212 }else if (stream.match(/\s*\(/,false)) {
213 // 'put' and 'erlang:put' are bifs, 'foo:put' is not
213 // 'put' and 'erlang:put' are bifs, 'foo:put' is not
214 if (is_member(w,bifWords) &&
214 if (is_member(w,bifWords) &&
215 ((peekToken(state).token != ":") ||
215 ((peekToken(state).token != ":") ||
216 (peekToken(state,2).token == "erlang"))) {
216 (peekToken(state,2).token == "erlang"))) {
217 return rval(state,stream,"builtin");
217 return rval(state,stream,"builtin");
218 }else if (is_member(w,guardWords)) {
218 }else if (is_member(w,guardWords)) {
219 return rval(state,stream,"guard");
219 return rval(state,stream,"guard");
220 }else{
220 }else{
221 return rval(state,stream,"function");
221 return rval(state,stream,"function");
222 }
222 }
223 }else if (lookahead(stream) == ":") {
223 }else if (lookahead(stream) == ":") {
224 if (w == "erlang") {
224 if (w == "erlang") {
225 return rval(state,stream,"builtin");
225 return rval(state,stream,"builtin");
226 } else {
226 } else {
227 return rval(state,stream,"function");
227 return rval(state,stream,"function");
228 }
228 }
229 }else if (is_member(w,["true","false"])) {
229 }else if (is_member(w,["true","false"])) {
230 return rval(state,stream,"boolean");
230 return rval(state,stream,"boolean");
231 }else{
231 }else{
232 return rval(state,stream,"atom");
232 return rval(state,stream,"atom");
233 }
233 }
234 }
234 }
235
235
236 // number
236 // number
237 var digitRE = /[0-9]/;
237 var digitRE = /[0-9]/;
238 var radixRE = /[0-9a-zA-Z]/; // 36#zZ style int
238 var radixRE = /[0-9a-zA-Z]/; // 36#zZ style int
239 if (digitRE.test(ch)) {
239 if (digitRE.test(ch)) {
240 stream.eatWhile(digitRE);
240 stream.eatWhile(digitRE);
241 if (stream.eat('#')) { // 36#aZ style integer
241 if (stream.eat('#')) { // 36#aZ style integer
242 if (!stream.eatWhile(radixRE)) {
242 if (!stream.eatWhile(radixRE)) {
243 stream.backUp(1); //"36#" - syntax error
243 stream.backUp(1); //"36#" - syntax error
244 }
244 }
245 } else if (stream.eat('.')) { // float
245 } else if (stream.eat('.')) { // float
246 if (!stream.eatWhile(digitRE)) {
246 if (!stream.eatWhile(digitRE)) {
247 stream.backUp(1); // "3." - probably end of function
247 stream.backUp(1); // "3." - probably end of function
248 } else {
248 } else {
249 if (stream.eat(/[eE]/)) { // float with exponent
249 if (stream.eat(/[eE]/)) { // float with exponent
250 if (stream.eat(/[-+]/)) {
250 if (stream.eat(/[-+]/)) {
251 if (!stream.eatWhile(digitRE)) {
251 if (!stream.eatWhile(digitRE)) {
252 stream.backUp(2); // "2e-" - syntax error
252 stream.backUp(2); // "2e-" - syntax error
253 }
253 }
254 } else {
254 } else {
255 if (!stream.eatWhile(digitRE)) {
255 if (!stream.eatWhile(digitRE)) {
256 stream.backUp(1); // "2e" - syntax error
256 stream.backUp(1); // "2e" - syntax error
257 }
257 }
258 }
258 }
259 }
259 }
260 }
260 }
261 }
261 }
262 return rval(state,stream,"number"); // normal integer
262 return rval(state,stream,"number"); // normal integer
263 }
263 }
264
264
265 // open parens
265 // open parens
266 if (nongreedy(stream,openParenRE,openParenWords)) {
266 if (nongreedy(stream,openParenRE,openParenWords)) {
267 return rval(state,stream,"open_paren");
267 return rval(state,stream,"open_paren");
268 }
268 }
269
269
270 // close parens
270 // close parens
271 if (nongreedy(stream,closeParenRE,closeParenWords)) {
271 if (nongreedy(stream,closeParenRE,closeParenWords)) {
272 return rval(state,stream,"close_paren");
272 return rval(state,stream,"close_paren");
273 }
273 }
274
274
275 // separators
275 // separators
276 if (greedy(stream,separatorRE,separatorWords)) {
276 if (greedy(stream,separatorRE,separatorWords)) {
277 return rval(state,stream,"separator");
277 return rval(state,stream,"separator");
278 }
278 }
279
279
280 // operators
280 // operators
281 if (greedy(stream,operatorSymbolRE,operatorSymbolWords)) {
281 if (greedy(stream,operatorSymbolRE,operatorSymbolWords)) {
282 return rval(state,stream,"operator");
282 return rval(state,stream,"operator");
283 }
283 }
284
284
285 return rval(state,stream,null);
285 return rval(state,stream,null);
286 }
286 }
287
287
288 /////////////////////////////////////////////////////////////////////////////
288 /////////////////////////////////////////////////////////////////////////////
289 // utilities
289 // utilities
290 function nongreedy(stream,re,words) {
290 function nongreedy(stream,re,words) {
291 if (stream.current().length == 1 && re.test(stream.current())) {
291 if (stream.current().length == 1 && re.test(stream.current())) {
292 stream.backUp(1);
292 stream.backUp(1);
293 while (re.test(stream.peek())) {
293 while (re.test(stream.peek())) {
294 stream.next();
294 stream.next();
295 if (is_member(stream.current(),words)) {
295 if (is_member(stream.current(),words)) {
296 return true;
296 return true;
297 }
297 }
298 }
298 }
299 stream.backUp(stream.current().length-1);
299 stream.backUp(stream.current().length-1);
300 }
300 }
301 return false;
301 return false;
302 }
302 }
303
303
304 function greedy(stream,re,words) {
304 function greedy(stream,re,words) {
305 if (stream.current().length == 1 && re.test(stream.current())) {
305 if (stream.current().length == 1 && re.test(stream.current())) {
306 while (re.test(stream.peek())) {
306 while (re.test(stream.peek())) {
307 stream.next();
307 stream.next();
308 }
308 }
309 while (0 < stream.current().length) {
309 while (0 < stream.current().length) {
310 if (is_member(stream.current(),words)) {
310 if (is_member(stream.current(),words)) {
311 return true;
311 return true;
312 }else{
312 }else{
313 stream.backUp(1);
313 stream.backUp(1);
314 }
314 }
315 }
315 }
316 stream.next();
316 stream.next();
317 }
317 }
318 return false;
318 return false;
319 }
319 }
320
320
321 function doubleQuote(stream) {
321 function doubleQuote(stream) {
322 return quote(stream, '"', '\\');
322 return quote(stream, '"', '\\');
323 }
323 }
324
324
325 function singleQuote(stream) {
325 function singleQuote(stream) {
326 return quote(stream,'\'','\\');
326 return quote(stream,'\'','\\');
327 }
327 }
328
328
329 function quote(stream,quoteChar,escapeChar) {
329 function quote(stream,quoteChar,escapeChar) {
330 while (!stream.eol()) {
330 while (!stream.eol()) {
331 var ch = stream.next();
331 var ch = stream.next();
332 if (ch == quoteChar) {
332 if (ch == quoteChar) {
333 return true;
333 return true;
334 }else if (ch == escapeChar) {
334 }else if (ch == escapeChar) {
335 stream.next();
335 stream.next();
336 }
336 }
337 }
337 }
338 return false;
338 return false;
339 }
339 }
340
340
341 function lookahead(stream) {
341 function lookahead(stream) {
342 var m = stream.match(/([\n\s]+|%[^\n]*\n)*(.)/,false);
342 var m = stream.match(/([\n\s]+|%[^\n]*\n)*(.)/,false);
343 return m ? m.pop() : "";
343 return m ? m.pop() : "";
344 }
344 }
345
345
346 function is_member(element,list) {
346 function is_member(element,list) {
347 return (-1 < list.indexOf(element));
347 return (-1 < list.indexOf(element));
348 }
348 }
349
349
350 function rval(state,stream,type) {
350 function rval(state,stream,type) {
351
351
352 // parse stack
352 // parse stack
353 pushToken(state,realToken(type,stream));
353 pushToken(state,realToken(type,stream));
354
354
355 // map erlang token type to CodeMirror style class
355 // map erlang token type to CodeMirror style class
356 // erlang -> CodeMirror tag
356 // erlang -> CodeMirror tag
357 switch (type) {
357 switch (type) {
358 case "atom": return "atom";
358 case "atom": return "atom";
359 case "attribute": return "attribute";
359 case "attribute": return "attribute";
360 case "boolean": return "atom";
360 case "boolean": return "atom";
361 case "builtin": return "builtin";
361 case "builtin": return "builtin";
362 case "close_paren": return null;
362 case "close_paren": return null;
363 case "colon": return null;
363 case "colon": return null;
364 case "comment": return "comment";
364 case "comment": return "comment";
365 case "dot": return null;
365 case "dot": return null;
366 case "error": return "error";
366 case "error": return "error";
367 case "fun": return "meta";
367 case "fun": return "meta";
368 case "function": return "tag";
368 case "function": return "tag";
369 case "guard": return "property";
369 case "guard": return "property";
370 case "keyword": return "keyword";
370 case "keyword": return "keyword";
371 case "macro": return "variable-2";
371 case "macro": return "variable-2";
372 case "number": return "number";
372 case "number": return "number";
373 case "open_paren": return null;
373 case "open_paren": return null;
374 case "operator": return "operator";
374 case "operator": return "operator";
375 case "record": return "bracket";
375 case "record": return "bracket";
376 case "separator": return null;
376 case "separator": return null;
377 case "string": return "string";
377 case "string": return "string";
378 case "type": return "def";
378 case "type": return "def";
379 case "variable": return "variable";
379 case "variable": return "variable";
380 default: return null;
380 default: return null;
381 }
381 }
382 }
382 }
383
383
384 function aToken(tok,col,ind,typ) {
384 function aToken(tok,col,ind,typ) {
385 return {token: tok,
385 return {token: tok,
386 column: col,
386 column: col,
387 indent: ind,
387 indent: ind,
388 type: typ};
388 type: typ};
389 }
389 }
390
390
391 function realToken(type,stream) {
391 function realToken(type,stream) {
392 return aToken(stream.current(),
392 return aToken(stream.current(),
393 stream.column(),
393 stream.column(),
394 stream.indentation(),
394 stream.indentation(),
395 type);
395 type);
396 }
396 }
397
397
398 function fakeToken(type) {
398 function fakeToken(type) {
399 return aToken(type,0,0,type);
399 return aToken(type,0,0,type);
400 }
400 }
401
401
402 function peekToken(state,depth) {
402 function peekToken(state,depth) {
403 var len = state.tokenStack.length;
403 var len = state.tokenStack.length;
404 var dep = (depth ? depth : 1);
404 var dep = (depth ? depth : 1);
405
405
406 if (len < dep) {
406 if (len < dep) {
407 return false;
407 return false;
408 }else{
408 }else{
409 return state.tokenStack[len-dep];
409 return state.tokenStack[len-dep];
410 }
410 }
411 }
411 }
412
412
413 function pushToken(state,token) {
413 function pushToken(state,token) {
414
414
415 if (!(token.type == "comment" || token.type == "whitespace")) {
415 if (!(token.type == "comment" || token.type == "whitespace")) {
416 state.tokenStack = maybe_drop_pre(state.tokenStack,token);
416 state.tokenStack = maybe_drop_pre(state.tokenStack,token);
417 state.tokenStack = maybe_drop_post(state.tokenStack);
417 state.tokenStack = maybe_drop_post(state.tokenStack);
418 }
418 }
419 }
419 }
420
420
421 function maybe_drop_pre(s,token) {
421 function maybe_drop_pre(s,token) {
422 var last = s.length-1;
422 var last = s.length-1;
423
423
424 if (0 < last && s[last].type === "record" && token.type === "dot") {
424 if (0 < last && s[last].type === "record" && token.type === "dot") {
425 s.pop();
425 s.pop();
426 }else if (0 < last && s[last].type === "group") {
426 }else if (0 < last && s[last].type === "group") {
427 s.pop();
427 s.pop();
428 s.push(token);
428 s.push(token);
429 }else{
429 }else{
430 s.push(token);
430 s.push(token);
431 }
431 }
432 return s;
432 return s;
433 }
433 }
434
434
435 function maybe_drop_post(s) {
435 function maybe_drop_post(s) {
436 if (!s.length) return s
436 var last = s.length-1;
437 var last = s.length-1;
437
438
438 if (s[last].type === "dot") {
439 if (s[last].type === "dot") {
439 return [];
440 return [];
440 }
441 }
441 if (s[last].type === "fun" && s[last-1].token === "fun") {
442 if (last > 1 && s[last].type === "fun" && s[last-1].token === "fun") {
442 return s.slice(0,last-1);
443 return s.slice(0,last-1);
443 }
444 }
444 switch (s[s.length-1].token) {
445 switch (s[last].token) {
445 case "}": return d(s,{g:["{"]});
446 case "}": return d(s,{g:["{"]});
446 case "]": return d(s,{i:["["]});
447 case "]": return d(s,{i:["["]});
447 case ")": return d(s,{i:["("]});
448 case ")": return d(s,{i:["("]});
448 case ">>": return d(s,{i:["<<"]});
449 case ">>": return d(s,{i:["<<"]});
449 case "end": return d(s,{i:["begin","case","fun","if","receive","try"]});
450 case "end": return d(s,{i:["begin","case","fun","if","receive","try"]});
450 case ",": return d(s,{e:["begin","try","when","->",
451 case ",": return d(s,{e:["begin","try","when","->",
451 ",","(","[","{","<<"]});
452 ",","(","[","{","<<"]});
452 case "->": return d(s,{r:["when"],
453 case "->": return d(s,{r:["when"],
453 m:["try","if","case","receive"]});
454 m:["try","if","case","receive"]});
454 case ";": return d(s,{E:["case","fun","if","receive","try","when"]});
455 case ";": return d(s,{E:["case","fun","if","receive","try","when"]});
455 case "catch":return d(s,{e:["try"]});
456 case "catch":return d(s,{e:["try"]});
456 case "of": return d(s,{e:["case"]});
457 case "of": return d(s,{e:["case"]});
457 case "after":return d(s,{e:["receive","try"]});
458 case "after":return d(s,{e:["receive","try"]});
458 default: return s;
459 default: return s;
459 }
460 }
460 }
461 }
461
462
462 function d(stack,tt) {
463 function d(stack,tt) {
463 // stack is a stack of Token objects.
464 // stack is a stack of Token objects.
464 // tt is an object; {type:tokens}
465 // tt is an object; {type:tokens}
465 // type is a char, tokens is a list of token strings.
466 // type is a char, tokens is a list of token strings.
466 // The function returns (possibly truncated) stack.
467 // The function returns (possibly truncated) stack.
467 // It will descend the stack, looking for a Token such that Token.token
468 // It will descend the stack, looking for a Token such that Token.token
468 // is a member of tokens. If it does not find that, it will normally (but
469 // is a member of tokens. If it does not find that, it will normally (but
469 // see "E" below) return stack. If it does find a match, it will remove
470 // see "E" below) return stack. If it does find a match, it will remove
470 // all the Tokens between the top and the matched Token.
471 // all the Tokens between the top and the matched Token.
471 // If type is "m", that is all it does.
472 // If type is "m", that is all it does.
472 // If type is "i", it will also remove the matched Token and the top Token.
473 // If type is "i", it will also remove the matched Token and the top Token.
473 // If type is "g", like "i", but add a fake "group" token at the top.
474 // If type is "g", like "i", but add a fake "group" token at the top.
474 // If type is "r", it will remove the matched Token, but not the top Token.
475 // If type is "r", it will remove the matched Token, but not the top Token.
475 // If type is "e", it will keep the matched Token but not the top Token.
476 // If type is "e", it will keep the matched Token but not the top Token.
476 // If type is "E", it behaves as for type "e", except if there is no match,
477 // If type is "E", it behaves as for type "e", except if there is no match,
477 // in which case it will return an empty stack.
478 // in which case it will return an empty stack.
478
479
479 for (var type in tt) {
480 for (var type in tt) {
480 var len = stack.length-1;
481 var len = stack.length-1;
481 var tokens = tt[type];
482 var tokens = tt[type];
482 for (var i = len-1; -1 < i ; i--) {
483 for (var i = len-1; -1 < i ; i--) {
483 if (is_member(stack[i].token,tokens)) {
484 if (is_member(stack[i].token,tokens)) {
484 var ss = stack.slice(0,i);
485 var ss = stack.slice(0,i);
485 switch (type) {
486 switch (type) {
486 case "m": return ss.concat(stack[i]).concat(stack[len]);
487 case "m": return ss.concat(stack[i]).concat(stack[len]);
487 case "r": return ss.concat(stack[len]);
488 case "r": return ss.concat(stack[len]);
488 case "i": return ss;
489 case "i": return ss;
489 case "g": return ss.concat(fakeToken("group"));
490 case "g": return ss.concat(fakeToken("group"));
490 case "E": return ss.concat(stack[i]);
491 case "E": return ss.concat(stack[i]);
491 case "e": return ss.concat(stack[i]);
492 case "e": return ss.concat(stack[i]);
492 }
493 }
493 }
494 }
494 }
495 }
495 }
496 }
496 return (type == "E" ? [] : stack);
497 return (type == "E" ? [] : stack);
497 }
498 }
498
499
499 /////////////////////////////////////////////////////////////////////////////
500 /////////////////////////////////////////////////////////////////////////////
500 // indenter
501 // indenter
501
502
502 function indenter(state,textAfter) {
503 function indenter(state,textAfter) {
503 var t;
504 var t;
504 var unit = cmCfg.indentUnit;
505 var unit = cmCfg.indentUnit;
505 var wordAfter = wordafter(textAfter);
506 var wordAfter = wordafter(textAfter);
506 var currT = peekToken(state,1);
507 var currT = peekToken(state,1);
507 var prevT = peekToken(state,2);
508 var prevT = peekToken(state,2);
508
509
509 if (state.in_string || state.in_atom) {
510 if (state.in_string || state.in_atom) {
510 return CodeMirror.Pass;
511 return CodeMirror.Pass;
511 }else if (!prevT) {
512 }else if (!prevT) {
512 return 0;
513 return 0;
513 }else if (currT.token == "when") {
514 }else if (currT.token == "when") {
514 return currT.column+unit;
515 return currT.column+unit;
515 }else if (wordAfter === "when" && prevT.type === "function") {
516 }else if (wordAfter === "when" && prevT.type === "function") {
516 return prevT.indent+unit;
517 return prevT.indent+unit;
517 }else if (wordAfter === "(" && currT.token === "fun") {
518 }else if (wordAfter === "(" && currT.token === "fun") {
518 return currT.column+3;
519 return currT.column+3;
519 }else if (wordAfter === "catch" && (t = getToken(state,["try"]))) {
520 }else if (wordAfter === "catch" && (t = getToken(state,["try"]))) {
520 return t.column;
521 return t.column;
521 }else if (is_member(wordAfter,["end","after","of"])) {
522 }else if (is_member(wordAfter,["end","after","of"])) {
522 t = getToken(state,["begin","case","fun","if","receive","try"]);
523 t = getToken(state,["begin","case","fun","if","receive","try"]);
523 return t ? t.column : CodeMirror.Pass;
524 return t ? t.column : CodeMirror.Pass;
524 }else if (is_member(wordAfter,closeParenWords)) {
525 }else if (is_member(wordAfter,closeParenWords)) {
525 t = getToken(state,openParenWords);
526 t = getToken(state,openParenWords);
526 return t ? t.column : CodeMirror.Pass;
527 return t ? t.column : CodeMirror.Pass;
527 }else if (is_member(currT.token,[",","|","||"]) ||
528 }else if (is_member(currT.token,[",","|","||"]) ||
528 is_member(wordAfter,[",","|","||"])) {
529 is_member(wordAfter,[",","|","||"])) {
529 t = postcommaToken(state);
530 t = postcommaToken(state);
530 return t ? t.column+t.token.length : unit;
531 return t ? t.column+t.token.length : unit;
531 }else if (currT.token == "->") {
532 }else if (currT.token == "->") {
532 if (is_member(prevT.token, ["receive","case","if","try"])) {
533 if (is_member(prevT.token, ["receive","case","if","try"])) {
533 return prevT.column+unit+unit;
534 return prevT.column+unit+unit;
534 }else{
535 }else{
535 return prevT.column+unit;
536 return prevT.column+unit;
536 }
537 }
537 }else if (is_member(currT.token,openParenWords)) {
538 }else if (is_member(currT.token,openParenWords)) {
538 return currT.column+currT.token.length;
539 return currT.column+currT.token.length;
539 }else{
540 }else{
540 t = defaultToken(state);
541 t = defaultToken(state);
541 return truthy(t) ? t.column+unit : 0;
542 return truthy(t) ? t.column+unit : 0;
542 }
543 }
543 }
544 }
544
545
545 function wordafter(str) {
546 function wordafter(str) {
546 var m = str.match(/,|[a-z]+|\}|\]|\)|>>|\|+|\(/);
547 var m = str.match(/,|[a-z]+|\}|\]|\)|>>|\|+|\(/);
547
548
548 return truthy(m) && (m.index === 0) ? m[0] : "";
549 return truthy(m) && (m.index === 0) ? m[0] : "";
549 }
550 }
550
551
551 function postcommaToken(state) {
552 function postcommaToken(state) {
552 var objs = state.tokenStack.slice(0,-1);
553 var objs = state.tokenStack.slice(0,-1);
553 var i = getTokenIndex(objs,"type",["open_paren"]);
554 var i = getTokenIndex(objs,"type",["open_paren"]);
554
555
555 return truthy(objs[i]) ? objs[i] : false;
556 return truthy(objs[i]) ? objs[i] : false;
556 }
557 }
557
558
558 function defaultToken(state) {
559 function defaultToken(state) {
559 var objs = state.tokenStack;
560 var objs = state.tokenStack;
560 var stop = getTokenIndex(objs,"type",["open_paren","separator","keyword"]);
561 var stop = getTokenIndex(objs,"type",["open_paren","separator","keyword"]);
561 var oper = getTokenIndex(objs,"type",["operator"]);
562 var oper = getTokenIndex(objs,"type",["operator"]);
562
563
563 if (truthy(stop) && truthy(oper) && stop < oper) {
564 if (truthy(stop) && truthy(oper) && stop < oper) {
564 return objs[stop+1];
565 return objs[stop+1];
565 } else if (truthy(stop)) {
566 } else if (truthy(stop)) {
566 return objs[stop];
567 return objs[stop];
567 } else {
568 } else {
568 return false;
569 return false;
569 }
570 }
570 }
571 }
571
572
572 function getToken(state,tokens) {
573 function getToken(state,tokens) {
573 var objs = state.tokenStack;
574 var objs = state.tokenStack;
574 var i = getTokenIndex(objs,"token",tokens);
575 var i = getTokenIndex(objs,"token",tokens);
575
576
576 return truthy(objs[i]) ? objs[i] : false;
577 return truthy(objs[i]) ? objs[i] : false;
577 }
578 }
578
579
579 function getTokenIndex(objs,propname,propvals) {
580 function getTokenIndex(objs,propname,propvals) {
580
581
581 for (var i = objs.length-1; -1 < i ; i--) {
582 for (var i = objs.length-1; -1 < i ; i--) {
582 if (is_member(objs[i][propname],propvals)) {
583 if (is_member(objs[i][propname],propvals)) {
583 return i;
584 return i;
584 }
585 }
585 }
586 }
586 return false;
587 return false;
587 }
588 }
588
589
589 function truthy(x) {
590 function truthy(x) {
590 return (x !== false) && (x != null);
591 return (x !== false) && (x != null);
591 }
592 }
592
593
593 /////////////////////////////////////////////////////////////////////////////
594 /////////////////////////////////////////////////////////////////////////////
594 // this object defines the mode
595 // this object defines the mode
595
596
596 return {
597 return {
597 startState:
598 startState:
598 function() {
599 function() {
599 return {tokenStack: [],
600 return {tokenStack: [],
600 in_string: false,
601 in_string: false,
601 in_atom: false};
602 in_atom: false};
602 },
603 },
603
604
604 token:
605 token:
605 function(stream, state) {
606 function(stream, state) {
606 return tokenizer(stream, state);
607 return tokenizer(stream, state);
607 },
608 },
608
609
609 indent:
610 indent:
610 function(state, textAfter) {
611 function(state, textAfter) {
611 return indenter(state,textAfter);
612 return indenter(state,textAfter);
612 },
613 },
613
614
614 lineComment: "%"
615 lineComment: "%"
615 };
616 };
616 });
617 });
617
618
618 });
619 });
@@ -1,83 +1,85 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 // Factor syntax highlight - simple mode
4 // Factor syntax highlight - simple mode
5 //
5 //
6 // by Dimage Sapelkin (https://github.com/kerabromsmu)
6 // by Dimage Sapelkin (https://github.com/kerabromsmu)
7
7
8 (function(mod) {
8 (function(mod) {
9 if (typeof exports == "object" && typeof module == "object") // CommonJS
9 if (typeof exports == "object" && typeof module == "object") // CommonJS
10 mod(require("../../lib/codemirror"), require("../../addon/mode/simple"));
10 mod(require("../../lib/codemirror"), require("../../addon/mode/simple"));
11 else if (typeof define == "function" && define.amd) // AMD
11 else if (typeof define == "function" && define.amd) // AMD
12 define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
12 define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
13 else // Plain browser env
13 else // Plain browser env
14 mod(CodeMirror);
14 mod(CodeMirror);
15 })(function(CodeMirror) {
15 })(function(CodeMirror) {
16 "use strict";
16 "use strict";
17
17
18 CodeMirror.defineSimpleMode("factor", {
18 CodeMirror.defineSimpleMode("factor", {
19 // The start state contains the rules that are intially used
19 // The start state contains the rules that are intially used
20 start: [
20 start: [
21 // comments
21 // comments
22 {regex: /#?!.*/, token: "comment"},
22 {regex: /#?!.*/, token: "comment"},
23 // strings """, multiline --> state
23 // strings """, multiline --> state
24 {regex: /"""/, token: "string", next: "string3"},
24 {regex: /"""/, token: "string", next: "string3"},
25 {regex: /"/, token: "string", next: "string"},
25 {regex: /(STRING:)(\s)/, token: ["keyword", null], next: "string2"},
26 {regex: /\S*?"/, token: "string", next: "string"},
26 // numbers: dec, hex, unicode, bin, fractional, complex
27 // numbers: dec, hex, unicode, bin, fractional, complex
27 {regex: /(?:[+-]?)(?:0x[\d,a-f]+)|(?:0o[0-7]+)|(?:0b[0,1]+)|(?:\d+.?\d*)/, token: "number"},
28 {regex: /(?:0x[\d,a-f]+)|(?:0o[0-7]+)|(?:0b[0,1]+)|(?:\-?\d+.?\d*)(?=\s)/, token: "number"},
28 //{regex: /[+-]?/} //fractional
29 //{regex: /[+-]?/} //fractional
29 // definition: defining word, defined word, etc
30 // definition: defining word, defined word, etc
30 {regex: /(\:)(\s+)(\S+)(\s+)(\()/, token: ["keyword", null, "def", null, "keyword"], next: "stack"},
31 {regex: /((?:GENERIC)|\:?\:)(\s+)(\S+)(\s+)(\()/, token: ["keyword", null, "def", null, "bracket"], next: "stack"},
32 // method definition: defining word, type, defined word, etc
33 {regex: /(M\:)(\s+)(\S+)(\s+)(\S+)/, token: ["keyword", null, "def", null, "tag"]},
31 // vocabulary using --> state
34 // vocabulary using --> state
32 {regex: /USING\:/, token: "keyword", next: "vocabulary"},
35 {regex: /USING\:/, token: "keyword", next: "vocabulary"},
33 // vocabulary definition/use
36 // vocabulary definition/use
34 {regex: /(USE\:|IN\:)(\s+)(\S+)/, token: ["keyword", null, "variable-2"]},
37 {regex: /(USE\:|IN\:)(\s+)(\S+)(?=\s|$)/, token: ["keyword", null, "tag"]},
35 // <constructors>
38 // definition: a defining word, defined word
36 {regex: /<\S+>/, token: "builtin"},
39 {regex: /(\S+\:)(\s+)(\S+)(?=\s|$)/, token: ["keyword", null, "def"]},
37 // "keywords", incl. ; t f . [ ] { } defining words
40 // "keywords", incl. ; t f . [ ] { } defining words
38 {regex: /;|t|f|if|\.|\[|\]|\{|\}|MAIN:/, token: "keyword"},
41 {regex: /(?:;|\\|t|f|if|loop|while|until|do|PRIVATE>|<PRIVATE|\.|\S*\[|\]|\S*\{|\})(?=\s|$)/, token: "keyword"},
42 // <constructors> and the like
43 {regex: /\S+[\)>\.\*\?]+(?=\s|$)/, token: "builtin"},
44 {regex: /[\)><]+\S+(?=\s|$)/, token: "builtin"},
45 // operators
46 {regex: /(?:[\+\-\=\/\*<>])(?=\s|$)/, token: "keyword"},
39 // any id (?)
47 // any id (?)
40 {regex: /\S+/, token: "variable"},
48 {regex: /\S+/, token: "variable"},
41
49 {regex: /\s+|./, token: null}
42 {
43 regex: /./,
44 token: null
45 }
46 ],
50 ],
47 vocabulary: [
51 vocabulary: [
48 {regex: /;/, token: "keyword", next: "start"},
52 {regex: /;/, token: "keyword", next: "start"},
49 {regex: /\S+/, token: "variable-2"},
53 {regex: /\S+/, token: "tag"},
50 {
54 {regex: /\s+|./, token: null}
51 regex: /./,
52 token: null
53 }
54 ],
55 ],
55 string: [
56 string: [
56 {regex: /(?:[^\\]|\\.)*?"/, token: "string", next: "start"},
57 {regex: /(?:[^\\]|\\.)*?"/, token: "string", next: "start"},
57 {regex: /.*/, token: "string"}
58 {regex: /.*/, token: "string"}
58 ],
59 ],
60 string2: [
61 {regex: /^;/, token: "keyword", next: "start"},
62 {regex: /.*/, token: "string"}
63 ],
59 string3: [
64 string3: [
60 {regex: /(?:[^\\]|\\.)*?"""/, token: "string", next: "start"},
65 {regex: /(?:[^\\]|\\.)*?"""/, token: "string", next: "start"},
61 {regex: /.*/, token: "string"}
66 {regex: /.*/, token: "string"}
62 ],
67 ],
63 stack: [
68 stack: [
64 {regex: /\)/, token: "meta", next: "start"},
69 {regex: /\)/, token: "bracket", next: "start"},
65 {regex: /--/, token: "meta"},
70 {regex: /--/, token: "bracket"},
66 {regex: /\S+/, token: "variable-3"},
71 {regex: /\S+/, token: "meta"},
67 {
72 {regex: /\s+|./, token: null}
68 regex: /./,
69 token: null
70 }
71 ],
73 ],
72 // The meta property contains global information about the mode. It
74 // The meta property contains global information about the mode. It
73 // can contain properties like lineComment, which are supported by
75 // can contain properties like lineComment, which are supported by
74 // all modes, and also directives like dontIndentStates, which are
76 // all modes, and also directives like dontIndentStates, which are
75 // specific to simple modes.
77 // specific to simple modes.
76 meta: {
78 meta: {
77 dontIndentStates: ["start", "vocabulary", "string", "string3", "stack"],
79 dontIndentStates: ["start", "vocabulary", "string", "string3", "stack"],
78 lineComment: [ "!", "#!" ]
80 lineComment: [ "!", "#!" ]
79 }
81 }
80 });
82 });
81
83
82 CodeMirror.defineMIME("text/x-factor", "factor");
84 CodeMirror.defineMIME("text/x-factor", "factor");
83 });
85 });
@@ -1,180 +1,180 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 // Author: Aliaksei Chapyzhenka
4 // Author: Aliaksei Chapyzhenka
5
5
6 (function(mod) {
6 (function(mod) {
7 if (typeof exports == "object" && typeof module == "object") // CommonJS
7 if (typeof exports == "object" && typeof module == "object") // CommonJS
8 mod(require("../../lib/codemirror"));
8 mod(require("../../lib/codemirror"));
9 else if (typeof define == "function" && define.amd) // AMD
9 else if (typeof define == "function" && define.amd) // AMD
10 define(["../../lib/codemirror"], mod);
10 define(["../../lib/codemirror"], mod);
11 else // Plain browser env
11 else // Plain browser env
12 mod(CodeMirror);
12 mod(CodeMirror);
13 })(function(CodeMirror) {
13 })(function(CodeMirror) {
14 "use strict";
14 "use strict";
15
15
16 function toWordList(words) {
16 function toWordList(words) {
17 var ret = [];
17 var ret = [];
18 words.split(' ').forEach(function(e){
18 words.split(' ').forEach(function(e){
19 ret.push({name: e});
19 ret.push({name: e});
20 });
20 });
21 return ret;
21 return ret;
22 }
22 }
23
23
24 var coreWordList = toWordList(
24 var coreWordList = toWordList(
25 'INVERT AND OR XOR\
25 'INVERT AND OR XOR\
26 2* 2/ LSHIFT RSHIFT\
26 2* 2/ LSHIFT RSHIFT\
27 0= = 0< < > U< MIN MAX\
27 0= = 0< < > U< MIN MAX\
28 2DROP 2DUP 2OVER 2SWAP ?DUP DEPTH DROP DUP OVER ROT SWAP\
28 2DROP 2DUP 2OVER 2SWAP ?DUP DEPTH DROP DUP OVER ROT SWAP\
29 >R R> R@\
29 >R R> R@\
30 + - 1+ 1- ABS NEGATE\
30 + - 1+ 1- ABS NEGATE\
31 S>D * M* UM*\
31 S>D * M* UM*\
32 FM/MOD SM/REM UM/MOD */ */MOD / /MOD MOD\
32 FM/MOD SM/REM UM/MOD */ */MOD / /MOD MOD\
33 HERE , @ ! CELL+ CELLS C, C@ C! CHARS 2@ 2!\
33 HERE , @ ! CELL+ CELLS C, C@ C! CHARS 2@ 2!\
34 ALIGN ALIGNED +! ALLOT\
34 ALIGN ALIGNED +! ALLOT\
35 CHAR [CHAR] [ ] BL\
35 CHAR [CHAR] [ ] BL\
36 FIND EXECUTE IMMEDIATE COUNT LITERAL STATE\
36 FIND EXECUTE IMMEDIATE COUNT LITERAL STATE\
37 ; DOES> >BODY\
37 ; DOES> >BODY\
38 EVALUATE\
38 EVALUATE\
39 SOURCE >IN\
39 SOURCE >IN\
40 <# # #S #> HOLD SIGN BASE >NUMBER HEX DECIMAL\
40 <# # #S #> HOLD SIGN BASE >NUMBER HEX DECIMAL\
41 FILL MOVE\
41 FILL MOVE\
42 . CR EMIT SPACE SPACES TYPE U. .R U.R\
42 . CR EMIT SPACE SPACES TYPE U. .R U.R\
43 ACCEPT\
43 ACCEPT\
44 TRUE FALSE\
44 TRUE FALSE\
45 <> U> 0<> 0>\
45 <> U> 0<> 0>\
46 NIP TUCK ROLL PICK\
46 NIP TUCK ROLL PICK\
47 2>R 2R@ 2R>\
47 2>R 2R@ 2R>\
48 WITHIN UNUSED MARKER\
48 WITHIN UNUSED MARKER\
49 I J\
49 I J\
50 TO\
50 TO\
51 COMPILE, [COMPILE]\
51 COMPILE, [COMPILE]\
52 SAVE-INPUT RESTORE-INPUT\
52 SAVE-INPUT RESTORE-INPUT\
53 PAD ERASE\
53 PAD ERASE\
54 2LITERAL DNEGATE\
54 2LITERAL DNEGATE\
55 D- D+ D0< D0= D2* D2/ D< D= DMAX DMIN D>S DABS\
55 D- D+ D0< D0= D2* D2/ D< D= DMAX DMIN D>S DABS\
56 M+ M*/ D. D.R 2ROT DU<\
56 M+ M*/ D. D.R 2ROT DU<\
57 CATCH THROW\
57 CATCH THROW\
58 FREE RESIZE ALLOCATE\
58 FREE RESIZE ALLOCATE\
59 CS-PICK CS-ROLL\
59 CS-PICK CS-ROLL\
60 GET-CURRENT SET-CURRENT FORTH-WORDLIST GET-ORDER SET-ORDER\
60 GET-CURRENT SET-CURRENT FORTH-WORDLIST GET-ORDER SET-ORDER\
61 PREVIOUS SEARCH-WORDLIST WORDLIST FIND ALSO ONLY FORTH DEFINITIONS ORDER\
61 PREVIOUS SEARCH-WORDLIST WORDLIST FIND ALSO ONLY FORTH DEFINITIONS ORDER\
62 -TRAILING /STRING SEARCH COMPARE CMOVE CMOVE> BLANK SLITERAL');
62 -TRAILING /STRING SEARCH COMPARE CMOVE CMOVE> BLANK SLITERAL');
63
63
64 var immediateWordList = toWordList('IF ELSE THEN BEGIN WHILE REPEAT UNTIL RECURSE [IF] [ELSE] [THEN] ?DO DO LOOP +LOOP UNLOOP LEAVE EXIT AGAIN CASE OF ENDOF ENDCASE');
64 var immediateWordList = toWordList('IF ELSE THEN BEGIN WHILE REPEAT UNTIL RECURSE [IF] [ELSE] [THEN] ?DO DO LOOP +LOOP UNLOOP LEAVE EXIT AGAIN CASE OF ENDOF ENDCASE');
65
65
66 CodeMirror.defineMode('forth', function() {
66 CodeMirror.defineMode('forth', function() {
67 function searchWordList (wordList, word) {
67 function searchWordList (wordList, word) {
68 var i;
68 var i;
69 for (i = wordList.length - 1; i >= 0; i--) {
69 for (i = wordList.length - 1; i >= 0; i--) {
70 if (wordList[i].name === word.toUpperCase()) {
70 if (wordList[i].name === word.toUpperCase()) {
71 return wordList[i];
71 return wordList[i];
72 }
72 }
73 }
73 }
74 return undefined;
74 return undefined;
75 }
75 }
76 return {
76 return {
77 startState: function() {
77 startState: function() {
78 return {
78 return {
79 state: '',
79 state: '',
80 base: 10,
80 base: 10,
81 coreWordList: coreWordList,
81 coreWordList: coreWordList,
82 immediateWordList: immediateWordList,
82 immediateWordList: immediateWordList,
83 wordList: []
83 wordList: []
84 };
84 };
85 },
85 },
86 token: function (stream, stt) {
86 token: function (stream, stt) {
87 var mat;
87 var mat;
88 if (stream.eatSpace()) {
88 if (stream.eatSpace()) {
89 return null;
89 return null;
90 }
90 }
91 if (stt.state === '') { // interpretation
91 if (stt.state === '') { // interpretation
92 if (stream.match(/^(\]|:NONAME)(\s|$)/i)) {
92 if (stream.match(/^(\]|:NONAME)(\s|$)/i)) {
93 stt.state = ' compilation';
93 stt.state = ' compilation';
94 return 'builtin compilation';
94 return 'builtin compilation';
95 }
95 }
96 mat = stream.match(/^(\:)\s+(\S+)(\s|$)+/);
96 mat = stream.match(/^(\:)\s+(\S+)(\s|$)+/);
97 if (mat) {
97 if (mat) {
98 stt.wordList.push({name: mat[2].toUpperCase()});
98 stt.wordList.push({name: mat[2].toUpperCase()});
99 stt.state = ' compilation';
99 stt.state = ' compilation';
100 return 'def' + stt.state;
100 return 'def' + stt.state;
101 }
101 }
102 mat = stream.match(/^(VARIABLE|2VARIABLE|CONSTANT|2CONSTANT|CREATE|POSTPONE|VALUE|WORD)\s+(\S+)(\s|$)+/i);
102 mat = stream.match(/^(VARIABLE|2VARIABLE|CONSTANT|2CONSTANT|CREATE|POSTPONE|VALUE|WORD)\s+(\S+)(\s|$)+/i);
103 if (mat) {
103 if (mat) {
104 stt.wordList.push({name: mat[2].toUpperCase()});
104 stt.wordList.push({name: mat[2].toUpperCase()});
105 return 'def' + stt.state;
105 return 'def' + stt.state;
106 }
106 }
107 mat = stream.match(/^(\'|\[\'\])\s+(\S+)(\s|$)+/);
107 mat = stream.match(/^(\'|\[\'\])\s+(\S+)(\s|$)+/);
108 if (mat) {
108 if (mat) {
109 return 'builtin' + stt.state;
109 return 'builtin' + stt.state;
110 }
110 }
111 } else { // compilation
111 } else { // compilation
112 // ; [
112 // ; [
113 if (stream.match(/^(\;|\[)(\s)/)) {
113 if (stream.match(/^(\;|\[)(\s)/)) {
114 stt.state = '';
114 stt.state = '';
115 stream.backUp(1);
115 stream.backUp(1);
116 return 'builtin compilation';
116 return 'builtin compilation';
117 }
117 }
118 if (stream.match(/^(\;|\[)($)/)) {
118 if (stream.match(/^(\;|\[)($)/)) {
119 stt.state = '';
119 stt.state = '';
120 return 'builtin compilation';
120 return 'builtin compilation';
121 }
121 }
122 if (stream.match(/^(POSTPONE)\s+\S+(\s|$)+/)) {
122 if (stream.match(/^(POSTPONE)\s+\S+(\s|$)+/)) {
123 return 'builtin';
123 return 'builtin';
124 }
124 }
125 }
125 }
126
126
127 // dynamic wordlist
127 // dynamic wordlist
128 mat = stream.match(/^(\S+)(\s+|$)/);
128 mat = stream.match(/^(\S+)(\s+|$)/);
129 if (mat) {
129 if (mat) {
130 if (searchWordList(stt.wordList, mat[1]) !== undefined) {
130 if (searchWordList(stt.wordList, mat[1]) !== undefined) {
131 return 'variable' + stt.state;
131 return 'variable' + stt.state;
132 }
132 }
133
133
134 // comments
134 // comments
135 if (mat[1] === '\\') {
135 if (mat[1] === '\\') {
136 stream.skipToEnd();
136 stream.skipToEnd();
137 return 'comment' + stt.state;
137 return 'comment' + stt.state;
138 }
138 }
139
139
140 // core words
140 // core words
141 if (searchWordList(stt.coreWordList, mat[1]) !== undefined) {
141 if (searchWordList(stt.coreWordList, mat[1]) !== undefined) {
142 return 'builtin' + stt.state;
142 return 'builtin' + stt.state;
143 }
143 }
144 if (searchWordList(stt.immediateWordList, mat[1]) !== undefined) {
144 if (searchWordList(stt.immediateWordList, mat[1]) !== undefined) {
145 return 'keyword' + stt.state;
145 return 'keyword' + stt.state;
146 }
146 }
147
147
148 if (mat[1] === '(') {
148 if (mat[1] === '(') {
149 stream.eatWhile(function (s) { return s !== ')'; });
149 stream.eatWhile(function (s) { return s !== ')'; });
150 stream.eat(')');
150 stream.eat(')');
151 return 'comment' + stt.state;
151 return 'comment' + stt.state;
152 }
152 }
153
153
154 // // strings
154 // // strings
155 if (mat[1] === '.(') {
155 if (mat[1] === '.(') {
156 stream.eatWhile(function (s) { return s !== ')'; });
156 stream.eatWhile(function (s) { return s !== ')'; });
157 stream.eat(')');
157 stream.eat(')');
158 return 'string' + stt.state;
158 return 'string' + stt.state;
159 }
159 }
160 if (mat[1] === 'S"' || mat[1] === '."' || mat[1] === 'C"') {
160 if (mat[1] === 'S"' || mat[1] === '."' || mat[1] === 'C"') {
161 stream.eatWhile(function (s) { return s !== '"'; });
161 stream.eatWhile(function (s) { return s !== '"'; });
162 stream.eat('"');
162 stream.eat('"');
163 return 'string' + stt.state;
163 return 'string' + stt.state;
164 }
164 }
165
165
166 // numbers
166 // numbers
167 if (mat[1] - 0xfffffffff) {
167 if (mat[1] - 0xfffffffff) {
168 return 'number' + stt.state;
168 return 'number' + stt.state;
169 }
169 }
170 // if (mat[1].match(/^[-+]?[0-9]+\.[0-9]*/)) {
170 // if (mat[1].match(/^[-+]?[0-9]+\.[0-9]*/)) {
171 // return 'number' + stt.state;
171 // return 'number' + stt.state;
172 // }
172 // }
173
173
174 return 'atom' + stt.state;
174 return 'atom' + stt.state;
175 }
175 }
176 }
176 }
177 };
177 };
178 });
178 });
179 CodeMirror.defineMIME("text/x-forth", "forth");
179 CodeMirror.defineMIME("text/x-forth", "forth");
180 });
180 });
@@ -1,188 +1,188 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("fortran", function() {
14 CodeMirror.defineMode("fortran", function() {
15 function words(array) {
15 function words(array) {
16 var keys = {};
16 var keys = {};
17 for (var i = 0; i < array.length; ++i) {
17 for (var i = 0; i < array.length; ++i) {
18 keys[array[i]] = true;
18 keys[array[i]] = true;
19 }
19 }
20 return keys;
20 return keys;
21 }
21 }
22
22
23 var keywords = words([
23 var keywords = words([
24 "abstract", "accept", "allocatable", "allocate",
24 "abstract", "accept", "allocatable", "allocate",
25 "array", "assign", "asynchronous", "backspace",
25 "array", "assign", "asynchronous", "backspace",
26 "bind", "block", "byte", "call", "case",
26 "bind", "block", "byte", "call", "case",
27 "class", "close", "common", "contains",
27 "class", "close", "common", "contains",
28 "continue", "cycle", "data", "deallocate",
28 "continue", "cycle", "data", "deallocate",
29 "decode", "deferred", "dimension", "do",
29 "decode", "deferred", "dimension", "do",
30 "elemental", "else", "encode", "end",
30 "elemental", "else", "encode", "end",
31 "endif", "entry", "enumerator", "equivalence",
31 "endif", "entry", "enumerator", "equivalence",
32 "exit", "external", "extrinsic", "final",
32 "exit", "external", "extrinsic", "final",
33 "forall", "format", "function", "generic",
33 "forall", "format", "function", "generic",
34 "go", "goto", "if", "implicit", "import", "include",
34 "go", "goto", "if", "implicit", "import", "include",
35 "inquire", "intent", "interface", "intrinsic",
35 "inquire", "intent", "interface", "intrinsic",
36 "module", "namelist", "non_intrinsic",
36 "module", "namelist", "non_intrinsic",
37 "non_overridable", "none", "nopass",
37 "non_overridable", "none", "nopass",
38 "nullify", "open", "optional", "options",
38 "nullify", "open", "optional", "options",
39 "parameter", "pass", "pause", "pointer",
39 "parameter", "pass", "pause", "pointer",
40 "print", "private", "program", "protected",
40 "print", "private", "program", "protected",
41 "public", "pure", "read", "recursive", "result",
41 "public", "pure", "read", "recursive", "result",
42 "return", "rewind", "save", "select", "sequence",
42 "return", "rewind", "save", "select", "sequence",
43 "stop", "subroutine", "target", "then", "to", "type",
43 "stop", "subroutine", "target", "then", "to", "type",
44 "use", "value", "volatile", "where", "while",
44 "use", "value", "volatile", "where", "while",
45 "write"]);
45 "write"]);
46 var builtins = words(["abort", "abs", "access", "achar", "acos",
46 var builtins = words(["abort", "abs", "access", "achar", "acos",
47 "adjustl", "adjustr", "aimag", "aint", "alarm",
47 "adjustl", "adjustr", "aimag", "aint", "alarm",
48 "all", "allocated", "alog", "amax", "amin",
48 "all", "allocated", "alog", "amax", "amin",
49 "amod", "and", "anint", "any", "asin",
49 "amod", "and", "anint", "any", "asin",
50 "associated", "atan", "besj", "besjn", "besy",
50 "associated", "atan", "besj", "besjn", "besy",
51 "besyn", "bit_size", "btest", "cabs", "ccos",
51 "besyn", "bit_size", "btest", "cabs", "ccos",
52 "ceiling", "cexp", "char", "chdir", "chmod",
52 "ceiling", "cexp", "char", "chdir", "chmod",
53 "clog", "cmplx", "command_argument_count",
53 "clog", "cmplx", "command_argument_count",
54 "complex", "conjg", "cos", "cosh", "count",
54 "complex", "conjg", "cos", "cosh", "count",
55 "cpu_time", "cshift", "csin", "csqrt", "ctime",
55 "cpu_time", "cshift", "csin", "csqrt", "ctime",
56 "c_funloc", "c_loc", "c_associated", "c_null_ptr",
56 "c_funloc", "c_loc", "c_associated", "c_null_ptr",
57 "c_null_funptr", "c_f_pointer", "c_null_char",
57 "c_null_funptr", "c_f_pointer", "c_null_char",
58 "c_alert", "c_backspace", "c_form_feed",
58 "c_alert", "c_backspace", "c_form_feed",
59 "c_new_line", "c_carriage_return",
59 "c_new_line", "c_carriage_return",
60 "c_horizontal_tab", "c_vertical_tab", "dabs",
60 "c_horizontal_tab", "c_vertical_tab", "dabs",
61 "dacos", "dasin", "datan", "date_and_time",
61 "dacos", "dasin", "datan", "date_and_time",
62 "dbesj", "dbesj", "dbesjn", "dbesy", "dbesy",
62 "dbesj", "dbesj", "dbesjn", "dbesy", "dbesy",
63 "dbesyn", "dble", "dcos", "dcosh", "ddim", "derf",
63 "dbesyn", "dble", "dcos", "dcosh", "ddim", "derf",
64 "derfc", "dexp", "digits", "dim", "dint", "dlog",
64 "derfc", "dexp", "digits", "dim", "dint", "dlog",
65 "dlog", "dmax", "dmin", "dmod", "dnint",
65 "dlog", "dmax", "dmin", "dmod", "dnint",
66 "dot_product", "dprod", "dsign", "dsinh",
66 "dot_product", "dprod", "dsign", "dsinh",
67 "dsin", "dsqrt", "dtanh", "dtan", "dtime",
67 "dsin", "dsqrt", "dtanh", "dtan", "dtime",
68 "eoshift", "epsilon", "erf", "erfc", "etime",
68 "eoshift", "epsilon", "erf", "erfc", "etime",
69 "exit", "exp", "exponent", "extends_type_of",
69 "exit", "exp", "exponent", "extends_type_of",
70 "fdate", "fget", "fgetc", "float", "floor",
70 "fdate", "fget", "fgetc", "float", "floor",
71 "flush", "fnum", "fputc", "fput", "fraction",
71 "flush", "fnum", "fputc", "fput", "fraction",
72 "fseek", "fstat", "ftell", "gerror", "getarg",
72 "fseek", "fstat", "ftell", "gerror", "getarg",
73 "get_command", "get_command_argument",
73 "get_command", "get_command_argument",
74 "get_environment_variable", "getcwd",
74 "get_environment_variable", "getcwd",
75 "getenv", "getgid", "getlog", "getpid",
75 "getenv", "getgid", "getlog", "getpid",
76 "getuid", "gmtime", "hostnm", "huge", "iabs",
76 "getuid", "gmtime", "hostnm", "huge", "iabs",
77 "iachar", "iand", "iargc", "ibclr", "ibits",
77 "iachar", "iand", "iargc", "ibclr", "ibits",
78 "ibset", "ichar", "idate", "idim", "idint",
78 "ibset", "ichar", "idate", "idim", "idint",
79 "idnint", "ieor", "ierrno", "ifix", "imag",
79 "idnint", "ieor", "ierrno", "ifix", "imag",
80 "imagpart", "index", "int", "ior", "irand",
80 "imagpart", "index", "int", "ior", "irand",
81 "isatty", "ishft", "ishftc", "isign",
81 "isatty", "ishft", "ishftc", "isign",
82 "iso_c_binding", "is_iostat_end", "is_iostat_eor",
82 "iso_c_binding", "is_iostat_end", "is_iostat_eor",
83 "itime", "kill", "kind", "lbound", "len", "len_trim",
83 "itime", "kill", "kind", "lbound", "len", "len_trim",
84 "lge", "lgt", "link", "lle", "llt", "lnblnk", "loc",
84 "lge", "lgt", "link", "lle", "llt", "lnblnk", "loc",
85 "log", "logical", "long", "lshift", "lstat", "ltime",
85 "log", "logical", "long", "lshift", "lstat", "ltime",
86 "matmul", "max", "maxexponent", "maxloc", "maxval",
86 "matmul", "max", "maxexponent", "maxloc", "maxval",
87 "mclock", "merge", "move_alloc", "min", "minexponent",
87 "mclock", "merge", "move_alloc", "min", "minexponent",
88 "minloc", "minval", "mod", "modulo", "mvbits",
88 "minloc", "minval", "mod", "modulo", "mvbits",
89 "nearest", "new_line", "nint", "not", "or", "pack",
89 "nearest", "new_line", "nint", "not", "or", "pack",
90 "perror", "precision", "present", "product", "radix",
90 "perror", "precision", "present", "product", "radix",
91 "rand", "random_number", "random_seed", "range",
91 "rand", "random_number", "random_seed", "range",
92 "real", "realpart", "rename", "repeat", "reshape",
92 "real", "realpart", "rename", "repeat", "reshape",
93 "rrspacing", "rshift", "same_type_as", "scale",
93 "rrspacing", "rshift", "same_type_as", "scale",
94 "scan", "second", "selected_int_kind",
94 "scan", "second", "selected_int_kind",
95 "selected_real_kind", "set_exponent", "shape",
95 "selected_real_kind", "set_exponent", "shape",
96 "short", "sign", "signal", "sinh", "sin", "sleep",
96 "short", "sign", "signal", "sinh", "sin", "sleep",
97 "sngl", "spacing", "spread", "sqrt", "srand", "stat",
97 "sngl", "spacing", "spread", "sqrt", "srand", "stat",
98 "sum", "symlnk", "system", "system_clock", "tan",
98 "sum", "symlnk", "system", "system_clock", "tan",
99 "tanh", "time", "tiny", "transfer", "transpose",
99 "tanh", "time", "tiny", "transfer", "transpose",
100 "trim", "ttynam", "ubound", "umask", "unlink",
100 "trim", "ttynam", "ubound", "umask", "unlink",
101 "unpack", "verify", "xor", "zabs", "zcos", "zexp",
101 "unpack", "verify", "xor", "zabs", "zcos", "zexp",
102 "zlog", "zsin", "zsqrt"]);
102 "zlog", "zsin", "zsqrt"]);
103
103
104 var dataTypes = words(["c_bool", "c_char", "c_double", "c_double_complex",
104 var dataTypes = words(["c_bool", "c_char", "c_double", "c_double_complex",
105 "c_float", "c_float_complex", "c_funptr", "c_int",
105 "c_float", "c_float_complex", "c_funptr", "c_int",
106 "c_int16_t", "c_int32_t", "c_int64_t", "c_int8_t",
106 "c_int16_t", "c_int32_t", "c_int64_t", "c_int8_t",
107 "c_int_fast16_t", "c_int_fast32_t", "c_int_fast64_t",
107 "c_int_fast16_t", "c_int_fast32_t", "c_int_fast64_t",
108 "c_int_fast8_t", "c_int_least16_t", "c_int_least32_t",
108 "c_int_fast8_t", "c_int_least16_t", "c_int_least32_t",
109 "c_int_least64_t", "c_int_least8_t", "c_intmax_t",
109 "c_int_least64_t", "c_int_least8_t", "c_intmax_t",
110 "c_intptr_t", "c_long", "c_long_double",
110 "c_intptr_t", "c_long", "c_long_double",
111 "c_long_double_complex", "c_long_long", "c_ptr",
111 "c_long_double_complex", "c_long_long", "c_ptr",
112 "c_short", "c_signed_char", "c_size_t", "character",
112 "c_short", "c_signed_char", "c_size_t", "character",
113 "complex", "double", "integer", "logical", "real"]);
113 "complex", "double", "integer", "logical", "real"]);
114 var isOperatorChar = /[+\-*&=<>\/\:]/;
114 var isOperatorChar = /[+\-*&=<>\/\:]/;
115 var litOperator = new RegExp("(\.and\.|\.or\.|\.eq\.|\.lt\.|\.le\.|\.gt\.|\.ge\.|\.ne\.|\.not\.|\.eqv\.|\.neqv\.)", "i");
115 var litOperator = new RegExp("(\.and\.|\.or\.|\.eq\.|\.lt\.|\.le\.|\.gt\.|\.ge\.|\.ne\.|\.not\.|\.eqv\.|\.neqv\.)", "i");
116
116
117 function tokenBase(stream, state) {
117 function tokenBase(stream, state) {
118
118
119 if (stream.match(litOperator)){
119 if (stream.match(litOperator)){
120 return 'operator';
120 return 'operator';
121 }
121 }
122
122
123 var ch = stream.next();
123 var ch = stream.next();
124 if (ch == "!") {
124 if (ch == "!") {
125 stream.skipToEnd();
125 stream.skipToEnd();
126 return "comment";
126 return "comment";
127 }
127 }
128 if (ch == '"' || ch == "'") {
128 if (ch == '"' || ch == "'") {
129 state.tokenize = tokenString(ch);
129 state.tokenize = tokenString(ch);
130 return state.tokenize(stream, state);
130 return state.tokenize(stream, state);
131 }
131 }
132 if (/[\[\]\(\),]/.test(ch)) {
132 if (/[\[\]\(\),]/.test(ch)) {
133 return null;
133 return null;
134 }
134 }
135 if (/\d/.test(ch)) {
135 if (/\d/.test(ch)) {
136 stream.eatWhile(/[\w\.]/);
136 stream.eatWhile(/[\w\.]/);
137 return "number";
137 return "number";
138 }
138 }
139 if (isOperatorChar.test(ch)) {
139 if (isOperatorChar.test(ch)) {
140 stream.eatWhile(isOperatorChar);
140 stream.eatWhile(isOperatorChar);
141 return "operator";
141 return "operator";
142 }
142 }
143 stream.eatWhile(/[\w\$_]/);
143 stream.eatWhile(/[\w\$_]/);
144 var word = stream.current().toLowerCase();
144 var word = stream.current().toLowerCase();
145
145
146 if (keywords.hasOwnProperty(word)){
146 if (keywords.hasOwnProperty(word)){
147 return 'keyword';
147 return 'keyword';
148 }
148 }
149 if (builtins.hasOwnProperty(word) || dataTypes.hasOwnProperty(word)) {
149 if (builtins.hasOwnProperty(word) || dataTypes.hasOwnProperty(word)) {
150 return 'builtin';
150 return 'builtin';
151 }
151 }
152 return "variable";
152 return "variable";
153 }
153 }
154
154
155 function tokenString(quote) {
155 function tokenString(quote) {
156 return function(stream, state) {
156 return function(stream, state) {
157 var escaped = false, next, end = false;
157 var escaped = false, next, end = false;
158 while ((next = stream.next()) != null) {
158 while ((next = stream.next()) != null) {
159 if (next == quote && !escaped) {
159 if (next == quote && !escaped) {
160 end = true;
160 end = true;
161 break;
161 break;
162 }
162 }
163 escaped = !escaped && next == "\\";
163 escaped = !escaped && next == "\\";
164 }
164 }
165 if (end || !escaped) state.tokenize = null;
165 if (end || !escaped) state.tokenize = null;
166 return "string";
166 return "string";
167 };
167 };
168 }
168 }
169
169
170 // Interface
170 // Interface
171
171
172 return {
172 return {
173 startState: function() {
173 startState: function() {
174 return {tokenize: null};
174 return {tokenize: null};
175 },
175 },
176
176
177 token: function(stream, state) {
177 token: function(stream, state) {
178 if (stream.eatSpace()) return null;
178 if (stream.eatSpace()) return null;
179 var style = (state.tokenize || tokenBase)(stream, state);
179 var style = (state.tokenize || tokenBase)(stream, state);
180 if (style == "comment" || style == "meta") return style;
180 if (style == "comment" || style == "meta") return style;
181 return style;
181 return style;
182 }
182 }
183 };
183 };
184 });
184 });
185
185
186 CodeMirror.defineMIME("text/x-fortran", "fortran");
186 CodeMirror.defineMIME("text/x-fortran", "fortran");
187
187
188 });
188 });
@@ -1,345 +1,345 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("gas", function(_config, parserConfig) {
14 CodeMirror.defineMode("gas", function(_config, parserConfig) {
15 'use strict';
15 'use strict';
16
16
17 // If an architecture is specified, its initialization function may
17 // If an architecture is specified, its initialization function may
18 // populate this array with custom parsing functions which will be
18 // populate this array with custom parsing functions which will be
19 // tried in the event that the standard functions do not find a match.
19 // tried in the event that the standard functions do not find a match.
20 var custom = [];
20 var custom = [];
21
21
22 // The symbol used to start a line comment changes based on the target
22 // The symbol used to start a line comment changes based on the target
23 // architecture.
23 // architecture.
24 // If no architecture is pased in "parserConfig" then only multiline
24 // If no architecture is pased in "parserConfig" then only multiline
25 // comments will have syntax support.
25 // comments will have syntax support.
26 var lineCommentStartSymbol = "";
26 var lineCommentStartSymbol = "";
27
27
28 // These directives are architecture independent.
28 // These directives are architecture independent.
29 // Machine specific directives should go in their respective
29 // Machine specific directives should go in their respective
30 // architecture initialization function.
30 // architecture initialization function.
31 // Reference:
31 // Reference:
32 // http://sourceware.org/binutils/docs/as/Pseudo-Ops.html#Pseudo-Ops
32 // http://sourceware.org/binutils/docs/as/Pseudo-Ops.html#Pseudo-Ops
33 var directives = {
33 var directives = {
34 ".abort" : "builtin",
34 ".abort" : "builtin",
35 ".align" : "builtin",
35 ".align" : "builtin",
36 ".altmacro" : "builtin",
36 ".altmacro" : "builtin",
37 ".ascii" : "builtin",
37 ".ascii" : "builtin",
38 ".asciz" : "builtin",
38 ".asciz" : "builtin",
39 ".balign" : "builtin",
39 ".balign" : "builtin",
40 ".balignw" : "builtin",
40 ".balignw" : "builtin",
41 ".balignl" : "builtin",
41 ".balignl" : "builtin",
42 ".bundle_align_mode" : "builtin",
42 ".bundle_align_mode" : "builtin",
43 ".bundle_lock" : "builtin",
43 ".bundle_lock" : "builtin",
44 ".bundle_unlock" : "builtin",
44 ".bundle_unlock" : "builtin",
45 ".byte" : "builtin",
45 ".byte" : "builtin",
46 ".cfi_startproc" : "builtin",
46 ".cfi_startproc" : "builtin",
47 ".comm" : "builtin",
47 ".comm" : "builtin",
48 ".data" : "builtin",
48 ".data" : "builtin",
49 ".def" : "builtin",
49 ".def" : "builtin",
50 ".desc" : "builtin",
50 ".desc" : "builtin",
51 ".dim" : "builtin",
51 ".dim" : "builtin",
52 ".double" : "builtin",
52 ".double" : "builtin",
53 ".eject" : "builtin",
53 ".eject" : "builtin",
54 ".else" : "builtin",
54 ".else" : "builtin",
55 ".elseif" : "builtin",
55 ".elseif" : "builtin",
56 ".end" : "builtin",
56 ".end" : "builtin",
57 ".endef" : "builtin",
57 ".endef" : "builtin",
58 ".endfunc" : "builtin",
58 ".endfunc" : "builtin",
59 ".endif" : "builtin",
59 ".endif" : "builtin",
60 ".equ" : "builtin",
60 ".equ" : "builtin",
61 ".equiv" : "builtin",
61 ".equiv" : "builtin",
62 ".eqv" : "builtin",
62 ".eqv" : "builtin",
63 ".err" : "builtin",
63 ".err" : "builtin",
64 ".error" : "builtin",
64 ".error" : "builtin",
65 ".exitm" : "builtin",
65 ".exitm" : "builtin",
66 ".extern" : "builtin",
66 ".extern" : "builtin",
67 ".fail" : "builtin",
67 ".fail" : "builtin",
68 ".file" : "builtin",
68 ".file" : "builtin",
69 ".fill" : "builtin",
69 ".fill" : "builtin",
70 ".float" : "builtin",
70 ".float" : "builtin",
71 ".func" : "builtin",
71 ".func" : "builtin",
72 ".global" : "builtin",
72 ".global" : "builtin",
73 ".gnu_attribute" : "builtin",
73 ".gnu_attribute" : "builtin",
74 ".hidden" : "builtin",
74 ".hidden" : "builtin",
75 ".hword" : "builtin",
75 ".hword" : "builtin",
76 ".ident" : "builtin",
76 ".ident" : "builtin",
77 ".if" : "builtin",
77 ".if" : "builtin",
78 ".incbin" : "builtin",
78 ".incbin" : "builtin",
79 ".include" : "builtin",
79 ".include" : "builtin",
80 ".int" : "builtin",
80 ".int" : "builtin",
81 ".internal" : "builtin",
81 ".internal" : "builtin",
82 ".irp" : "builtin",
82 ".irp" : "builtin",
83 ".irpc" : "builtin",
83 ".irpc" : "builtin",
84 ".lcomm" : "builtin",
84 ".lcomm" : "builtin",
85 ".lflags" : "builtin",
85 ".lflags" : "builtin",
86 ".line" : "builtin",
86 ".line" : "builtin",
87 ".linkonce" : "builtin",
87 ".linkonce" : "builtin",
88 ".list" : "builtin",
88 ".list" : "builtin",
89 ".ln" : "builtin",
89 ".ln" : "builtin",
90 ".loc" : "builtin",
90 ".loc" : "builtin",
91 ".loc_mark_labels" : "builtin",
91 ".loc_mark_labels" : "builtin",
92 ".local" : "builtin",
92 ".local" : "builtin",
93 ".long" : "builtin",
93 ".long" : "builtin",
94 ".macro" : "builtin",
94 ".macro" : "builtin",
95 ".mri" : "builtin",
95 ".mri" : "builtin",
96 ".noaltmacro" : "builtin",
96 ".noaltmacro" : "builtin",
97 ".nolist" : "builtin",
97 ".nolist" : "builtin",
98 ".octa" : "builtin",
98 ".octa" : "builtin",
99 ".offset" : "builtin",
99 ".offset" : "builtin",
100 ".org" : "builtin",
100 ".org" : "builtin",
101 ".p2align" : "builtin",
101 ".p2align" : "builtin",
102 ".popsection" : "builtin",
102 ".popsection" : "builtin",
103 ".previous" : "builtin",
103 ".previous" : "builtin",
104 ".print" : "builtin",
104 ".print" : "builtin",
105 ".protected" : "builtin",
105 ".protected" : "builtin",
106 ".psize" : "builtin",
106 ".psize" : "builtin",
107 ".purgem" : "builtin",
107 ".purgem" : "builtin",
108 ".pushsection" : "builtin",
108 ".pushsection" : "builtin",
109 ".quad" : "builtin",
109 ".quad" : "builtin",
110 ".reloc" : "builtin",
110 ".reloc" : "builtin",
111 ".rept" : "builtin",
111 ".rept" : "builtin",
112 ".sbttl" : "builtin",
112 ".sbttl" : "builtin",
113 ".scl" : "builtin",
113 ".scl" : "builtin",
114 ".section" : "builtin",
114 ".section" : "builtin",
115 ".set" : "builtin",
115 ".set" : "builtin",
116 ".short" : "builtin",
116 ".short" : "builtin",
117 ".single" : "builtin",
117 ".single" : "builtin",
118 ".size" : "builtin",
118 ".size" : "builtin",
119 ".skip" : "builtin",
119 ".skip" : "builtin",
120 ".sleb128" : "builtin",
120 ".sleb128" : "builtin",
121 ".space" : "builtin",
121 ".space" : "builtin",
122 ".stab" : "builtin",
122 ".stab" : "builtin",
123 ".string" : "builtin",
123 ".string" : "builtin",
124 ".struct" : "builtin",
124 ".struct" : "builtin",
125 ".subsection" : "builtin",
125 ".subsection" : "builtin",
126 ".symver" : "builtin",
126 ".symver" : "builtin",
127 ".tag" : "builtin",
127 ".tag" : "builtin",
128 ".text" : "builtin",
128 ".text" : "builtin",
129 ".title" : "builtin",
129 ".title" : "builtin",
130 ".type" : "builtin",
130 ".type" : "builtin",
131 ".uleb128" : "builtin",
131 ".uleb128" : "builtin",
132 ".val" : "builtin",
132 ".val" : "builtin",
133 ".version" : "builtin",
133 ".version" : "builtin",
134 ".vtable_entry" : "builtin",
134 ".vtable_entry" : "builtin",
135 ".vtable_inherit" : "builtin",
135 ".vtable_inherit" : "builtin",
136 ".warning" : "builtin",
136 ".warning" : "builtin",
137 ".weak" : "builtin",
137 ".weak" : "builtin",
138 ".weakref" : "builtin",
138 ".weakref" : "builtin",
139 ".word" : "builtin"
139 ".word" : "builtin"
140 };
140 };
141
141
142 var registers = {};
142 var registers = {};
143
143
144 function x86(_parserConfig) {
144 function x86(_parserConfig) {
145 lineCommentStartSymbol = "#";
145 lineCommentStartSymbol = "#";
146
146
147 registers.ax = "variable";
147 registers.ax = "variable";
148 registers.eax = "variable-2";
148 registers.eax = "variable-2";
149 registers.rax = "variable-3";
149 registers.rax = "variable-3";
150
150
151 registers.bx = "variable";
151 registers.bx = "variable";
152 registers.ebx = "variable-2";
152 registers.ebx = "variable-2";
153 registers.rbx = "variable-3";
153 registers.rbx = "variable-3";
154
154
155 registers.cx = "variable";
155 registers.cx = "variable";
156 registers.ecx = "variable-2";
156 registers.ecx = "variable-2";
157 registers.rcx = "variable-3";
157 registers.rcx = "variable-3";
158
158
159 registers.dx = "variable";
159 registers.dx = "variable";
160 registers.edx = "variable-2";
160 registers.edx = "variable-2";
161 registers.rdx = "variable-3";
161 registers.rdx = "variable-3";
162
162
163 registers.si = "variable";
163 registers.si = "variable";
164 registers.esi = "variable-2";
164 registers.esi = "variable-2";
165 registers.rsi = "variable-3";
165 registers.rsi = "variable-3";
166
166
167 registers.di = "variable";
167 registers.di = "variable";
168 registers.edi = "variable-2";
168 registers.edi = "variable-2";
169 registers.rdi = "variable-3";
169 registers.rdi = "variable-3";
170
170
171 registers.sp = "variable";
171 registers.sp = "variable";
172 registers.esp = "variable-2";
172 registers.esp = "variable-2";
173 registers.rsp = "variable-3";
173 registers.rsp = "variable-3";
174
174
175 registers.bp = "variable";
175 registers.bp = "variable";
176 registers.ebp = "variable-2";
176 registers.ebp = "variable-2";
177 registers.rbp = "variable-3";
177 registers.rbp = "variable-3";
178
178
179 registers.ip = "variable";
179 registers.ip = "variable";
180 registers.eip = "variable-2";
180 registers.eip = "variable-2";
181 registers.rip = "variable-3";
181 registers.rip = "variable-3";
182
182
183 registers.cs = "keyword";
183 registers.cs = "keyword";
184 registers.ds = "keyword";
184 registers.ds = "keyword";
185 registers.ss = "keyword";
185 registers.ss = "keyword";
186 registers.es = "keyword";
186 registers.es = "keyword";
187 registers.fs = "keyword";
187 registers.fs = "keyword";
188 registers.gs = "keyword";
188 registers.gs = "keyword";
189 }
189 }
190
190
191 function armv6(_parserConfig) {
191 function armv6(_parserConfig) {
192 // Reference:
192 // Reference:
193 // http://infocenter.arm.com/help/topic/com.arm.doc.qrc0001l/QRC0001_UAL.pdf
193 // http://infocenter.arm.com/help/topic/com.arm.doc.qrc0001l/QRC0001_UAL.pdf
194 // http://infocenter.arm.com/help/topic/com.arm.doc.ddi0301h/DDI0301H_arm1176jzfs_r0p7_trm.pdf
194 // http://infocenter.arm.com/help/topic/com.arm.doc.ddi0301h/DDI0301H_arm1176jzfs_r0p7_trm.pdf
195 lineCommentStartSymbol = "@";
195 lineCommentStartSymbol = "@";
196 directives.syntax = "builtin";
196 directives.syntax = "builtin";
197
197
198 registers.r0 = "variable";
198 registers.r0 = "variable";
199 registers.r1 = "variable";
199 registers.r1 = "variable";
200 registers.r2 = "variable";
200 registers.r2 = "variable";
201 registers.r3 = "variable";
201 registers.r3 = "variable";
202 registers.r4 = "variable";
202 registers.r4 = "variable";
203 registers.r5 = "variable";
203 registers.r5 = "variable";
204 registers.r6 = "variable";
204 registers.r6 = "variable";
205 registers.r7 = "variable";
205 registers.r7 = "variable";
206 registers.r8 = "variable";
206 registers.r8 = "variable";
207 registers.r9 = "variable";
207 registers.r9 = "variable";
208 registers.r10 = "variable";
208 registers.r10 = "variable";
209 registers.r11 = "variable";
209 registers.r11 = "variable";
210 registers.r12 = "variable";
210 registers.r12 = "variable";
211
211
212 registers.sp = "variable-2";
212 registers.sp = "variable-2";
213 registers.lr = "variable-2";
213 registers.lr = "variable-2";
214 registers.pc = "variable-2";
214 registers.pc = "variable-2";
215 registers.r13 = registers.sp;
215 registers.r13 = registers.sp;
216 registers.r14 = registers.lr;
216 registers.r14 = registers.lr;
217 registers.r15 = registers.pc;
217 registers.r15 = registers.pc;
218
218
219 custom.push(function(ch, stream) {
219 custom.push(function(ch, stream) {
220 if (ch === '#') {
220 if (ch === '#') {
221 stream.eatWhile(/\w/);
221 stream.eatWhile(/\w/);
222 return "number";
222 return "number";
223 }
223 }
224 });
224 });
225 }
225 }
226
226
227 var arch = (parserConfig.architecture || "x86").toLowerCase();
227 var arch = (parserConfig.architecture || "x86").toLowerCase();
228 if (arch === "x86") {
228 if (arch === "x86") {
229 x86(parserConfig);
229 x86(parserConfig);
230 } else if (arch === "arm" || arch === "armv6") {
230 } else if (arch === "arm" || arch === "armv6") {
231 armv6(parserConfig);
231 armv6(parserConfig);
232 }
232 }
233
233
234 function nextUntilUnescaped(stream, end) {
234 function nextUntilUnescaped(stream, end) {
235 var escaped = false, next;
235 var escaped = false, next;
236 while ((next = stream.next()) != null) {
236 while ((next = stream.next()) != null) {
237 if (next === end && !escaped) {
237 if (next === end && !escaped) {
238 return false;
238 return false;
239 }
239 }
240 escaped = !escaped && next === "\\";
240 escaped = !escaped && next === "\\";
241 }
241 }
242 return escaped;
242 return escaped;
243 }
243 }
244
244
245 function clikeComment(stream, state) {
245 function clikeComment(stream, state) {
246 var maybeEnd = false, ch;
246 var maybeEnd = false, ch;
247 while ((ch = stream.next()) != null) {
247 while ((ch = stream.next()) != null) {
248 if (ch === "/" && maybeEnd) {
248 if (ch === "/" && maybeEnd) {
249 state.tokenize = null;
249 state.tokenize = null;
250 break;
250 break;
251 }
251 }
252 maybeEnd = (ch === "*");
252 maybeEnd = (ch === "*");
253 }
253 }
254 return "comment";
254 return "comment";
255 }
255 }
256
256
257 return {
257 return {
258 startState: function() {
258 startState: function() {
259 return {
259 return {
260 tokenize: null
260 tokenize: null
261 };
261 };
262 },
262 },
263
263
264 token: function(stream, state) {
264 token: function(stream, state) {
265 if (state.tokenize) {
265 if (state.tokenize) {
266 return state.tokenize(stream, state);
266 return state.tokenize(stream, state);
267 }
267 }
268
268
269 if (stream.eatSpace()) {
269 if (stream.eatSpace()) {
270 return null;
270 return null;
271 }
271 }
272
272
273 var style, cur, ch = stream.next();
273 var style, cur, ch = stream.next();
274
274
275 if (ch === "/") {
275 if (ch === "/") {
276 if (stream.eat("*")) {
276 if (stream.eat("*")) {
277 state.tokenize = clikeComment;
277 state.tokenize = clikeComment;
278 return clikeComment(stream, state);
278 return clikeComment(stream, state);
279 }
279 }
280 }
280 }
281
281
282 if (ch === lineCommentStartSymbol) {
282 if (ch === lineCommentStartSymbol) {
283 stream.skipToEnd();
283 stream.skipToEnd();
284 return "comment";
284 return "comment";
285 }
285 }
286
286
287 if (ch === '"') {
287 if (ch === '"') {
288 nextUntilUnescaped(stream, '"');
288 nextUntilUnescaped(stream, '"');
289 return "string";
289 return "string";
290 }
290 }
291
291
292 if (ch === '.') {
292 if (ch === '.') {
293 stream.eatWhile(/\w/);
293 stream.eatWhile(/\w/);
294 cur = stream.current().toLowerCase();
294 cur = stream.current().toLowerCase();
295 style = directives[cur];
295 style = directives[cur];
296 return style || null;
296 return style || null;
297 }
297 }
298
298
299 if (ch === '=') {
299 if (ch === '=') {
300 stream.eatWhile(/\w/);
300 stream.eatWhile(/\w/);
301 return "tag";
301 return "tag";
302 }
302 }
303
303
304 if (ch === '{') {
304 if (ch === '{') {
305 return "braket";
305 return "braket";
306 }
306 }
307
307
308 if (ch === '}') {
308 if (ch === '}') {
309 return "braket";
309 return "braket";
310 }
310 }
311
311
312 if (/\d/.test(ch)) {
312 if (/\d/.test(ch)) {
313 if (ch === "0" && stream.eat("x")) {
313 if (ch === "0" && stream.eat("x")) {
314 stream.eatWhile(/[0-9a-fA-F]/);
314 stream.eatWhile(/[0-9a-fA-F]/);
315 return "number";
315 return "number";
316 }
316 }
317 stream.eatWhile(/\d/);
317 stream.eatWhile(/\d/);
318 return "number";
318 return "number";
319 }
319 }
320
320
321 if (/\w/.test(ch)) {
321 if (/\w/.test(ch)) {
322 stream.eatWhile(/\w/);
322 stream.eatWhile(/\w/);
323 if (stream.eat(":")) {
323 if (stream.eat(":")) {
324 return 'tag';
324 return 'tag';
325 }
325 }
326 cur = stream.current().toLowerCase();
326 cur = stream.current().toLowerCase();
327 style = registers[cur];
327 style = registers[cur];
328 return style || null;
328 return style || null;
329 }
329 }
330
330
331 for (var i = 0; i < custom.length; i++) {
331 for (var i = 0; i < custom.length; i++) {
332 style = custom[i](ch, stream, state);
332 style = custom[i](ch, stream, state);
333 if (style) {
333 if (style) {
334 return style;
334 return style;
335 }
335 }
336 }
336 }
337 },
337 },
338
338
339 lineComment: lineCommentStartSymbol,
339 lineComment: lineCommentStartSymbol,
340 blockCommentStart: "/*",
340 blockCommentStart: "/*",
341 blockCommentEnd: "*/"
341 blockCommentEnd: "*/"
342 };
342 };
343 });
343 });
344
344
345 });
345 });
@@ -1,130 +1,129 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"), require("../markdown/markdown"), require("../../addon/mode/overlay"));
6 mod(require("../../lib/codemirror"), require("../markdown/markdown"), require("../../addon/mode/overlay"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror", "../markdown/markdown", "../../addon/mode/overlay"], mod);
8 define(["../../lib/codemirror", "../markdown/markdown", "../../addon/mode/overlay"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 var urlRE = /^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|tag|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i
14 var urlRE = /^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|tag|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i
15
15
16 CodeMirror.defineMode("gfm", function(config, modeConfig) {
16 CodeMirror.defineMode("gfm", function(config, modeConfig) {
17 var codeDepth = 0;
17 var codeDepth = 0;
18 function blankLine(state) {
18 function blankLine(state) {
19 state.code = false;
19 state.code = false;
20 return null;
20 return null;
21 }
21 }
22 var gfmOverlay = {
22 var gfmOverlay = {
23 startState: function() {
23 startState: function() {
24 return {
24 return {
25 code: false,
25 code: false,
26 codeBlock: false,
26 codeBlock: false,
27 ateSpace: false
27 ateSpace: false
28 };
28 };
29 },
29 },
30 copyState: function(s) {
30 copyState: function(s) {
31 return {
31 return {
32 code: s.code,
32 code: s.code,
33 codeBlock: s.codeBlock,
33 codeBlock: s.codeBlock,
34 ateSpace: s.ateSpace
34 ateSpace: s.ateSpace
35 };
35 };
36 },
36 },
37 token: function(stream, state) {
37 token: function(stream, state) {
38 state.combineTokens = null;
38 state.combineTokens = null;
39
39
40 // Hack to prevent formatting override inside code blocks (block and inline)
40 // Hack to prevent formatting override inside code blocks (block and inline)
41 if (state.codeBlock) {
41 if (state.codeBlock) {
42 if (stream.match(/^```+/)) {
42 if (stream.match(/^```+/)) {
43 state.codeBlock = false;
43 state.codeBlock = false;
44 return null;
44 return null;
45 }
45 }
46 stream.skipToEnd();
46 stream.skipToEnd();
47 return null;
47 return null;
48 }
48 }
49 if (stream.sol()) {
49 if (stream.sol()) {
50 state.code = false;
50 state.code = false;
51 }
51 }
52 if (stream.sol() && stream.match(/^```+/)) {
52 if (stream.sol() && stream.match(/^```+/)) {
53 stream.skipToEnd();
53 stream.skipToEnd();
54 state.codeBlock = true;
54 state.codeBlock = true;
55 return null;
55 return null;
56 }
56 }
57 // If this block is changed, it may need to be updated in Markdown mode
57 // If this block is changed, it may need to be updated in Markdown mode
58 if (stream.peek() === '`') {
58 if (stream.peek() === '`') {
59 stream.next();
59 stream.next();
60 var before = stream.pos;
60 var before = stream.pos;
61 stream.eatWhile('`');
61 stream.eatWhile('`');
62 var difference = 1 + stream.pos - before;
62 var difference = 1 + stream.pos - before;
63 if (!state.code) {
63 if (!state.code) {
64 codeDepth = difference;
64 codeDepth = difference;
65 state.code = true;
65 state.code = true;
66 } else {
66 } else {
67 if (difference === codeDepth) { // Must be exact
67 if (difference === codeDepth) { // Must be exact
68 state.code = false;
68 state.code = false;
69 }
69 }
70 }
70 }
71 return null;
71 return null;
72 } else if (state.code) {
72 } else if (state.code) {
73 stream.next();
73 stream.next();
74 return null;
74 return null;
75 }
75 }
76 // Check if space. If so, links can be formatted later on
76 // Check if space. If so, links can be formatted later on
77 if (stream.eatSpace()) {
77 if (stream.eatSpace()) {
78 state.ateSpace = true;
78 state.ateSpace = true;
79 return null;
79 return null;
80 }
80 }
81 if (stream.sol() || state.ateSpace) {
81 if (stream.sol() || state.ateSpace) {
82 state.ateSpace = false;
82 state.ateSpace = false;
83 if (modeConfig.gitHubSpice !== false) {
83 if (modeConfig.gitHubSpice !== false) {
84 if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/)) {
84 if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?=.{0,6}\d)(?:[a-f0-9]{7,40}\b)/)) {
85 // User/Project@SHA
85 // User/Project@SHA
86 // User@SHA
86 // User@SHA
87 // SHA
87 // SHA
88 state.combineTokens = true;
88 state.combineTokens = true;
89 return "link";
89 return "link";
90 } else if (stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) {
90 } else if (stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) {
91 // User/Project#Num
91 // User/Project#Num
92 // User#Num
92 // User#Num
93 // #Num
93 // #Num
94 state.combineTokens = true;
94 state.combineTokens = true;
95 return "link";
95 return "link";
96 }
96 }
97 }
97 }
98 }
98 }
99 if (stream.match(urlRE) &&
99 if (stream.match(urlRE) &&
100 stream.string.slice(stream.start - 2, stream.start) != "](" &&
100 stream.string.slice(stream.start - 2, stream.start) != "](" &&
101 (stream.start == 0 || /\W/.test(stream.string.charAt(stream.start - 1)))) {
101 (stream.start == 0 || /\W/.test(stream.string.charAt(stream.start - 1)))) {
102 // URLs
102 // URLs
103 // Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
103 // Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
104 // And then (issue #1160) simplified to make it not crash the Chrome Regexp engine
104 // And then (issue #1160) simplified to make it not crash the Chrome Regexp engine
105 // And then limited url schemes to the CommonMark list, so foo:bar isn't matched as a URL
105 // And then limited url schemes to the CommonMark list, so foo:bar isn't matched as a URL
106 state.combineTokens = true;
106 state.combineTokens = true;
107 return "link";
107 return "link";
108 }
108 }
109 stream.next();
109 stream.next();
110 return null;
110 return null;
111 },
111 },
112 blankLine: blankLine
112 blankLine: blankLine
113 };
113 };
114
114
115 var markdownConfig = {
115 var markdownConfig = {
116 underscoresBreakWords: false,
117 taskLists: true,
116 taskLists: true,
118 fencedCodeBlocks: '```',
117 strikethrough: true,
119 strikethrough: true
118 emoji: true
120 };
119 };
121 for (var attr in modeConfig) {
120 for (var attr in modeConfig) {
122 markdownConfig[attr] = modeConfig[attr];
121 markdownConfig[attr] = modeConfig[attr];
123 }
122 }
124 markdownConfig.name = "markdown";
123 markdownConfig.name = "markdown";
125 return CodeMirror.overlayMode(CodeMirror.getMode(config, markdownConfig), gfmOverlay);
124 return CodeMirror.overlayMode(CodeMirror.getMode(config, markdownConfig), gfmOverlay);
126
125
127 }, "markdown");
126 }, "markdown");
128
127
129 CodeMirror.defineMIME("text/x-gfm", "gfm");
128 CodeMirror.defineMIME("text/x-gfm", "gfm");
130 });
129 });
@@ -1,178 +1,178 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 /*
4 /*
5 Gherkin mode - http://www.cukes.info/
5 Gherkin mode - http://www.cukes.info/
6 Report bugs/issues here: https://github.com/codemirror/CodeMirror/issues
6 Report bugs/issues here: https://github.com/codemirror/CodeMirror/issues
7 */
7 */
8
8
9 // Following Objs from Brackets implementation: https://github.com/tregusti/brackets-gherkin/blob/master/main.js
9 // Following Objs from Brackets implementation: https://github.com/tregusti/brackets-gherkin/blob/master/main.js
10 //var Quotes = {
10 //var Quotes = {
11 // SINGLE: 1,
11 // SINGLE: 1,
12 // DOUBLE: 2
12 // DOUBLE: 2
13 //};
13 //};
14
14
15 //var regex = {
15 //var regex = {
16 // keywords: /(Feature| {2}(Scenario|In order to|As|I)| {4}(Given|When|Then|And))/
16 // keywords: /(Feature| {2}(Scenario|In order to|As|I)| {4}(Given|When|Then|And))/
17 //};
17 //};
18
18
19 (function(mod) {
19 (function(mod) {
20 if (typeof exports == "object" && typeof module == "object") // CommonJS
20 if (typeof exports == "object" && typeof module == "object") // CommonJS
21 mod(require("../../lib/codemirror"));
21 mod(require("../../lib/codemirror"));
22 else if (typeof define == "function" && define.amd) // AMD
22 else if (typeof define == "function" && define.amd) // AMD
23 define(["../../lib/codemirror"], mod);
23 define(["../../lib/codemirror"], mod);
24 else // Plain browser env
24 else // Plain browser env
25 mod(CodeMirror);
25 mod(CodeMirror);
26 })(function(CodeMirror) {
26 })(function(CodeMirror) {
27 "use strict";
27 "use strict";
28
28
29 CodeMirror.defineMode("gherkin", function () {
29 CodeMirror.defineMode("gherkin", function () {
30 return {
30 return {
31 startState: function () {
31 startState: function () {
32 return {
32 return {
33 lineNumber: 0,
33 lineNumber: 0,
34 tableHeaderLine: false,
34 tableHeaderLine: false,
35 allowFeature: true,
35 allowFeature: true,
36 allowBackground: false,
36 allowBackground: false,
37 allowScenario: false,
37 allowScenario: false,
38 allowSteps: false,
38 allowSteps: false,
39 allowPlaceholders: false,
39 allowPlaceholders: false,
40 allowMultilineArgument: false,
40 allowMultilineArgument: false,
41 inMultilineString: false,
41 inMultilineString: false,
42 inMultilineTable: false,
42 inMultilineTable: false,
43 inKeywordLine: false
43 inKeywordLine: false
44 };
44 };
45 },
45 },
46 token: function (stream, state) {
46 token: function (stream, state) {
47 if (stream.sol()) {
47 if (stream.sol()) {
48 state.lineNumber++;
48 state.lineNumber++;
49 state.inKeywordLine = false;
49 state.inKeywordLine = false;
50 if (state.inMultilineTable) {
50 if (state.inMultilineTable) {
51 state.tableHeaderLine = false;
51 state.tableHeaderLine = false;
52 if (!stream.match(/\s*\|/, false)) {
52 if (!stream.match(/\s*\|/, false)) {
53 state.allowMultilineArgument = false;
53 state.allowMultilineArgument = false;
54 state.inMultilineTable = false;
54 state.inMultilineTable = false;
55 }
55 }
56 }
56 }
57 }
57 }
58
58
59 stream.eatSpace();
59 stream.eatSpace();
60
60
61 if (state.allowMultilineArgument) {
61 if (state.allowMultilineArgument) {
62
62
63 // STRING
63 // STRING
64 if (state.inMultilineString) {
64 if (state.inMultilineString) {
65 if (stream.match('"""')) {
65 if (stream.match('"""')) {
66 state.inMultilineString = false;
66 state.inMultilineString = false;
67 state.allowMultilineArgument = false;
67 state.allowMultilineArgument = false;
68 } else {
68 } else {
69 stream.match(/.*/);
69 stream.match(/.*/);
70 }
70 }
71 return "string";
71 return "string";
72 }
72 }
73
73
74 // TABLE
74 // TABLE
75 if (state.inMultilineTable) {
75 if (state.inMultilineTable) {
76 if (stream.match(/\|\s*/)) {
76 if (stream.match(/\|\s*/)) {
77 return "bracket";
77 return "bracket";
78 } else {
78 } else {
79 stream.match(/[^\|]*/);
79 stream.match(/[^\|]*/);
80 return state.tableHeaderLine ? "header" : "string";
80 return state.tableHeaderLine ? "header" : "string";
81 }
81 }
82 }
82 }
83
83
84 // DETECT START
84 // DETECT START
85 if (stream.match('"""')) {
85 if (stream.match('"""')) {
86 // String
86 // String
87 state.inMultilineString = true;
87 state.inMultilineString = true;
88 return "string";
88 return "string";
89 } else if (stream.match("|")) {
89 } else if (stream.match("|")) {
90 // Table
90 // Table
91 state.inMultilineTable = true;
91 state.inMultilineTable = true;
92 state.tableHeaderLine = true;
92 state.tableHeaderLine = true;
93 return "bracket";
93 return "bracket";
94 }
94 }
95
95
96 }
96 }
97
97
98 // LINE COMMENT
98 // LINE COMMENT
99 if (stream.match(/#.*/)) {
99 if (stream.match(/#.*/)) {
100 return "comment";
100 return "comment";
101
101
102 // TAG
102 // TAG
103 } else if (!state.inKeywordLine && stream.match(/@\S+/)) {
103 } else if (!state.inKeywordLine && stream.match(/@\S+/)) {
104 return "tag";
104 return "tag";
105
105
106 // FEATURE
106 // FEATURE
107 } else if (!state.inKeywordLine && state.allowFeature && stream.match(/(機能|功能|フィーチャ|기능|โครงหลัก|ความสามารถ|ความต้องการทางธุรกิจ|ಹೆಚ್ಚಳ|గుణము|ਮੁਹਾਂਦਰਾ|ਨਕਸ਼ ਨੁਹਾਰ|ਖਾਸੀਅਤ|रूप लेख|وِیژگی|خاصية|תכונה|Функціонал|Функция|Функционалност|Функционал|Үзенчәлеклелек|Свойство|Особина|Мөмкинлек|Могућност|Λειτουργία|Δυνατότητα|Właściwość|Vlastnosť|Trajto|Tính năng|Savybė|Pretty much|Požiadavka|Požadavek|Potrzeba biznesowa|Özellik|Osobina|Ominaisuus|Omadus|OH HAI|Mogućnost|Mogucnost|Jellemző|Hwæt|Hwaet|Funzionalità|Funktionalitéit|Funktionalität|Funkcja|Funkcionalnost|Funkcionalitāte|Funkcia|Fungsi|Functionaliteit|Funcționalitate|Funcţionalitate|Functionalitate|Funcionalitat|Funcionalidade|Fonctionnalité|Fitur|Fīča|Feature|Eiginleiki|Egenskap|Egenskab|Característica|Caracteristica|Business Need|Aspekt|Arwedd|Ahoy matey!|Ability):/)) {
107 } else if (!state.inKeywordLine && state.allowFeature && stream.match(/(機能|功能|フィーチャ|기능|โครงหลัก|ความสามารถ|ความต้องการทางธุรกิจ|ಹೆಚ್ಚಳ|గుణము|ਮੁਹਾਂਦਰਾ|ਨਕਸ਼ ਨੁਹਾਰ|ਖਾਸੀਅਤ|रूप लेख|وِیژگی|خاصية|תכונה|Функціонал|Функция|Функционалност|Функционал|Үзенчәлеклелек|Свойство|Особина|Мөмкинлек|Могућност|Λειτουργία|Δυνατότητα|Właściwość|Vlastnosť|Trajto|Tính năng|Savybė|Pretty much|Požiadavka|Požadavek|Potrzeba biznesowa|Özellik|Osobina|Ominaisuus|Omadus|OH HAI|Mogućnost|Mogucnost|Jellemző|Hwæt|Hwaet|Funzionalità|Funktionalitéit|Funktionalität|Funkcja|Funkcionalnost|Funkcionalitāte|Funkcia|Fungsi|Functionaliteit|Funcționalitate|Funcţionalitate|Functionalitate|Funcionalitat|Funcionalidade|Fonctionnalité|Fitur|Fīča|Feature|Eiginleiki|Egenskap|Egenskab|Característica|Caracteristica|Business Need|Aspekt|Arwedd|Ahoy matey!|Ability):/)) {
108 state.allowScenario = true;
108 state.allowScenario = true;
109 state.allowBackground = true;
109 state.allowBackground = true;
110 state.allowPlaceholders = false;
110 state.allowPlaceholders = false;
111 state.allowSteps = false;
111 state.allowSteps = false;
112 state.allowMultilineArgument = false;
112 state.allowMultilineArgument = false;
113 state.inKeywordLine = true;
113 state.inKeywordLine = true;
114 return "keyword";
114 return "keyword";
115
115
116 // BACKGROUND
116 // BACKGROUND
117 } else if (!state.inKeywordLine && state.allowBackground && stream.match(/(背景|배경|แนวคิด|ಹಿನ್ನೆಲೆ|నేపథ్యం|ਪਿਛੋਕੜ|पृष्ठभूमि|زمینه|الخلفية|רקע|Тарих|Предыстория|Предистория|Позадина|Передумова|Основа|Контекст|Кереш|Υπόβαθρο|Założenia|Yo\-ho\-ho|Tausta|Taust|Situācija|Rerefons|Pozadina|Pozadie|Pozadí|Osnova|Latar Belakang|Kontext|Konteksts|Kontekstas|Kontekst|Háttér|Hannergrond|Grundlage|Geçmiş|Fundo|Fono|First off|Dis is what went down|Dasar|Contexto|Contexte|Context|Contesto|Cenário de Fundo|Cenario de Fundo|Cefndir|Bối cảnh|Bakgrunnur|Bakgrunn|Bakgrund|Baggrund|Background|B4|Antecedents|Antecedentes|Ær|Aer|Achtergrond):/)) {
117 } else if (!state.inKeywordLine && state.allowBackground && stream.match(/(背景|배경|แนวคิด|ಹಿನ್ನೆಲೆ|నేపథ్యం|ਪਿਛੋਕੜ|पृष्ठभूमि|زمینه|الخلفية|רקע|Тарих|Предыстория|Предистория|Позадина|Передумова|Основа|Контекст|Кереш|Υπόβαθρο|Założenia|Yo\-ho\-ho|Tausta|Taust|Situācija|Rerefons|Pozadina|Pozadie|Pozadí|Osnova|Latar Belakang|Kontext|Konteksts|Kontekstas|Kontekst|Háttér|Hannergrond|Grundlage|Geçmiş|Fundo|Fono|First off|Dis is what went down|Dasar|Contexto|Contexte|Context|Contesto|Cenário de Fundo|Cenario de Fundo|Cefndir|Bối cảnh|Bakgrunnur|Bakgrunn|Bakgrund|Baggrund|Background|B4|Antecedents|Antecedentes|Ær|Aer|Achtergrond):/)) {
118 state.allowPlaceholders = false;
118 state.allowPlaceholders = false;
119 state.allowSteps = true;
119 state.allowSteps = true;
120 state.allowBackground = false;
120 state.allowBackground = false;
121 state.allowMultilineArgument = false;
121 state.allowMultilineArgument = false;
122 state.inKeywordLine = true;
122 state.inKeywordLine = true;
123 return "keyword";
123 return "keyword";
124
124
125 // SCENARIO OUTLINE
125 // SCENARIO OUTLINE
126 } else if (!state.inKeywordLine && state.allowScenario && stream.match(/(場景大綱|场景大纲|劇本大綱|剧本大纲|テンプレ|シナリオテンプレート|シナリオテンプレ|シナリオアウトライン|시나리오 개요|สรุปเหตุการณ์|โครงสร้างของเหตุการณ์|ವಿವರಣೆ|కథనం|ਪਟਕਥਾ ਰੂਪ ਰੇਖਾ|ਪਟਕਥਾ ਢਾਂਚਾ|परिदृश्य रूपरेखा|سيناريو مخطط|الگوی سناریو|תבנית תרחיש|Сценарийның төзелеше|Сценарий структураси|Структура сценарію|Структура сценария|Структура сценарија|Скица|Рамка на сценарий|Концепт|Περιγραφή Σεναρίου|Wharrimean is|Template Situai|Template Senario|Template Keadaan|Tapausaihio|Szenariogrundriss|Szablon scenariusza|Swa hwær swa|Swa hwaer swa|Struktura scenarija|Structură scenariu|Structura scenariu|Skica|Skenario konsep|Shiver me timbers|Senaryo taslağı|Schema dello scenario|Scenariomall|Scenariomal|Scenario Template|Scenario Outline|Scenario Amlinellol|Scenārijs pēc parauga|Scenarijaus šablonas|Reckon it's like|Raamstsenaarium|Plang vum Szenario|Plan du Scénario|Plan du scénario|Osnova scénáře|Osnova Scenára|Náčrt Scenáru|Náčrt Scénáře|Náčrt Scenára|MISHUN SRSLY|Menggariskan Senario|Lýsing Dæma|Lýsing Atburðarásar|Konturo de la scenaro|Koncept|Khung tình huống|Khung kịch bản|Forgatókönyv vázlat|Esquema do Cenário|Esquema do Cenario|Esquema del escenario|Esquema de l'escenari|Esbozo do escenario|Delineação do Cenário|Delineacao do Cenario|All y'all|Abstrakt Scenario|Abstract Scenario):/)) {
126 } else if (!state.inKeywordLine && state.allowScenario && stream.match(/(場景大綱|场景大纲|劇本大綱|剧本大纲|テンプレ|シナリオテンプレート|シナリオテンプレ|シナリオアウトライン|시나리오 개요|สรุปเหตุการณ์|โครงสร้างของเหตุการณ์|ವಿವರಣೆ|కథనం|ਪਟਕਥਾ ਰੂਪ ਰੇਖਾ|ਪਟਕਥਾ ਢਾਂਚਾ|परिदृश्य रूपरेखा|سيناريو مخطط|الگوی سناریو|תבנית תרחיש|Сценарийның төзелеше|Сценарий структураси|Структура сценарію|Структура сценария|Структура сценарија|Скица|Рамка на сценарий|Концепт|Περιγραφή Σεναρίου|Wharrimean is|Template Situai|Template Senario|Template Keadaan|Tapausaihio|Szenariogrundriss|Szablon scenariusza|Swa hwær swa|Swa hwaer swa|Struktura scenarija|Structură scenariu|Structura scenariu|Skica|Skenario konsep|Shiver me timbers|Senaryo taslağı|Schema dello scenario|Scenariomall|Scenariomal|Scenario Template|Scenario Outline|Scenario Amlinellol|Scenārijs pēc parauga|Scenarijaus šablonas|Reckon it's like|Raamstsenaarium|Plang vum Szenario|Plan du Scénario|Plan du scénario|Osnova scénáře|Osnova Scenára|Náčrt Scenáru|Náčrt Scénáře|Náčrt Scenára|MISHUN SRSLY|Menggariskan Senario|Lýsing Dæma|Lýsing Atburðarásar|Konturo de la scenaro|Koncept|Khung tình huống|Khung kịch bản|Forgatókönyv vázlat|Esquema do Cenário|Esquema do Cenario|Esquema del escenario|Esquema de l'escenari|Esbozo do escenario|Delineação do Cenário|Delineacao do Cenario|All y'all|Abstrakt Scenario|Abstract Scenario):/)) {
127 state.allowPlaceholders = true;
127 state.allowPlaceholders = true;
128 state.allowSteps = true;
128 state.allowSteps = true;
129 state.allowMultilineArgument = false;
129 state.allowMultilineArgument = false;
130 state.inKeywordLine = true;
130 state.inKeywordLine = true;
131 return "keyword";
131 return "keyword";
132
132
133 // EXAMPLES
133 // EXAMPLES
134 } else if (state.allowScenario && stream.match(/(例子|例|サンプル|예|ชุดของเหตุการณ์|ชุดของตัวอย่าง|ಉದಾಹರಣೆಗಳು|ఉదాహరణలు|ਉਦਾਹਰਨਾਂ|उदाहरण|نمونه ها|امثلة|דוגמאות|Үрнәкләр|Сценарији|Примеры|Примери|Приклади|Мисоллар|Мисаллар|Σενάρια|Παραδείγματα|You'll wanna|Voorbeelden|Variantai|Tapaukset|Se þe|Se the|Se ðe|Scenarios|Scenariji|Scenarijai|Przykłady|Primjeri|Primeri|Příklady|Príklady|Piemēri|Példák|Pavyzdžiai|Paraugs|Örnekler|Juhtumid|Exemplos|Exemples|Exemple|Exempel|EXAMPLZ|Examples|Esempi|Enghreifftiau|Ekzemploj|Eksempler|Ejemplos|Dữ liệu|Dead men tell no tales|Dæmi|Contoh|Cenários|Cenarios|Beispiller|Beispiele|Atburðarásir):/)) {
134 } else if (state.allowScenario && stream.match(/(例子|例|サンプル|예|ชุดของเหตุการณ์|ชุดของตัวอย่าง|ಉದಾಹರಣೆಗಳು|ఉదాహరణలు|ਉਦਾਹਰਨਾਂ|उदाहरण|نمونه ها|امثلة|דוגמאות|Үрнәкләр|Сценарији|Примеры|Примери|Приклади|Мисоллар|Мисаллар|Σενάρια|Παραδείγματα|You'll wanna|Voorbeelden|Variantai|Tapaukset|Se þe|Se the|Se ðe|Scenarios|Scenariji|Scenarijai|Przykłady|Primjeri|Primeri|Příklady|Príklady|Piemēri|Példák|Pavyzdžiai|Paraugs|Örnekler|Juhtumid|Exemplos|Exemples|Exemple|Exempel|EXAMPLZ|Examples|Esempi|Enghreifftiau|Ekzemploj|Eksempler|Ejemplos|Dữ liệu|Dead men tell no tales|Dæmi|Contoh|Cenários|Cenarios|Beispiller|Beispiele|Atburðarásir):/)) {
135 state.allowPlaceholders = false;
135 state.allowPlaceholders = false;
136 state.allowSteps = true;
136 state.allowSteps = true;
137 state.allowBackground = false;
137 state.allowBackground = false;
138 state.allowMultilineArgument = true;
138 state.allowMultilineArgument = true;
139 return "keyword";
139 return "keyword";
140
140
141 // SCENARIO
141 // SCENARIO
142 } else if (!state.inKeywordLine && state.allowScenario && stream.match(/(場景|场景|劇本|剧本|シナリオ|시나리오|เหตุการณ์|ಕಥಾಸಾರಾಂಶ|సన్నివేశం|ਪਟਕਥਾ|परिदृश्य|سيناريو|سناریو|תרחיש|Сценарій|Сценарио|Сценарий|Пример|Σενάριο|Tình huống|The thing of it is|Tapaus|Szenario|Swa|Stsenaarium|Skenario|Situai|Senaryo|Senario|Scenaro|Scenariusz|Scenariu|Scénario|Scenario|Scenarijus|Scenārijs|Scenarij|Scenarie|Scénář|Scenár|Primer|MISHUN|Kịch bản|Keadaan|Heave to|Forgatókönyv|Escenario|Escenari|Cenário|Cenario|Awww, look mate|Atburðarás):/)) {
142 } else if (!state.inKeywordLine && state.allowScenario && stream.match(/(場景|场景|劇本|剧本|シナリオ|시나리오|เหตุการณ์|ಕಥಾಸಾರಾಂಶ|సన్నివేశం|ਪਟਕਥਾ|परिदृश्य|سيناريو|سناریو|תרחיש|Сценарій|Сценарио|Сценарий|Пример|Σενάριο|Tình huống|The thing of it is|Tapaus|Szenario|Swa|Stsenaarium|Skenario|Situai|Senaryo|Senario|Scenaro|Scenariusz|Scenariu|Scénario|Scenario|Scenarijus|Scenārijs|Scenarij|Scenarie|Scénář|Scenár|Primer|MISHUN|Kịch bản|Keadaan|Heave to|Forgatókönyv|Escenario|Escenari|Cenário|Cenario|Awww, look mate|Atburðarás):/)) {
143 state.allowPlaceholders = false;
143 state.allowPlaceholders = false;
144 state.allowSteps = true;
144 state.allowSteps = true;
145 state.allowBackground = false;
145 state.allowBackground = false;
146 state.allowMultilineArgument = false;
146 state.allowMultilineArgument = false;
147 state.inKeywordLine = true;
147 state.inKeywordLine = true;
148 return "keyword";
148 return "keyword";
149
149
150 // STEPS
150 // STEPS
151 } else if (!state.inKeywordLine && state.allowSteps && stream.match(/(那麼|那么|而且|當|当|并且|同時|同时|前提|假设|假設|假定|假如|但是|但し|並且|もし|ならば|ただし|しかし|かつ|하지만|조건|먼저|만일|만약|단|그리고|그러면|และ |เมื่อ |แต่ |ดังนั้น |กำหนดให้ |ಸ್ಥಿತಿಯನ್ನು |ಮತ್ತು |ನೀಡಿದ |ನಂತರ |ಆದರೆ |మరియు |చెప్పబడినది |కాని |ఈ పరిస్థితిలో |అప్పుడు |ਪਰ |ਤਦ |ਜੇਕਰ |ਜਿਵੇਂ ਕਿ |ਜਦੋਂ |ਅਤੇ |यदि |परन्तु |पर |तब |तदा |तथा |जब |चूंकि |किन्तु |कदा |और |अगर |و |هنگامی |متى |لكن |عندما |ثم |بفرض |با فرض |اما |اذاً |آنگاه |כאשר |וגם |בהינתן |אזי |אז |אבל |Якщо |Һәм |Унда |Тоді |Тогда |То |Также |Та |Пусть |Припустимо, що |Припустимо |Онда |Но |Нехай |Нәтиҗәдә |Лекин |Ләкин |Коли |Когда |Когато |Када |Кад |К тому же |І |И |Задато |Задати |Задате |Если |Допустим |Дано |Дадено |Вә |Ва |Бирок |Әмма |Әйтик |Әгәр |Аммо |Али |Але |Агар |А також |А |Τότε |Όταν |Και |Δεδομένου |Αλλά |Þurh |Þegar |Þa þe |Þá |Þa |Zatati |Zakładając |Zadato |Zadate |Zadano |Zadani |Zadan |Za předpokladu |Za predpokladu |Youse know when youse got |Youse know like when |Yna |Yeah nah |Y'know |Y |Wun |Wtedy |When y'all |When |Wenn |WEN |wann |Ve |Và |Und |Un |ugeholl |Too right |Thurh |Thì |Then y'all |Then |Tha the |Tha |Tetapi |Tapi |Tak |Tada |Tad |Stel |Soit |Siis |Și |Şi |Si |Sed |Se |Så |Quando |Quand |Quan |Pryd |Potom |Pokud |Pokiaľ |Però |Pero |Pak |Oraz |Onda |Ond |Oletetaan |Og |Och |O zaman |Niin |Nhưng |När |Når |Mutta |Men |Mas |Maka |Majd |Mając |Mais |Maar |mä |Ma |Lorsque |Lorsqu'|Logo |Let go and haul |Kun |Kuid |Kui |Kiedy |Khi |Ketika |Kemudian |Keď |Když |Kaj |Kai |Kada |Kad |Jeżeli |Jeśli |Ja |It's just unbelievable |Ir |I CAN HAZ |I |Ha |Givun |Givet |Given y'all |Given |Gitt |Gegeven |Gegeben seien |Gegeben sei |Gdy |Gangway! |Fakat |Étant donnés |Etant donnés |Étant données |Etant données |Étant donnée |Etant donnée |Étant donné |Etant donné |Et |És |Entonces |Entón |Então |Entao |En |Eğer ki |Ef |Eeldades |E |Ðurh |Duota |Dun |Donitaĵo |Donat |Donada |Do |Diyelim ki |Diberi |Dengan |Den youse gotta |DEN |De |Dato |Dați fiind |Daţi fiind |Dati fiind |Dati |Date fiind |Date |Data |Dat fiind |Dar |Dann |dann |Dan |Dados |Dado |Dadas |Dada |Ða ðe |Ða |Cuando |Cho |Cando |Când |Cand |Cal |But y'all |But at the end of the day I reckon |BUT |But |Buh |Blimey! |Biết |Bet |Bagi |Aye |awer |Avast! |Atunci |Atesa |Atès |Apabila |Anrhegedig a |Angenommen |And y'all |And |AN |An |an |Amikor |Amennyiben |Ama |Als |Alors |Allora |Ali |Aleshores |Ale |Akkor |Ak |Adott |Ac |Aber |A zároveň |A tiež |A taktiež |A také |A |a |7 |\* )/)) {
151 } else if (!state.inKeywordLine && state.allowSteps && stream.match(/(那麼|那么|而且|當|当|并且|同時|同时|前提|假设|假設|假定|假如|但是|但し|並且|もし|ならば|ただし|しかし|かつ|하지만|조건|먼저|만일|만약|단|그리고|그러면|และ |เมื่อ |แต่ |ดังนั้น |กำหนดให้ |ಸ್ಥಿತಿಯನ್ನು |ಮತ್ತು |ನೀಡಿದ |ನಂತರ |ಆದರೆ |మరియు |చెప్పబడినది |కాని |ఈ పరిస్థితిలో |అప్పుడు |ਪਰ |ਤਦ |ਜੇਕਰ |ਜਿਵੇਂ ਕਿ |ਜਦੋਂ |ਅਤੇ |यदि |परन्तु |पर |तब |तदा |तथा |जब |चूंकि |किन्तु |कदा |और |अगर |و |هنگامی |متى |لكن |عندما |ثم |بفرض |با فرض |اما |اذاً |آنگاه |כאשר |וגם |בהינתן |אזי |אז |אבל |Якщо |Һәм |Унда |Тоді |Тогда |То |Также |Та |Пусть |Припустимо, що |Припустимо |Онда |Но |Нехай |Нәтиҗәдә |Лекин |Ләкин |Коли |Когда |Когато |Када |Кад |К тому же |І |И |Задато |Задати |Задате |Если |Допустим |Дано |Дадено |Вә |Ва |Бирок |Әмма |Әйтик |Әгәр |Аммо |Али |Але |Агар |А також |А |Τότε |Όταν |Και |Δεδομένου |Αλλά |Þurh |Þegar |Þa þe |Þá |Þa |Zatati |Zakładając |Zadato |Zadate |Zadano |Zadani |Zadan |Za předpokladu |Za predpokladu |Youse know when youse got |Youse know like when |Yna |Yeah nah |Y'know |Y |Wun |Wtedy |When y'all |When |Wenn |WEN |wann |Ve |Và |Und |Un |ugeholl |Too right |Thurh |Thì |Then y'all |Then |Tha the |Tha |Tetapi |Tapi |Tak |Tada |Tad |Stel |Soit |Siis |Și |Şi |Si |Sed |Se |Så |Quando |Quand |Quan |Pryd |Potom |Pokud |Pokiaľ |Però |Pero |Pak |Oraz |Onda |Ond |Oletetaan |Og |Och |O zaman |Niin |Nhưng |När |Når |Mutta |Men |Mas |Maka |Majd |Mając |Mais |Maar |mä |Ma |Lorsque |Lorsqu'|Logo |Let go and haul |Kun |Kuid |Kui |Kiedy |Khi |Ketika |Kemudian |Keď |Když |Kaj |Kai |Kada |Kad |Jeżeli |Jeśli |Ja |It's just unbelievable |Ir |I CAN HAZ |I |Ha |Givun |Givet |Given y'all |Given |Gitt |Gegeven |Gegeben seien |Gegeben sei |Gdy |Gangway! |Fakat |Étant donnés |Etant donnés |Étant données |Etant données |Étant donnée |Etant donnée |Étant donné |Etant donné |Et |És |Entonces |Entón |Então |Entao |En |Eğer ki |Ef |Eeldades |E |Ðurh |Duota |Dun |Donitaĵo |Donat |Donada |Do |Diyelim ki |Diberi |Dengan |Den youse gotta |DEN |De |Dato |Dați fiind |Daţi fiind |Dati fiind |Dati |Date fiind |Date |Data |Dat fiind |Dar |Dann |dann |Dan |Dados |Dado |Dadas |Dada |Ða ðe |Ða |Cuando |Cho |Cando |Când |Cand |Cal |But y'all |But at the end of the day I reckon |BUT |But |Buh |Blimey! |Biết |Bet |Bagi |Aye |awer |Avast! |Atunci |Atesa |Atès |Apabila |Anrhegedig a |Angenommen |And y'all |And |AN |An |an |Amikor |Amennyiben |Ama |Als |Alors |Allora |Ali |Aleshores |Ale |Akkor |Ak |Adott |Ac |Aber |A zároveň |A tiež |A taktiež |A také |A |a |7 |\* )/)) {
152 state.inStep = true;
152 state.inStep = true;
153 state.allowPlaceholders = true;
153 state.allowPlaceholders = true;
154 state.allowMultilineArgument = true;
154 state.allowMultilineArgument = true;
155 state.inKeywordLine = true;
155 state.inKeywordLine = true;
156 return "keyword";
156 return "keyword";
157
157
158 // INLINE STRING
158 // INLINE STRING
159 } else if (stream.match(/"[^"]*"?/)) {
159 } else if (stream.match(/"[^"]*"?/)) {
160 return "string";
160 return "string";
161
161
162 // PLACEHOLDER
162 // PLACEHOLDER
163 } else if (state.allowPlaceholders && stream.match(/<[^>]*>?/)) {
163 } else if (state.allowPlaceholders && stream.match(/<[^>]*>?/)) {
164 return "variable";
164 return "variable";
165
165
166 // Fall through
166 // Fall through
167 } else {
167 } else {
168 stream.next();
168 stream.next();
169 stream.eatWhile(/[^@"<#]/);
169 stream.eatWhile(/[^@"<#]/);
170 return null;
170 return null;
171 }
171 }
172 }
172 }
173 };
173 };
174 });
174 });
175
175
176 CodeMirror.defineMIME("text/x-feature", "gherkin");
176 CodeMirror.defineMIME("text/x-feature", "gherkin");
177
177
178 });
178 });
@@ -1,185 +1,187 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("go", function(config) {
14 CodeMirror.defineMode("go", function(config) {
15 var indentUnit = config.indentUnit;
15 var indentUnit = config.indentUnit;
16
16
17 var keywords = {
17 var keywords = {
18 "break":true, "case":true, "chan":true, "const":true, "continue":true,
18 "break":true, "case":true, "chan":true, "const":true, "continue":true,
19 "default":true, "defer":true, "else":true, "fallthrough":true, "for":true,
19 "default":true, "defer":true, "else":true, "fallthrough":true, "for":true,
20 "func":true, "go":true, "goto":true, "if":true, "import":true,
20 "func":true, "go":true, "goto":true, "if":true, "import":true,
21 "interface":true, "map":true, "package":true, "range":true, "return":true,
21 "interface":true, "map":true, "package":true, "range":true, "return":true,
22 "select":true, "struct":true, "switch":true, "type":true, "var":true,
22 "select":true, "struct":true, "switch":true, "type":true, "var":true,
23 "bool":true, "byte":true, "complex64":true, "complex128":true,
23 "bool":true, "byte":true, "complex64":true, "complex128":true,
24 "float32":true, "float64":true, "int8":true, "int16":true, "int32":true,
24 "float32":true, "float64":true, "int8":true, "int16":true, "int32":true,
25 "int64":true, "string":true, "uint8":true, "uint16":true, "uint32":true,
25 "int64":true, "string":true, "uint8":true, "uint16":true, "uint32":true,
26 "uint64":true, "int":true, "uint":true, "uintptr":true
26 "uint64":true, "int":true, "uint":true, "uintptr":true, "error": true,
27 "rune":true
27 };
28 };
28
29
29 var atoms = {
30 var atoms = {
30 "true":true, "false":true, "iota":true, "nil":true, "append":true,
31 "true":true, "false":true, "iota":true, "nil":true, "append":true,
31 "cap":true, "close":true, "complex":true, "copy":true, "imag":true,
32 "cap":true, "close":true, "complex":true, "copy":true, "delete":true, "imag":true,
32 "len":true, "make":true, "new":true, "panic":true, "print":true,
33 "len":true, "make":true, "new":true, "panic":true, "print":true,
33 "println":true, "real":true, "recover":true
34 "println":true, "real":true, "recover":true
34 };
35 };
35
36
36 var isOperatorChar = /[+\-*&^%:=<>!|\/]/;
37 var isOperatorChar = /[+\-*&^%:=<>!|\/]/;
37
38
38 var curPunc;
39 var curPunc;
39
40
40 function tokenBase(stream, state) {
41 function tokenBase(stream, state) {
41 var ch = stream.next();
42 var ch = stream.next();
42 if (ch == '"' || ch == "'" || ch == "`") {
43 if (ch == '"' || ch == "'" || ch == "`") {
43 state.tokenize = tokenString(ch);
44 state.tokenize = tokenString(ch);
44 return state.tokenize(stream, state);
45 return state.tokenize(stream, state);
45 }
46 }
46 if (/[\d\.]/.test(ch)) {
47 if (/[\d\.]/.test(ch)) {
47 if (ch == ".") {
48 if (ch == ".") {
48 stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/);
49 stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/);
49 } else if (ch == "0") {
50 } else if (ch == "0") {
50 stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/);
51 stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/);
51 } else {
52 } else {
52 stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/);
53 stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/);
53 }
54 }
54 return "number";
55 return "number";
55 }
56 }
56 if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
57 if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
57 curPunc = ch;
58 curPunc = ch;
58 return null;
59 return null;
59 }
60 }
60 if (ch == "/") {
61 if (ch == "/") {
61 if (stream.eat("*")) {
62 if (stream.eat("*")) {
62 state.tokenize = tokenComment;
63 state.tokenize = tokenComment;
63 return tokenComment(stream, state);
64 return tokenComment(stream, state);
64 }
65 }
65 if (stream.eat("/")) {
66 if (stream.eat("/")) {
66 stream.skipToEnd();
67 stream.skipToEnd();
67 return "comment";
68 return "comment";
68 }
69 }
69 }
70 }
70 if (isOperatorChar.test(ch)) {
71 if (isOperatorChar.test(ch)) {
71 stream.eatWhile(isOperatorChar);
72 stream.eatWhile(isOperatorChar);
72 return "operator";
73 return "operator";
73 }
74 }
74 stream.eatWhile(/[\w\$_\xa1-\uffff]/);
75 stream.eatWhile(/[\w\$_\xa1-\uffff]/);
75 var cur = stream.current();
76 var cur = stream.current();
76 if (keywords.propertyIsEnumerable(cur)) {
77 if (keywords.propertyIsEnumerable(cur)) {
77 if (cur == "case" || cur == "default") curPunc = "case";
78 if (cur == "case" || cur == "default") curPunc = "case";
78 return "keyword";
79 return "keyword";
79 }
80 }
80 if (atoms.propertyIsEnumerable(cur)) return "atom";
81 if (atoms.propertyIsEnumerable(cur)) return "atom";
81 return "variable";
82 return "variable";
82 }
83 }
83
84
84 function tokenString(quote) {
85 function tokenString(quote) {
85 return function(stream, state) {
86 return function(stream, state) {
86 var escaped = false, next, end = false;
87 var escaped = false, next, end = false;
87 while ((next = stream.next()) != null) {
88 while ((next = stream.next()) != null) {
88 if (next == quote && !escaped) {end = true; break;}
89 if (next == quote && !escaped) {end = true; break;}
89 escaped = !escaped && quote != "`" && next == "\\";
90 escaped = !escaped && quote != "`" && next == "\\";
90 }
91 }
91 if (end || !(escaped || quote == "`"))
92 if (end || !(escaped || quote == "`"))
92 state.tokenize = tokenBase;
93 state.tokenize = tokenBase;
93 return "string";
94 return "string";
94 };
95 };
95 }
96 }
96
97
97 function tokenComment(stream, state) {
98 function tokenComment(stream, state) {
98 var maybeEnd = false, ch;
99 var maybeEnd = false, ch;
99 while (ch = stream.next()) {
100 while (ch = stream.next()) {
100 if (ch == "/" && maybeEnd) {
101 if (ch == "/" && maybeEnd) {
101 state.tokenize = tokenBase;
102 state.tokenize = tokenBase;
102 break;
103 break;
103 }
104 }
104 maybeEnd = (ch == "*");
105 maybeEnd = (ch == "*");
105 }
106 }
106 return "comment";
107 return "comment";
107 }
108 }
108
109
109 function Context(indented, column, type, align, prev) {
110 function Context(indented, column, type, align, prev) {
110 this.indented = indented;
111 this.indented = indented;
111 this.column = column;
112 this.column = column;
112 this.type = type;
113 this.type = type;
113 this.align = align;
114 this.align = align;
114 this.prev = prev;
115 this.prev = prev;
115 }
116 }
116 function pushContext(state, col, type) {
117 function pushContext(state, col, type) {
117 return state.context = new Context(state.indented, col, type, null, state.context);
118 return state.context = new Context(state.indented, col, type, null, state.context);
118 }
119 }
119 function popContext(state) {
120 function popContext(state) {
120 if (!state.context.prev) return;
121 if (!state.context.prev) return;
121 var t = state.context.type;
122 var t = state.context.type;
122 if (t == ")" || t == "]" || t == "}")
123 if (t == ")" || t == "]" || t == "}")
123 state.indented = state.context.indented;
124 state.indented = state.context.indented;
124 return state.context = state.context.prev;
125 return state.context = state.context.prev;
125 }
126 }
126
127
127 // Interface
128 // Interface
128
129
129 return {
130 return {
130 startState: function(basecolumn) {
131 startState: function(basecolumn) {
131 return {
132 return {
132 tokenize: null,
133 tokenize: null,
133 context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
134 context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
134 indented: 0,
135 indented: 0,
135 startOfLine: true
136 startOfLine: true
136 };
137 };
137 },
138 },
138
139
139 token: function(stream, state) {
140 token: function(stream, state) {
140 var ctx = state.context;
141 var ctx = state.context;
141 if (stream.sol()) {
142 if (stream.sol()) {
142 if (ctx.align == null) ctx.align = false;
143 if (ctx.align == null) ctx.align = false;
143 state.indented = stream.indentation();
144 state.indented = stream.indentation();
144 state.startOfLine = true;
145 state.startOfLine = true;
145 if (ctx.type == "case") ctx.type = "}";
146 if (ctx.type == "case") ctx.type = "}";
146 }
147 }
147 if (stream.eatSpace()) return null;
148 if (stream.eatSpace()) return null;
148 curPunc = null;
149 curPunc = null;
149 var style = (state.tokenize || tokenBase)(stream, state);
150 var style = (state.tokenize || tokenBase)(stream, state);
150 if (style == "comment") return style;
151 if (style == "comment") return style;
151 if (ctx.align == null) ctx.align = true;
152 if (ctx.align == null) ctx.align = true;
152
153
153 if (curPunc == "{") pushContext(state, stream.column(), "}");
154 if (curPunc == "{") pushContext(state, stream.column(), "}");
154 else if (curPunc == "[") pushContext(state, stream.column(), "]");
155 else if (curPunc == "[") pushContext(state, stream.column(), "]");
155 else if (curPunc == "(") pushContext(state, stream.column(), ")");
156 else if (curPunc == "(") pushContext(state, stream.column(), ")");
156 else if (curPunc == "case") ctx.type = "case";
157 else if (curPunc == "case") ctx.type = "case";
157 else if (curPunc == "}" && ctx.type == "}") ctx = popContext(state);
158 else if (curPunc == "}" && ctx.type == "}") popContext(state);
158 else if (curPunc == ctx.type) popContext(state);
159 else if (curPunc == ctx.type) popContext(state);
159 state.startOfLine = false;
160 state.startOfLine = false;
160 return style;
161 return style;
161 },
162 },
162
163
163 indent: function(state, textAfter) {
164 indent: function(state, textAfter) {
164 if (state.tokenize != tokenBase && state.tokenize != null) return 0;
165 if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
165 var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
166 var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
166 if (ctx.type == "case" && /^(?:case|default)\b/.test(textAfter)) {
167 if (ctx.type == "case" && /^(?:case|default)\b/.test(textAfter)) {
167 state.context.type = "}";
168 state.context.type = "}";
168 return ctx.indented;
169 return ctx.indented;
169 }
170 }
170 var closing = firstChar == ctx.type;
171 var closing = firstChar == ctx.type;
171 if (ctx.align) return ctx.column + (closing ? 0 : 1);
172 if (ctx.align) return ctx.column + (closing ? 0 : 1);
172 else return ctx.indented + (closing ? 0 : indentUnit);
173 else return ctx.indented + (closing ? 0 : indentUnit);
173 },
174 },
174
175
175 electricChars: "{}):",
176 electricChars: "{}):",
177 closeBrackets: "()[]{}''\"\"``",
176 fold: "brace",
178 fold: "brace",
177 blockCommentStart: "/*",
179 blockCommentStart: "/*",
178 blockCommentEnd: "*/",
180 blockCommentEnd: "*/",
179 lineComment: "//"
181 lineComment: "//"
180 };
182 };
181 });
183 });
182
184
183 CodeMirror.defineMIME("text/x-go", "go");
185 CodeMirror.defineMIME("text/x-go", "go");
184
186
185 });
187 });
@@ -1,230 +1,233 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("groovy", function(config) {
14 CodeMirror.defineMode("groovy", function(config) {
15 function words(str) {
15 function words(str) {
16 var obj = {}, words = str.split(" ");
16 var obj = {}, words = str.split(" ");
17 for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
17 for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
18 return obj;
18 return obj;
19 }
19 }
20 var keywords = words(
20 var keywords = words(
21 "abstract as assert boolean break byte case catch char class const continue def default " +
21 "abstract as assert boolean break byte case catch char class const continue def default " +
22 "do double else enum extends final finally float for goto if implements import in " +
22 "do double else enum extends final finally float for goto if implements import in " +
23 "instanceof int interface long native new package private protected public return " +
23 "instanceof int interface long native new package private protected public return " +
24 "short static strictfp super switch synchronized threadsafe throw throws transient " +
24 "short static strictfp super switch synchronized threadsafe throw throws trait transient " +
25 "try void volatile while");
25 "try void volatile while");
26 var blockKeywords = words("catch class do else finally for if switch try while enum interface def");
26 var blockKeywords = words("catch class def do else enum finally for if interface switch trait try while");
27 var standaloneKeywords = words("return break continue");
27 var standaloneKeywords = words("return break continue");
28 var atoms = words("null true false this");
28 var atoms = words("null true false this");
29
29
30 var curPunc;
30 var curPunc;
31 function tokenBase(stream, state) {
31 function tokenBase(stream, state) {
32 var ch = stream.next();
32 var ch = stream.next();
33 if (ch == '"' || ch == "'") {
33 if (ch == '"' || ch == "'") {
34 return startString(ch, stream, state);
34 return startString(ch, stream, state);
35 }
35 }
36 if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
36 if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
37 curPunc = ch;
37 curPunc = ch;
38 return null;
38 return null;
39 }
39 }
40 if (/\d/.test(ch)) {
40 if (/\d/.test(ch)) {
41 stream.eatWhile(/[\w\.]/);
41 stream.eatWhile(/[\w\.]/);
42 if (stream.eat(/eE/)) { stream.eat(/\+\-/); stream.eatWhile(/\d/); }
42 if (stream.eat(/eE/)) { stream.eat(/\+\-/); stream.eatWhile(/\d/); }
43 return "number";
43 return "number";
44 }
44 }
45 if (ch == "/") {
45 if (ch == "/") {
46 if (stream.eat("*")) {
46 if (stream.eat("*")) {
47 state.tokenize.push(tokenComment);
47 state.tokenize.push(tokenComment);
48 return tokenComment(stream, state);
48 return tokenComment(stream, state);
49 }
49 }
50 if (stream.eat("/")) {
50 if (stream.eat("/")) {
51 stream.skipToEnd();
51 stream.skipToEnd();
52 return "comment";
52 return "comment";
53 }
53 }
54 if (expectExpression(state.lastToken, false)) {
54 if (expectExpression(state.lastToken, false)) {
55 return startString(ch, stream, state);
55 return startString(ch, stream, state);
56 }
56 }
57 }
57 }
58 if (ch == "-" && stream.eat(">")) {
58 if (ch == "-" && stream.eat(">")) {
59 curPunc = "->";
59 curPunc = "->";
60 return null;
60 return null;
61 }
61 }
62 if (/[+\-*&%=<>!?|\/~]/.test(ch)) {
62 if (/[+\-*&%=<>!?|\/~]/.test(ch)) {
63 stream.eatWhile(/[+\-*&%=<>|~]/);
63 stream.eatWhile(/[+\-*&%=<>|~]/);
64 return "operator";
64 return "operator";
65 }
65 }
66 stream.eatWhile(/[\w\$_]/);
66 stream.eatWhile(/[\w\$_]/);
67 if (ch == "@") { stream.eatWhile(/[\w\$_\.]/); return "meta"; }
67 if (ch == "@") { stream.eatWhile(/[\w\$_\.]/); return "meta"; }
68 if (state.lastToken == ".") return "property";
68 if (state.lastToken == ".") return "property";
69 if (stream.eat(":")) { curPunc = "proplabel"; return "property"; }
69 if (stream.eat(":")) { curPunc = "proplabel"; return "property"; }
70 var cur = stream.current();
70 var cur = stream.current();
71 if (atoms.propertyIsEnumerable(cur)) { return "atom"; }
71 if (atoms.propertyIsEnumerable(cur)) { return "atom"; }
72 if (keywords.propertyIsEnumerable(cur)) {
72 if (keywords.propertyIsEnumerable(cur)) {
73 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
73 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
74 else if (standaloneKeywords.propertyIsEnumerable(cur)) curPunc = "standalone";
74 else if (standaloneKeywords.propertyIsEnumerable(cur)) curPunc = "standalone";
75 return "keyword";
75 return "keyword";
76 }
76 }
77 return "variable";
77 return "variable";
78 }
78 }
79 tokenBase.isBase = true;
79 tokenBase.isBase = true;
80
80
81 function startString(quote, stream, state) {
81 function startString(quote, stream, state) {
82 var tripleQuoted = false;
82 var tripleQuoted = false;
83 if (quote != "/" && stream.eat(quote)) {
83 if (quote != "/" && stream.eat(quote)) {
84 if (stream.eat(quote)) tripleQuoted = true;
84 if (stream.eat(quote)) tripleQuoted = true;
85 else return "string";
85 else return "string";
86 }
86 }
87 function t(stream, state) {
87 function t(stream, state) {
88 var escaped = false, next, end = !tripleQuoted;
88 var escaped = false, next, end = !tripleQuoted;
89 while ((next = stream.next()) != null) {
89 while ((next = stream.next()) != null) {
90 if (next == quote && !escaped) {
90 if (next == quote && !escaped) {
91 if (!tripleQuoted) { break; }
91 if (!tripleQuoted) { break; }
92 if (stream.match(quote + quote)) { end = true; break; }
92 if (stream.match(quote + quote)) { end = true; break; }
93 }
93 }
94 if (quote == '"' && next == "$" && !escaped && stream.eat("{")) {
94 if (quote == '"' && next == "$" && !escaped && stream.eat("{")) {
95 state.tokenize.push(tokenBaseUntilBrace());
95 state.tokenize.push(tokenBaseUntilBrace());
96 return "string";
96 return "string";
97 }
97 }
98 escaped = !escaped && next == "\\";
98 escaped = !escaped && next == "\\";
99 }
99 }
100 if (end) state.tokenize.pop();
100 if (end) state.tokenize.pop();
101 return "string";
101 return "string";
102 }
102 }
103 state.tokenize.push(t);
103 state.tokenize.push(t);
104 return t(stream, state);
104 return t(stream, state);
105 }
105 }
106
106
107 function tokenBaseUntilBrace() {
107 function tokenBaseUntilBrace() {
108 var depth = 1;
108 var depth = 1;
109 function t(stream, state) {
109 function t(stream, state) {
110 if (stream.peek() == "}") {
110 if (stream.peek() == "}") {
111 depth--;
111 depth--;
112 if (depth == 0) {
112 if (depth == 0) {
113 state.tokenize.pop();
113 state.tokenize.pop();
114 return state.tokenize[state.tokenize.length-1](stream, state);
114 return state.tokenize[state.tokenize.length-1](stream, state);
115 }
115 }
116 } else if (stream.peek() == "{") {
116 } else if (stream.peek() == "{") {
117 depth++;
117 depth++;
118 }
118 }
119 return tokenBase(stream, state);
119 return tokenBase(stream, state);
120 }
120 }
121 t.isBase = true;
121 t.isBase = true;
122 return t;
122 return t;
123 }
123 }
124
124
125 function tokenComment(stream, state) {
125 function tokenComment(stream, state) {
126 var maybeEnd = false, ch;
126 var maybeEnd = false, ch;
127 while (ch = stream.next()) {
127 while (ch = stream.next()) {
128 if (ch == "/" && maybeEnd) {
128 if (ch == "/" && maybeEnd) {
129 state.tokenize.pop();
129 state.tokenize.pop();
130 break;
130 break;
131 }
131 }
132 maybeEnd = (ch == "*");
132 maybeEnd = (ch == "*");
133 }
133 }
134 return "comment";
134 return "comment";
135 }
135 }
136
136
137 function expectExpression(last, newline) {
137 function expectExpression(last, newline) {
138 return !last || last == "operator" || last == "->" || /[\.\[\{\(,;:]/.test(last) ||
138 return !last || last == "operator" || last == "->" || /[\.\[\{\(,;:]/.test(last) ||
139 last == "newstatement" || last == "keyword" || last == "proplabel" ||
139 last == "newstatement" || last == "keyword" || last == "proplabel" ||
140 (last == "standalone" && !newline);
140 (last == "standalone" && !newline);
141 }
141 }
142
142
143 function Context(indented, column, type, align, prev) {
143 function Context(indented, column, type, align, prev) {
144 this.indented = indented;
144 this.indented = indented;
145 this.column = column;
145 this.column = column;
146 this.type = type;
146 this.type = type;
147 this.align = align;
147 this.align = align;
148 this.prev = prev;
148 this.prev = prev;
149 }
149 }
150 function pushContext(state, col, type) {
150 function pushContext(state, col, type) {
151 return state.context = new Context(state.indented, col, type, null, state.context);
151 return state.context = new Context(state.indented, col, type, null, state.context);
152 }
152 }
153 function popContext(state) {
153 function popContext(state) {
154 var t = state.context.type;
154 var t = state.context.type;
155 if (t == ")" || t == "]" || t == "}")
155 if (t == ")" || t == "]" || t == "}")
156 state.indented = state.context.indented;
156 state.indented = state.context.indented;
157 return state.context = state.context.prev;
157 return state.context = state.context.prev;
158 }
158 }
159
159
160 // Interface
160 // Interface
161
161
162 return {
162 return {
163 startState: function(basecolumn) {
163 startState: function(basecolumn) {
164 return {
164 return {
165 tokenize: [tokenBase],
165 tokenize: [tokenBase],
166 context: new Context((basecolumn || 0) - config.indentUnit, 0, "top", false),
166 context: new Context((basecolumn || 0) - config.indentUnit, 0, "top", false),
167 indented: 0,
167 indented: 0,
168 startOfLine: true,
168 startOfLine: true,
169 lastToken: null
169 lastToken: null
170 };
170 };
171 },
171 },
172
172
173 token: function(stream, state) {
173 token: function(stream, state) {
174 var ctx = state.context;
174 var ctx = state.context;
175 if (stream.sol()) {
175 if (stream.sol()) {
176 if (ctx.align == null) ctx.align = false;
176 if (ctx.align == null) ctx.align = false;
177 state.indented = stream.indentation();
177 state.indented = stream.indentation();
178 state.startOfLine = true;
178 state.startOfLine = true;
179 // Automatic semicolon insertion
179 // Automatic semicolon insertion
180 if (ctx.type == "statement" && !expectExpression(state.lastToken, true)) {
180 if (ctx.type == "statement" && !expectExpression(state.lastToken, true)) {
181 popContext(state); ctx = state.context;
181 popContext(state); ctx = state.context;
182 }
182 }
183 }
183 }
184 if (stream.eatSpace()) return null;
184 if (stream.eatSpace()) return null;
185 curPunc = null;
185 curPunc = null;
186 var style = state.tokenize[state.tokenize.length-1](stream, state);
186 var style = state.tokenize[state.tokenize.length-1](stream, state);
187 if (style == "comment") return style;
187 if (style == "comment") return style;
188 if (ctx.align == null) ctx.align = true;
188 if (ctx.align == null) ctx.align = true;
189
189
190 if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
190 if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
191 // Handle indentation for {x -> \n ... }
191 // Handle indentation for {x -> \n ... }
192 else if (curPunc == "->" && ctx.type == "statement" && ctx.prev.type == "}") {
192 else if (curPunc == "->" && ctx.type == "statement" && ctx.prev.type == "}") {
193 popContext(state);
193 popContext(state);
194 state.context.align = false;
194 state.context.align = false;
195 }
195 }
196 else if (curPunc == "{") pushContext(state, stream.column(), "}");
196 else if (curPunc == "{") pushContext(state, stream.column(), "}");
197 else if (curPunc == "[") pushContext(state, stream.column(), "]");
197 else if (curPunc == "[") pushContext(state, stream.column(), "]");
198 else if (curPunc == "(") pushContext(state, stream.column(), ")");
198 else if (curPunc == "(") pushContext(state, stream.column(), ")");
199 else if (curPunc == "}") {
199 else if (curPunc == "}") {
200 while (ctx.type == "statement") ctx = popContext(state);
200 while (ctx.type == "statement") ctx = popContext(state);
201 if (ctx.type == "}") ctx = popContext(state);
201 if (ctx.type == "}") ctx = popContext(state);
202 while (ctx.type == "statement") ctx = popContext(state);
202 while (ctx.type == "statement") ctx = popContext(state);
203 }
203 }
204 else if (curPunc == ctx.type) popContext(state);
204 else if (curPunc == ctx.type) popContext(state);
205 else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
205 else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
206 pushContext(state, stream.column(), "statement");
206 pushContext(state, stream.column(), "statement");
207 state.startOfLine = false;
207 state.startOfLine = false;
208 state.lastToken = curPunc || style;
208 state.lastToken = curPunc || style;
209 return style;
209 return style;
210 },
210 },
211
211
212 indent: function(state, textAfter) {
212 indent: function(state, textAfter) {
213 if (!state.tokenize[state.tokenize.length-1].isBase) return 0;
213 if (!state.tokenize[state.tokenize.length-1].isBase) return CodeMirror.Pass;
214 var firstChar = textAfter && textAfter.charAt(0), ctx = state.context;
214 var firstChar = textAfter && textAfter.charAt(0), ctx = state.context;
215 if (ctx.type == "statement" && !expectExpression(state.lastToken, true)) ctx = ctx.prev;
215 if (ctx.type == "statement" && !expectExpression(state.lastToken, true)) ctx = ctx.prev;
216 var closing = firstChar == ctx.type;
216 var closing = firstChar == ctx.type;
217 if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : config.indentUnit);
217 if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : config.indentUnit);
218 else if (ctx.align) return ctx.column + (closing ? 0 : 1);
218 else if (ctx.align) return ctx.column + (closing ? 0 : 1);
219 else return ctx.indented + (closing ? 0 : config.indentUnit);
219 else return ctx.indented + (closing ? 0 : config.indentUnit);
220 },
220 },
221
221
222 electricChars: "{}",
222 electricChars: "{}",
223 closeBrackets: {triples: "'\""},
223 closeBrackets: {triples: "'\""},
224 fold: "brace"
224 fold: "brace",
225 blockCommentStart: "/*",
226 blockCommentEnd: "*/",
227 lineComment: "//"
225 };
228 };
226 });
229 });
227
230
228 CodeMirror.defineMIME("text/x-groovy", "groovy");
231 CodeMirror.defineMIME("text/x-groovy", "groovy");
229
232
230 });
233 });
@@ -1,161 +1,161 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"), require("../ruby/ruby"));
6 mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"), require("../ruby/ruby"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror", "../htmlmixed/htmlmixed", "../ruby/ruby"], mod);
8 define(["../../lib/codemirror", "../htmlmixed/htmlmixed", "../ruby/ruby"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 // full haml mode. This handled embeded ruby and html fragments too
14 // full haml mode. This handled embedded ruby and html fragments too
15 CodeMirror.defineMode("haml", function(config) {
15 CodeMirror.defineMode("haml", function(config) {
16 var htmlMode = CodeMirror.getMode(config, {name: "htmlmixed"});
16 var htmlMode = CodeMirror.getMode(config, {name: "htmlmixed"});
17 var rubyMode = CodeMirror.getMode(config, "ruby");
17 var rubyMode = CodeMirror.getMode(config, "ruby");
18
18
19 function rubyInQuote(endQuote) {
19 function rubyInQuote(endQuote) {
20 return function(stream, state) {
20 return function(stream, state) {
21 var ch = stream.peek();
21 var ch = stream.peek();
22 if (ch == endQuote && state.rubyState.tokenize.length == 1) {
22 if (ch == endQuote && state.rubyState.tokenize.length == 1) {
23 // step out of ruby context as it seems to complete processing all the braces
23 // step out of ruby context as it seems to complete processing all the braces
24 stream.next();
24 stream.next();
25 state.tokenize = html;
25 state.tokenize = html;
26 return "closeAttributeTag";
26 return "closeAttributeTag";
27 } else {
27 } else {
28 return ruby(stream, state);
28 return ruby(stream, state);
29 }
29 }
30 };
30 };
31 }
31 }
32
32
33 function ruby(stream, state) {
33 function ruby(stream, state) {
34 if (stream.match("-#")) {
34 if (stream.match("-#")) {
35 stream.skipToEnd();
35 stream.skipToEnd();
36 return "comment";
36 return "comment";
37 }
37 }
38 return rubyMode.token(stream, state.rubyState);
38 return rubyMode.token(stream, state.rubyState);
39 }
39 }
40
40
41 function html(stream, state) {
41 function html(stream, state) {
42 var ch = stream.peek();
42 var ch = stream.peek();
43
43
44 // handle haml declarations. All declarations that cant be handled here
44 // handle haml declarations. All declarations that cant be handled here
45 // will be passed to html mode
45 // will be passed to html mode
46 if (state.previousToken.style == "comment" ) {
46 if (state.previousToken.style == "comment" ) {
47 if (state.indented > state.previousToken.indented) {
47 if (state.indented > state.previousToken.indented) {
48 stream.skipToEnd();
48 stream.skipToEnd();
49 return "commentLine";
49 return "commentLine";
50 }
50 }
51 }
51 }
52
52
53 if (state.startOfLine) {
53 if (state.startOfLine) {
54 if (ch == "!" && stream.match("!!")) {
54 if (ch == "!" && stream.match("!!")) {
55 stream.skipToEnd();
55 stream.skipToEnd();
56 return "tag";
56 return "tag";
57 } else if (stream.match(/^%[\w:#\.]+=/)) {
57 } else if (stream.match(/^%[\w:#\.]+=/)) {
58 state.tokenize = ruby;
58 state.tokenize = ruby;
59 return "hamlTag";
59 return "hamlTag";
60 } else if (stream.match(/^%[\w:]+/)) {
60 } else if (stream.match(/^%[\w:]+/)) {
61 return "hamlTag";
61 return "hamlTag";
62 } else if (ch == "/" ) {
62 } else if (ch == "/" ) {
63 stream.skipToEnd();
63 stream.skipToEnd();
64 return "comment";
64 return "comment";
65 }
65 }
66 }
66 }
67
67
68 if (state.startOfLine || state.previousToken.style == "hamlTag") {
68 if (state.startOfLine || state.previousToken.style == "hamlTag") {
69 if ( ch == "#" || ch == ".") {
69 if ( ch == "#" || ch == ".") {
70 stream.match(/[\w-#\.]*/);
70 stream.match(/[\w-#\.]*/);
71 return "hamlAttribute";
71 return "hamlAttribute";
72 }
72 }
73 }
73 }
74
74
75 // donot handle --> as valid ruby, make it HTML close comment instead
75 // donot handle --> as valid ruby, make it HTML close comment instead
76 if (state.startOfLine && !stream.match("-->", false) && (ch == "=" || ch == "-" )) {
76 if (state.startOfLine && !stream.match("-->", false) && (ch == "=" || ch == "-" )) {
77 state.tokenize = ruby;
77 state.tokenize = ruby;
78 return state.tokenize(stream, state);
78 return state.tokenize(stream, state);
79 }
79 }
80
80
81 if (state.previousToken.style == "hamlTag" ||
81 if (state.previousToken.style == "hamlTag" ||
82 state.previousToken.style == "closeAttributeTag" ||
82 state.previousToken.style == "closeAttributeTag" ||
83 state.previousToken.style == "hamlAttribute") {
83 state.previousToken.style == "hamlAttribute") {
84 if (ch == "(") {
84 if (ch == "(") {
85 state.tokenize = rubyInQuote(")");
85 state.tokenize = rubyInQuote(")");
86 return state.tokenize(stream, state);
86 return state.tokenize(stream, state);
87 } else if (ch == "{") {
87 } else if (ch == "{") {
88 if (!stream.match(/^\{%.*/)) {
88 if (!stream.match(/^\{%.*/)) {
89 state.tokenize = rubyInQuote("}");
89 state.tokenize = rubyInQuote("}");
90 return state.tokenize(stream, state);
90 return state.tokenize(stream, state);
91 }
91 }
92 }
92 }
93 }
93 }
94
94
95 return htmlMode.token(stream, state.htmlState);
95 return htmlMode.token(stream, state.htmlState);
96 }
96 }
97
97
98 return {
98 return {
99 // default to html mode
99 // default to html mode
100 startState: function() {
100 startState: function() {
101 var htmlState = htmlMode.startState();
101 var htmlState = CodeMirror.startState(htmlMode);
102 var rubyState = rubyMode.startState();
102 var rubyState = CodeMirror.startState(rubyMode);
103 return {
103 return {
104 htmlState: htmlState,
104 htmlState: htmlState,
105 rubyState: rubyState,
105 rubyState: rubyState,
106 indented: 0,
106 indented: 0,
107 previousToken: { style: null, indented: 0},
107 previousToken: { style: null, indented: 0},
108 tokenize: html
108 tokenize: html
109 };
109 };
110 },
110 },
111
111
112 copyState: function(state) {
112 copyState: function(state) {
113 return {
113 return {
114 htmlState : CodeMirror.copyState(htmlMode, state.htmlState),
114 htmlState : CodeMirror.copyState(htmlMode, state.htmlState),
115 rubyState: CodeMirror.copyState(rubyMode, state.rubyState),
115 rubyState: CodeMirror.copyState(rubyMode, state.rubyState),
116 indented: state.indented,
116 indented: state.indented,
117 previousToken: state.previousToken,
117 previousToken: state.previousToken,
118 tokenize: state.tokenize
118 tokenize: state.tokenize
119 };
119 };
120 },
120 },
121
121
122 token: function(stream, state) {
122 token: function(stream, state) {
123 if (stream.sol()) {
123 if (stream.sol()) {
124 state.indented = stream.indentation();
124 state.indented = stream.indentation();
125 state.startOfLine = true;
125 state.startOfLine = true;
126 }
126 }
127 if (stream.eatSpace()) return null;
127 if (stream.eatSpace()) return null;
128 var style = state.tokenize(stream, state);
128 var style = state.tokenize(stream, state);
129 state.startOfLine = false;
129 state.startOfLine = false;
130 // dont record comment line as we only want to measure comment line with
130 // dont record comment line as we only want to measure comment line with
131 // the opening comment block
131 // the opening comment block
132 if (style && style != "commentLine") {
132 if (style && style != "commentLine") {
133 state.previousToken = { style: style, indented: state.indented };
133 state.previousToken = { style: style, indented: state.indented };
134 }
134 }
135 // if current state is ruby and the previous token is not `,` reset the
135 // if current state is ruby and the previous token is not `,` reset the
136 // tokenize to html
136 // tokenize to html
137 if (stream.eol() && state.tokenize == ruby) {
137 if (stream.eol() && state.tokenize == ruby) {
138 stream.backUp(1);
138 stream.backUp(1);
139 var ch = stream.peek();
139 var ch = stream.peek();
140 stream.next();
140 stream.next();
141 if (ch && ch != ",") {
141 if (ch && ch != ",") {
142 state.tokenize = html;
142 state.tokenize = html;
143 }
143 }
144 }
144 }
145 // reprocess some of the specific style tag when finish setting previousToken
145 // reprocess some of the specific style tag when finish setting previousToken
146 if (style == "hamlTag") {
146 if (style == "hamlTag") {
147 style = "tag";
147 style = "tag";
148 } else if (style == "commentLine") {
148 } else if (style == "commentLine") {
149 style = "comment";
149 style = "comment";
150 } else if (style == "hamlAttribute") {
150 } else if (style == "hamlAttribute") {
151 style = "attribute";
151 style = "attribute";
152 } else if (style == "closeAttributeTag") {
152 } else if (style == "closeAttributeTag") {
153 style = null;
153 style = null;
154 }
154 }
155 return style;
155 return style;
156 }
156 }
157 };
157 };
158 }, "htmlmixed", "ruby");
158 }, "htmlmixed", "ruby");
159
159
160 CodeMirror.defineMIME("text/x-haml", "haml");
160 CodeMirror.defineMIME("text/x-haml", "haml");
161 });
161 });
@@ -1,62 +1,70 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"), require("../../addon/mode/simple"), require("../../addon/mode/multiplex"));
6 mod(require("../../lib/codemirror"), require("../../addon/mode/simple"), require("../../addon/mode/multiplex"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror", "../../addon/mode/simple", "../../addon/mode/multiplex"], mod);
8 define(["../../lib/codemirror", "../../addon/mode/simple", "../../addon/mode/multiplex"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineSimpleMode("handlebars-tags", {
14 CodeMirror.defineSimpleMode("handlebars-tags", {
15 start: [
15 start: [
16 { regex: /\{\{\{/, push: "handlebars_raw", token: "tag" },
16 { regex: /\{\{!--/, push: "dash_comment", token: "comment" },
17 { regex: /\{\{!--/, push: "dash_comment", token: "comment" },
17 { regex: /\{\{!/, push: "comment", token: "comment" },
18 { regex: /\{\{!/, push: "comment", token: "comment" },
18 { regex: /\{\{/, push: "handlebars", token: "tag" }
19 { regex: /\{\{/, push: "handlebars", token: "tag" }
19 ],
20 ],
21 handlebars_raw: [
22 { regex: /\}\}\}/, pop: true, token: "tag" },
23 ],
20 handlebars: [
24 handlebars: [
21 { regex: /\}\}/, pop: true, token: "tag" },
25 { regex: /\}\}/, pop: true, token: "tag" },
22
26
23 // Double and single quotes
27 // Double and single quotes
24 { regex: /"(?:[^\\"]|\\.)*"?/, token: "string" },
28 { regex: /"(?:[^\\"]|\\.)*"?/, token: "string" },
25 { regex: /'(?:[^\\']|\\.)*'?/, token: "string" },
29 { regex: /'(?:[^\\']|\\.)*'?/, token: "string" },
26
30
27 // Handlebars keywords
31 // Handlebars keywords
28 { regex: />|[#\/]([A-Za-z_]\w*)/, token: "keyword" },
32 { regex: />|[#\/]([A-Za-z_]\w*)/, token: "keyword" },
29 { regex: /(?:else|this)\b/, token: "keyword" },
33 { regex: /(?:else|this)\b/, token: "keyword" },
30
34
31 // Numeral
35 // Numeral
32 { regex: /\d+/i, token: "number" },
36 { regex: /\d+/i, token: "number" },
33
37
34 // Atoms like = and .
38 // Atoms like = and .
35 { regex: /=|~|@|true|false/, token: "atom" },
39 { regex: /=|~|@|true|false/, token: "atom" },
36
40
37 // Paths
41 // Paths
38 { regex: /(?:\.\.\/)*(?:[A-Za-z_][\w\.]*)+/, token: "variable-2" }
42 { regex: /(?:\.\.\/)*(?:[A-Za-z_][\w\.]*)+/, token: "variable-2" }
39 ],
43 ],
40 dash_comment: [
44 dash_comment: [
41 { regex: /--\}\}/, pop: true, token: "comment" },
45 { regex: /--\}\}/, pop: true, token: "comment" },
42
46
43 // Commented code
47 // Commented code
44 { regex: /./, token: "comment"}
48 { regex: /./, token: "comment"}
45 ],
49 ],
46 comment: [
50 comment: [
47 { regex: /\}\}/, pop: true, token: "comment" },
51 { regex: /\}\}/, pop: true, token: "comment" },
48 { regex: /./, token: "comment" }
52 { regex: /./, token: "comment" }
49 ]
53 ],
54 meta: {
55 blockCommentStart: "{{--",
56 blockCommentEnd: "--}}"
57 }
50 });
58 });
51
59
52 CodeMirror.defineMode("handlebars", function(config, parserConfig) {
60 CodeMirror.defineMode("handlebars", function(config, parserConfig) {
53 var handlebars = CodeMirror.getMode(config, "handlebars-tags");
61 var handlebars = CodeMirror.getMode(config, "handlebars-tags");
54 if (!parserConfig || !parserConfig.base) return handlebars;
62 if (!parserConfig || !parserConfig.base) return handlebars;
55 return CodeMirror.multiplexingMode(
63 return CodeMirror.multiplexingMode(
56 CodeMirror.getMode(config, parserConfig.base),
64 CodeMirror.getMode(config, parserConfig.base),
57 {open: "{{", close: "}}", mode: handlebars, parseDelimiters: true}
65 {open: "{{", close: "}}", mode: handlebars, parseDelimiters: true}
58 );
66 );
59 });
67 });
60
68
61 CodeMirror.defineMIME("text/x-handlebars-template", "handlebars");
69 CodeMirror.defineMIME("text/x-handlebars-template", "handlebars");
62 });
70 });
@@ -1,43 +1,43 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function (mod) {
4 (function (mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"), require("../haskell/haskell"))
6 mod(require("../../lib/codemirror"), require("../haskell/haskell"))
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror", "../haskell/haskell"], mod)
8 define(["../../lib/codemirror", "../haskell/haskell"], mod)
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror)
10 mod(CodeMirror)
11 })(function (CodeMirror) {
11 })(function (CodeMirror) {
12 "use strict"
12 "use strict"
13
13
14 CodeMirror.defineMode("haskell-literate", function (config, parserConfig) {
14 CodeMirror.defineMode("haskell-literate", function (config, parserConfig) {
15 var baseMode = CodeMirror.getMode(config, (parserConfig && parserConfig.base) || "haskell")
15 var baseMode = CodeMirror.getMode(config, (parserConfig && parserConfig.base) || "haskell")
16
16
17 return {
17 return {
18 startState: function () {
18 startState: function () {
19 return {
19 return {
20 inCode: false,
20 inCode: false,
21 baseState: CodeMirror.startState(baseMode)
21 baseState: CodeMirror.startState(baseMode)
22 }
22 }
23 },
23 },
24 token: function (stream, state) {
24 token: function (stream, state) {
25 if (stream.sol()) {
25 if (stream.sol()) {
26 if (state.inCode = stream.eat(">"))
26 if (state.inCode = stream.eat(">"))
27 return "meta"
27 return "meta"
28 }
28 }
29 if (state.inCode) {
29 if (state.inCode) {
30 return baseMode.token(stream, state.baseState)
30 return baseMode.token(stream, state.baseState)
31 } else {
31 } else {
32 stream.skipToEnd()
32 stream.skipToEnd()
33 return "comment"
33 return "comment"
34 }
34 }
35 },
35 },
36 innerMode: function (state) {
36 innerMode: function (state) {
37 return state.inCode ? {state: state.baseState, mode: baseMode} : null
37 return state.inCode ? {state: state.baseState, mode: baseMode} : null
38 }
38 }
39 }
39 }
40 }, "haskell")
40 }, "haskell")
41
41
42 CodeMirror.defineMIME("text/x-literate-haskell", "haskell-literate")
42 CodeMirror.defineMIME("text/x-literate-haskell", "haskell-literate")
43 })
43 });
@@ -1,267 +1,268 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("haskell", function(_config, modeConfig) {
14 CodeMirror.defineMode("haskell", function(_config, modeConfig) {
15
15
16 function switchState(source, setState, f) {
16 function switchState(source, setState, f) {
17 setState(f);
17 setState(f);
18 return f(source, setState);
18 return f(source, setState);
19 }
19 }
20
20
21 // These should all be Unicode extended, as per the Haskell 2010 report
21 // These should all be Unicode extended, as per the Haskell 2010 report
22 var smallRE = /[a-z_]/;
22 var smallRE = /[a-z_]/;
23 var largeRE = /[A-Z]/;
23 var largeRE = /[A-Z]/;
24 var digitRE = /\d/;
24 var digitRE = /\d/;
25 var hexitRE = /[0-9A-Fa-f]/;
25 var hexitRE = /[0-9A-Fa-f]/;
26 var octitRE = /[0-7]/;
26 var octitRE = /[0-7]/;
27 var idRE = /[a-z_A-Z0-9'\xa1-\uffff]/;
27 var idRE = /[a-z_A-Z0-9'\xa1-\uffff]/;
28 var symbolRE = /[-!#$%&*+.\/<=>?@\\^|~:]/;
28 var symbolRE = /[-!#$%&*+.\/<=>?@\\^|~:]/;
29 var specialRE = /[(),;[\]`{}]/;
29 var specialRE = /[(),;[\]`{}]/;
30 var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer
30 var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer
31
31
32 function normal(source, setState) {
32 function normal(source, setState) {
33 if (source.eatWhile(whiteCharRE)) {
33 if (source.eatWhile(whiteCharRE)) {
34 return null;
34 return null;
35 }
35 }
36
36
37 var ch = source.next();
37 var ch = source.next();
38 if (specialRE.test(ch)) {
38 if (specialRE.test(ch)) {
39 if (ch == '{' && source.eat('-')) {
39 if (ch == '{' && source.eat('-')) {
40 var t = "comment";
40 var t = "comment";
41 if (source.eat('#')) {
41 if (source.eat('#')) {
42 t = "meta";
42 t = "meta";
43 }
43 }
44 return switchState(source, setState, ncomment(t, 1));
44 return switchState(source, setState, ncomment(t, 1));
45 }
45 }
46 return null;
46 return null;
47 }
47 }
48
48
49 if (ch == '\'') {
49 if (ch == '\'') {
50 if (source.eat('\\')) {
50 if (source.eat('\\')) {
51 source.next(); // should handle other escapes here
51 source.next(); // should handle other escapes here
52 }
52 }
53 else {
53 else {
54 source.next();
54 source.next();
55 }
55 }
56 if (source.eat('\'')) {
56 if (source.eat('\'')) {
57 return "string";
57 return "string";
58 }
58 }
59 return "error";
59 return "string error";
60 }
60 }
61
61
62 if (ch == '"') {
62 if (ch == '"') {
63 return switchState(source, setState, stringLiteral);
63 return switchState(source, setState, stringLiteral);
64 }
64 }
65
65
66 if (largeRE.test(ch)) {
66 if (largeRE.test(ch)) {
67 source.eatWhile(idRE);
67 source.eatWhile(idRE);
68 if (source.eat('.')) {
68 if (source.eat('.')) {
69 return "qualifier";
69 return "qualifier";
70 }
70 }
71 return "variable-2";
71 return "variable-2";
72 }
72 }
73
73
74 if (smallRE.test(ch)) {
74 if (smallRE.test(ch)) {
75 source.eatWhile(idRE);
75 source.eatWhile(idRE);
76 return "variable";
76 return "variable";
77 }
77 }
78
78
79 if (digitRE.test(ch)) {
79 if (digitRE.test(ch)) {
80 if (ch == '0') {
80 if (ch == '0') {
81 if (source.eat(/[xX]/)) {
81 if (source.eat(/[xX]/)) {
82 source.eatWhile(hexitRE); // should require at least 1
82 source.eatWhile(hexitRE); // should require at least 1
83 return "integer";
83 return "integer";
84 }
84 }
85 if (source.eat(/[oO]/)) {
85 if (source.eat(/[oO]/)) {
86 source.eatWhile(octitRE); // should require at least 1
86 source.eatWhile(octitRE); // should require at least 1
87 return "number";
87 return "number";
88 }
88 }
89 }
89 }
90 source.eatWhile(digitRE);
90 source.eatWhile(digitRE);
91 var t = "number";
91 var t = "number";
92 if (source.match(/^\.\d+/)) {
92 if (source.match(/^\.\d+/)) {
93 t = "number";
93 t = "number";
94 }
94 }
95 if (source.eat(/[eE]/)) {
95 if (source.eat(/[eE]/)) {
96 t = "number";
96 t = "number";
97 source.eat(/[-+]/);
97 source.eat(/[-+]/);
98 source.eatWhile(digitRE); // should require at least 1
98 source.eatWhile(digitRE); // should require at least 1
99 }
99 }
100 return t;
100 return t;
101 }
101 }
102
102
103 if (ch == "." && source.eat("."))
103 if (ch == "." && source.eat("."))
104 return "keyword";
104 return "keyword";
105
105
106 if (symbolRE.test(ch)) {
106 if (symbolRE.test(ch)) {
107 if (ch == '-' && source.eat(/-/)) {
107 if (ch == '-' && source.eat(/-/)) {
108 source.eatWhile(/-/);
108 source.eatWhile(/-/);
109 if (!source.eat(symbolRE)) {
109 if (!source.eat(symbolRE)) {
110 source.skipToEnd();
110 source.skipToEnd();
111 return "comment";
111 return "comment";
112 }
112 }
113 }
113 }
114 var t = "variable";
114 var t = "variable";
115 if (ch == ':') {
115 if (ch == ':') {
116 t = "variable-2";
116 t = "variable-2";
117 }
117 }
118 source.eatWhile(symbolRE);
118 source.eatWhile(symbolRE);
119 return t;
119 return t;
120 }
120 }
121
121
122 return "error";
122 return "error";
123 }
123 }
124
124
125 function ncomment(type, nest) {
125 function ncomment(type, nest) {
126 if (nest == 0) {
126 if (nest == 0) {
127 return normal;
127 return normal;
128 }
128 }
129 return function(source, setState) {
129 return function(source, setState) {
130 var currNest = nest;
130 var currNest = nest;
131 while (!source.eol()) {
131 while (!source.eol()) {
132 var ch = source.next();
132 var ch = source.next();
133 if (ch == '{' && source.eat('-')) {
133 if (ch == '{' && source.eat('-')) {
134 ++currNest;
134 ++currNest;
135 }
135 }
136 else if (ch == '-' && source.eat('}')) {
136 else if (ch == '-' && source.eat('}')) {
137 --currNest;
137 --currNest;
138 if (currNest == 0) {
138 if (currNest == 0) {
139 setState(normal);
139 setState(normal);
140 return type;
140 return type;
141 }
141 }
142 }
142 }
143 }
143 }
144 setState(ncomment(type, currNest));
144 setState(ncomment(type, currNest));
145 return type;
145 return type;
146 };
146 };
147 }
147 }
148
148
149 function stringLiteral(source, setState) {
149 function stringLiteral(source, setState) {
150 while (!source.eol()) {
150 while (!source.eol()) {
151 var ch = source.next();
151 var ch = source.next();
152 if (ch == '"') {
152 if (ch == '"') {
153 setState(normal);
153 setState(normal);
154 return "string";
154 return "string";
155 }
155 }
156 if (ch == '\\') {
156 if (ch == '\\') {
157 if (source.eol() || source.eat(whiteCharRE)) {
157 if (source.eol() || source.eat(whiteCharRE)) {
158 setState(stringGap);
158 setState(stringGap);
159 return "string";
159 return "string";
160 }
160 }
161 if (source.eat('&')) {
161 if (source.eat('&')) {
162 }
162 }
163 else {
163 else {
164 source.next(); // should handle other escapes here
164 source.next(); // should handle other escapes here
165 }
165 }
166 }
166 }
167 }
167 }
168 setState(normal);
168 setState(normal);
169 return "error";
169 return "string error";
170 }
170 }
171
171
172 function stringGap(source, setState) {
172 function stringGap(source, setState) {
173 if (source.eat('\\')) {
173 if (source.eat('\\')) {
174 return switchState(source, setState, stringLiteral);
174 return switchState(source, setState, stringLiteral);
175 }
175 }
176 source.next();
176 source.next();
177 setState(normal);
177 setState(normal);
178 return "error";
178 return "error";
179 }
179 }
180
180
181
181
182 var wellKnownWords = (function() {
182 var wellKnownWords = (function() {
183 var wkw = {};
183 var wkw = {};
184 function setType(t) {
184 function setType(t) {
185 return function () {
185 return function () {
186 for (var i = 0; i < arguments.length; i++)
186 for (var i = 0; i < arguments.length; i++)
187 wkw[arguments[i]] = t;
187 wkw[arguments[i]] = t;
188 };
188 };
189 }
189 }
190
190
191 setType("keyword")(
191 setType("keyword")(
192 "case", "class", "data", "default", "deriving", "do", "else", "foreign",
192 "case", "class", "data", "default", "deriving", "do", "else", "foreign",
193 "if", "import", "in", "infix", "infixl", "infixr", "instance", "let",
193 "if", "import", "in", "infix", "infixl", "infixr", "instance", "let",
194 "module", "newtype", "of", "then", "type", "where", "_");
194 "module", "newtype", "of", "then", "type", "where", "_");
195
195
196 setType("keyword")(
196 setType("keyword")(
197 "\.\.", ":", "::", "=", "\\", "\"", "<-", "->", "@", "~", "=>");
197 "\.\.", ":", "::", "=", "\\", "<-", "->", "@", "~", "=>");
198
198
199 setType("builtin")(
199 setType("builtin")(
200 "!!", "$!", "$", "&&", "+", "++", "-", ".", "/", "/=", "<", "<=", "=<<",
200 "!!", "$!", "$", "&&", "+", "++", "-", ".", "/", "/=", "<", "<*", "<=",
201 "==", ">", ">=", ">>", ">>=", "^", "^^", "||", "*", "**");
201 "<$>", "<*>", "=<<", "==", ">", ">=", ">>", ">>=", "^", "^^", "||", "*",
202 "*>", "**");
202
203
203 setType("builtin")(
204 setType("builtin")(
204 "Bool", "Bounded", "Char", "Double", "EQ", "Either", "Enum", "Eq",
205 "Applicative", "Bool", "Bounded", "Char", "Double", "EQ", "Either", "Enum",
205 "False", "FilePath", "Float", "Floating", "Fractional", "Functor", "GT",
206 "Eq", "False", "FilePath", "Float", "Floating", "Fractional", "Functor",
206 "IO", "IOError", "Int", "Integer", "Integral", "Just", "LT", "Left",
207 "GT", "IO", "IOError", "Int", "Integer", "Integral", "Just", "LT", "Left",
207 "Maybe", "Monad", "Nothing", "Num", "Ord", "Ordering", "Rational", "Read",
208 "Maybe", "Monad", "Nothing", "Num", "Ord", "Ordering", "Rational", "Read",
208 "ReadS", "Real", "RealFloat", "RealFrac", "Right", "Show", "ShowS",
209 "ReadS", "Real", "RealFloat", "RealFrac", "Right", "Show", "ShowS",
209 "String", "True");
210 "String", "True");
210
211
211 setType("builtin")(
212 setType("builtin")(
212 "abs", "acos", "acosh", "all", "and", "any", "appendFile", "asTypeOf",
213 "abs", "acos", "acosh", "all", "and", "any", "appendFile", "asTypeOf",
213 "asin", "asinh", "atan", "atan2", "atanh", "break", "catch", "ceiling",
214 "asin", "asinh", "atan", "atan2", "atanh", "break", "catch", "ceiling",
214 "compare", "concat", "concatMap", "const", "cos", "cosh", "curry",
215 "compare", "concat", "concatMap", "const", "cos", "cosh", "curry",
215 "cycle", "decodeFloat", "div", "divMod", "drop", "dropWhile", "either",
216 "cycle", "decodeFloat", "div", "divMod", "drop", "dropWhile", "either",
216 "elem", "encodeFloat", "enumFrom", "enumFromThen", "enumFromThenTo",
217 "elem", "encodeFloat", "enumFrom", "enumFromThen", "enumFromThenTo",
217 "enumFromTo", "error", "even", "exp", "exponent", "fail", "filter",
218 "enumFromTo", "error", "even", "exp", "exponent", "fail", "filter",
218 "flip", "floatDigits", "floatRadix", "floatRange", "floor", "fmap",
219 "flip", "floatDigits", "floatRadix", "floatRange", "floor", "fmap",
219 "foldl", "foldl1", "foldr", "foldr1", "fromEnum", "fromInteger",
220 "foldl", "foldl1", "foldr", "foldr1", "fromEnum", "fromInteger",
220 "fromIntegral", "fromRational", "fst", "gcd", "getChar", "getContents",
221 "fromIntegral", "fromRational", "fst", "gcd", "getChar", "getContents",
221 "getLine", "head", "id", "init", "interact", "ioError", "isDenormalized",
222 "getLine", "head", "id", "init", "interact", "ioError", "isDenormalized",
222 "isIEEE", "isInfinite", "isNaN", "isNegativeZero", "iterate", "last",
223 "isIEEE", "isInfinite", "isNaN", "isNegativeZero", "iterate", "last",
223 "lcm", "length", "lex", "lines", "log", "logBase", "lookup", "map",
224 "lcm", "length", "lex", "lines", "log", "logBase", "lookup", "map",
224 "mapM", "mapM_", "max", "maxBound", "maximum", "maybe", "min", "minBound",
225 "mapM", "mapM_", "max", "maxBound", "maximum", "maybe", "min", "minBound",
225 "minimum", "mod", "negate", "not", "notElem", "null", "odd", "or",
226 "minimum", "mod", "negate", "not", "notElem", "null", "odd", "or",
226 "otherwise", "pi", "pred", "print", "product", "properFraction",
227 "otherwise", "pi", "pred", "print", "product", "properFraction", "pure",
227 "putChar", "putStr", "putStrLn", "quot", "quotRem", "read", "readFile",
228 "putChar", "putStr", "putStrLn", "quot", "quotRem", "read", "readFile",
228 "readIO", "readList", "readLn", "readParen", "reads", "readsPrec",
229 "readIO", "readList", "readLn", "readParen", "reads", "readsPrec",
229 "realToFrac", "recip", "rem", "repeat", "replicate", "return", "reverse",
230 "realToFrac", "recip", "rem", "repeat", "replicate", "return", "reverse",
230 "round", "scaleFloat", "scanl", "scanl1", "scanr", "scanr1", "seq",
231 "round", "scaleFloat", "scanl", "scanl1", "scanr", "scanr1", "seq",
231 "sequence", "sequence_", "show", "showChar", "showList", "showParen",
232 "sequence", "sequence_", "show", "showChar", "showList", "showParen",
232 "showString", "shows", "showsPrec", "significand", "signum", "sin",
233 "showString", "shows", "showsPrec", "significand", "signum", "sin",
233 "sinh", "snd", "span", "splitAt", "sqrt", "subtract", "succ", "sum",
234 "sinh", "snd", "span", "splitAt", "sqrt", "subtract", "succ", "sum",
234 "tail", "take", "takeWhile", "tan", "tanh", "toEnum", "toInteger",
235 "tail", "take", "takeWhile", "tan", "tanh", "toEnum", "toInteger",
235 "toRational", "truncate", "uncurry", "undefined", "unlines", "until",
236 "toRational", "truncate", "uncurry", "undefined", "unlines", "until",
236 "unwords", "unzip", "unzip3", "userError", "words", "writeFile", "zip",
237 "unwords", "unzip", "unzip3", "userError", "words", "writeFile", "zip",
237 "zip3", "zipWith", "zipWith3");
238 "zip3", "zipWith", "zipWith3");
238
239
239 var override = modeConfig.overrideKeywords;
240 var override = modeConfig.overrideKeywords;
240 if (override) for (var word in override) if (override.hasOwnProperty(word))
241 if (override) for (var word in override) if (override.hasOwnProperty(word))
241 wkw[word] = override[word];
242 wkw[word] = override[word];
242
243
243 return wkw;
244 return wkw;
244 })();
245 })();
245
246
246
247
247
248
248 return {
249 return {
249 startState: function () { return { f: normal }; },
250 startState: function () { return { f: normal }; },
250 copyState: function (s) { return { f: s.f }; },
251 copyState: function (s) { return { f: s.f }; },
251
252
252 token: function(stream, state) {
253 token: function(stream, state) {
253 var t = state.f(stream, function(s) { state.f = s; });
254 var t = state.f(stream, function(s) { state.f = s; });
254 var w = stream.current();
255 var w = stream.current();
255 return wellKnownWords.hasOwnProperty(w) ? wellKnownWords[w] : t;
256 return wellKnownWords.hasOwnProperty(w) ? wellKnownWords[w] : t;
256 },
257 },
257
258
258 blockCommentStart: "{-",
259 blockCommentStart: "{-",
259 blockCommentEnd: "-}",
260 blockCommentEnd: "-}",
260 lineComment: "--"
261 lineComment: "--"
261 };
262 };
262
263
263 });
264 });
264
265
265 CodeMirror.defineMIME("text/x-haskell", "haskell");
266 CodeMirror.defineMIME("text/x-haskell", "haskell");
266
267
267 });
268 });
@@ -1,515 +1,515 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("haxe", function(config, parserConfig) {
14 CodeMirror.defineMode("haxe", function(config, parserConfig) {
15 var indentUnit = config.indentUnit;
15 var indentUnit = config.indentUnit;
16
16
17 // Tokenizer
17 // Tokenizer
18
18
19 function kw(type) {return {type: type, style: "keyword"};}
19 function kw(type) {return {type: type, style: "keyword"};}
20 var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
20 var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
21 var operator = kw("operator"), atom = {type: "atom", style: "atom"}, attribute = {type:"attribute", style: "attribute"};
21 var operator = kw("operator"), atom = {type: "atom", style: "atom"}, attribute = {type:"attribute", style: "attribute"};
22 var type = kw("typedef");
22 var type = kw("typedef");
23 var keywords = {
23 var keywords = {
24 "if": A, "while": A, "else": B, "do": B, "try": B,
24 "if": A, "while": A, "else": B, "do": B, "try": B,
25 "return": C, "break": C, "continue": C, "new": C, "throw": C,
25 "return": C, "break": C, "continue": C, "new": C, "throw": C,
26 "var": kw("var"), "inline":attribute, "static": attribute, "using":kw("import"),
26 "var": kw("var"), "inline":attribute, "static": attribute, "using":kw("import"),
27 "public": attribute, "private": attribute, "cast": kw("cast"), "import": kw("import"), "macro": kw("macro"),
27 "public": attribute, "private": attribute, "cast": kw("cast"), "import": kw("import"), "macro": kw("macro"),
28 "function": kw("function"), "catch": kw("catch"), "untyped": kw("untyped"), "callback": kw("cb"),
28 "function": kw("function"), "catch": kw("catch"), "untyped": kw("untyped"), "callback": kw("cb"),
29 "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
29 "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
30 "in": operator, "never": kw("property_access"), "trace":kw("trace"),
30 "in": operator, "never": kw("property_access"), "trace":kw("trace"),
31 "class": type, "abstract":type, "enum":type, "interface":type, "typedef":type, "extends":type, "implements":type, "dynamic":type,
31 "class": type, "abstract":type, "enum":type, "interface":type, "typedef":type, "extends":type, "implements":type, "dynamic":type,
32 "true": atom, "false": atom, "null": atom
32 "true": atom, "false": atom, "null": atom
33 };
33 };
34
34
35 var isOperatorChar = /[+\-*&%=<>!?|]/;
35 var isOperatorChar = /[+\-*&%=<>!?|]/;
36
36
37 function chain(stream, state, f) {
37 function chain(stream, state, f) {
38 state.tokenize = f;
38 state.tokenize = f;
39 return f(stream, state);
39 return f(stream, state);
40 }
40 }
41
41
42 function toUnescaped(stream, end) {
42 function toUnescaped(stream, end) {
43 var escaped = false, next;
43 var escaped = false, next;
44 while ((next = stream.next()) != null) {
44 while ((next = stream.next()) != null) {
45 if (next == end && !escaped)
45 if (next == end && !escaped)
46 return true;
46 return true;
47 escaped = !escaped && next == "\\";
47 escaped = !escaped && next == "\\";
48 }
48 }
49 }
49 }
50
50
51 // Used as scratch variables to communicate multiple values without
51 // Used as scratch variables to communicate multiple values without
52 // consing up tons of objects.
52 // consing up tons of objects.
53 var type, content;
53 var type, content;
54 function ret(tp, style, cont) {
54 function ret(tp, style, cont) {
55 type = tp; content = cont;
55 type = tp; content = cont;
56 return style;
56 return style;
57 }
57 }
58
58
59 function haxeTokenBase(stream, state) {
59 function haxeTokenBase(stream, state) {
60 var ch = stream.next();
60 var ch = stream.next();
61 if (ch == '"' || ch == "'") {
61 if (ch == '"' || ch == "'") {
62 return chain(stream, state, haxeTokenString(ch));
62 return chain(stream, state, haxeTokenString(ch));
63 } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
63 } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
64 return ret(ch);
64 return ret(ch);
65 } else if (ch == "0" && stream.eat(/x/i)) {
65 } else if (ch == "0" && stream.eat(/x/i)) {
66 stream.eatWhile(/[\da-f]/i);
66 stream.eatWhile(/[\da-f]/i);
67 return ret("number", "number");
67 return ret("number", "number");
68 } else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) {
68 } else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) {
69 stream.match(/^\d*(?:\.\d*(?!\.))?(?:[eE][+\-]?\d+)?/);
69 stream.match(/^\d*(?:\.\d*(?!\.))?(?:[eE][+\-]?\d+)?/);
70 return ret("number", "number");
70 return ret("number", "number");
71 } else if (state.reAllowed && (ch == "~" && stream.eat(/\//))) {
71 } else if (state.reAllowed && (ch == "~" && stream.eat(/\//))) {
72 toUnescaped(stream, "/");
72 toUnescaped(stream, "/");
73 stream.eatWhile(/[gimsu]/);
73 stream.eatWhile(/[gimsu]/);
74 return ret("regexp", "string-2");
74 return ret("regexp", "string-2");
75 } else if (ch == "/") {
75 } else if (ch == "/") {
76 if (stream.eat("*")) {
76 if (stream.eat("*")) {
77 return chain(stream, state, haxeTokenComment);
77 return chain(stream, state, haxeTokenComment);
78 } else if (stream.eat("/")) {
78 } else if (stream.eat("/")) {
79 stream.skipToEnd();
79 stream.skipToEnd();
80 return ret("comment", "comment");
80 return ret("comment", "comment");
81 } else {
81 } else {
82 stream.eatWhile(isOperatorChar);
82 stream.eatWhile(isOperatorChar);
83 return ret("operator", null, stream.current());
83 return ret("operator", null, stream.current());
84 }
84 }
85 } else if (ch == "#") {
85 } else if (ch == "#") {
86 stream.skipToEnd();
86 stream.skipToEnd();
87 return ret("conditional", "meta");
87 return ret("conditional", "meta");
88 } else if (ch == "@") {
88 } else if (ch == "@") {
89 stream.eat(/:/);
89 stream.eat(/:/);
90 stream.eatWhile(/[\w_]/);
90 stream.eatWhile(/[\w_]/);
91 return ret ("metadata", "meta");
91 return ret ("metadata", "meta");
92 } else if (isOperatorChar.test(ch)) {
92 } else if (isOperatorChar.test(ch)) {
93 stream.eatWhile(isOperatorChar);
93 stream.eatWhile(isOperatorChar);
94 return ret("operator", null, stream.current());
94 return ret("operator", null, stream.current());
95 } else {
95 } else {
96 var word;
96 var word;
97 if(/[A-Z]/.test(ch)) {
97 if(/[A-Z]/.test(ch)) {
98 stream.eatWhile(/[\w_<>]/);
98 stream.eatWhile(/[\w_<>]/);
99 word = stream.current();
99 word = stream.current();
100 return ret("type", "variable-3", word);
100 return ret("type", "variable-3", word);
101 } else {
101 } else {
102 stream.eatWhile(/[\w_]/);
102 stream.eatWhile(/[\w_]/);
103 var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
103 var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
104 return (known && state.kwAllowed) ? ret(known.type, known.style, word) :
104 return (known && state.kwAllowed) ? ret(known.type, known.style, word) :
105 ret("variable", "variable", word);
105 ret("variable", "variable", word);
106 }
106 }
107 }
107 }
108 }
108 }
109
109
110 function haxeTokenString(quote) {
110 function haxeTokenString(quote) {
111 return function(stream, state) {
111 return function(stream, state) {
112 if (toUnescaped(stream, quote))
112 if (toUnescaped(stream, quote))
113 state.tokenize = haxeTokenBase;
113 state.tokenize = haxeTokenBase;
114 return ret("string", "string");
114 return ret("string", "string");
115 };
115 };
116 }
116 }
117
117
118 function haxeTokenComment(stream, state) {
118 function haxeTokenComment(stream, state) {
119 var maybeEnd = false, ch;
119 var maybeEnd = false, ch;
120 while (ch = stream.next()) {
120 while (ch = stream.next()) {
121 if (ch == "/" && maybeEnd) {
121 if (ch == "/" && maybeEnd) {
122 state.tokenize = haxeTokenBase;
122 state.tokenize = haxeTokenBase;
123 break;
123 break;
124 }
124 }
125 maybeEnd = (ch == "*");
125 maybeEnd = (ch == "*");
126 }
126 }
127 return ret("comment", "comment");
127 return ret("comment", "comment");
128 }
128 }
129
129
130 // Parser
130 // Parser
131
131
132 var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true};
132 var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true};
133
133
134 function HaxeLexical(indented, column, type, align, prev, info) {
134 function HaxeLexical(indented, column, type, align, prev, info) {
135 this.indented = indented;
135 this.indented = indented;
136 this.column = column;
136 this.column = column;
137 this.type = type;
137 this.type = type;
138 this.prev = prev;
138 this.prev = prev;
139 this.info = info;
139 this.info = info;
140 if (align != null) this.align = align;
140 if (align != null) this.align = align;
141 }
141 }
142
142
143 function inScope(state, varname) {
143 function inScope(state, varname) {
144 for (var v = state.localVars; v; v = v.next)
144 for (var v = state.localVars; v; v = v.next)
145 if (v.name == varname) return true;
145 if (v.name == varname) return true;
146 }
146 }
147
147
148 function parseHaxe(state, style, type, content, stream) {
148 function parseHaxe(state, style, type, content, stream) {
149 var cc = state.cc;
149 var cc = state.cc;
150 // Communicate our context to the combinators.
150 // Communicate our context to the combinators.
151 // (Less wasteful than consing up a hundred closures on every call.)
151 // (Less wasteful than consing up a hundred closures on every call.)
152 cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc;
152 cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc;
153
153
154 if (!state.lexical.hasOwnProperty("align"))
154 if (!state.lexical.hasOwnProperty("align"))
155 state.lexical.align = true;
155 state.lexical.align = true;
156
156
157 while(true) {
157 while(true) {
158 var combinator = cc.length ? cc.pop() : statement;
158 var combinator = cc.length ? cc.pop() : statement;
159 if (combinator(type, content)) {
159 if (combinator(type, content)) {
160 while(cc.length && cc[cc.length - 1].lex)
160 while(cc.length && cc[cc.length - 1].lex)
161 cc.pop()();
161 cc.pop()();
162 if (cx.marked) return cx.marked;
162 if (cx.marked) return cx.marked;
163 if (type == "variable" && inScope(state, content)) return "variable-2";
163 if (type == "variable" && inScope(state, content)) return "variable-2";
164 if (type == "variable" && imported(state, content)) return "variable-3";
164 if (type == "variable" && imported(state, content)) return "variable-3";
165 return style;
165 return style;
166 }
166 }
167 }
167 }
168 }
168 }
169
169
170 function imported(state, typename) {
170 function imported(state, typename) {
171 if (/[a-z]/.test(typename.charAt(0)))
171 if (/[a-z]/.test(typename.charAt(0)))
172 return false;
172 return false;
173 var len = state.importedtypes.length;
173 var len = state.importedtypes.length;
174 for (var i = 0; i<len; i++)
174 for (var i = 0; i<len; i++)
175 if(state.importedtypes[i]==typename) return true;
175 if(state.importedtypes[i]==typename) return true;
176 }
176 }
177
177
178 function registerimport(importname) {
178 function registerimport(importname) {
179 var state = cx.state;
179 var state = cx.state;
180 for (var t = state.importedtypes; t; t = t.next)
180 for (var t = state.importedtypes; t; t = t.next)
181 if(t.name == importname) return;
181 if(t.name == importname) return;
182 state.importedtypes = { name: importname, next: state.importedtypes };
182 state.importedtypes = { name: importname, next: state.importedtypes };
183 }
183 }
184 // Combinator utils
184 // Combinator utils
185
185
186 var cx = {state: null, column: null, marked: null, cc: null};
186 var cx = {state: null, column: null, marked: null, cc: null};
187 function pass() {
187 function pass() {
188 for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
188 for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
189 }
189 }
190 function cont() {
190 function cont() {
191 pass.apply(null, arguments);
191 pass.apply(null, arguments);
192 return true;
192 return true;
193 }
193 }
194 function inList(name, list) {
194 function inList(name, list) {
195 for (var v = list; v; v = v.next)
195 for (var v = list; v; v = v.next)
196 if (v.name == name) return true;
196 if (v.name == name) return true;
197 return false;
197 return false;
198 }
198 }
199 function register(varname) {
199 function register(varname) {
200 var state = cx.state;
200 var state = cx.state;
201 if (state.context) {
201 if (state.context) {
202 cx.marked = "def";
202 cx.marked = "def";
203 if (inList(varname, state.localVars)) return;
203 if (inList(varname, state.localVars)) return;
204 state.localVars = {name: varname, next: state.localVars};
204 state.localVars = {name: varname, next: state.localVars};
205 } else if (state.globalVars) {
205 } else if (state.globalVars) {
206 if (inList(varname, state.globalVars)) return;
206 if (inList(varname, state.globalVars)) return;
207 state.globalVars = {name: varname, next: state.globalVars};
207 state.globalVars = {name: varname, next: state.globalVars};
208 }
208 }
209 }
209 }
210
210
211 // Combinators
211 // Combinators
212
212
213 var defaultVars = {name: "this", next: null};
213 var defaultVars = {name: "this", next: null};
214 function pushcontext() {
214 function pushcontext() {
215 if (!cx.state.context) cx.state.localVars = defaultVars;
215 if (!cx.state.context) cx.state.localVars = defaultVars;
216 cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
216 cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
217 }
217 }
218 function popcontext() {
218 function popcontext() {
219 cx.state.localVars = cx.state.context.vars;
219 cx.state.localVars = cx.state.context.vars;
220 cx.state.context = cx.state.context.prev;
220 cx.state.context = cx.state.context.prev;
221 }
221 }
222 popcontext.lex = true;
222 popcontext.lex = true;
223 function pushlex(type, info) {
223 function pushlex(type, info) {
224 var result = function() {
224 var result = function() {
225 var state = cx.state;
225 var state = cx.state;
226 state.lexical = new HaxeLexical(state.indented, cx.stream.column(), type, null, state.lexical, info);
226 state.lexical = new HaxeLexical(state.indented, cx.stream.column(), type, null, state.lexical, info);
227 };
227 };
228 result.lex = true;
228 result.lex = true;
229 return result;
229 return result;
230 }
230 }
231 function poplex() {
231 function poplex() {
232 var state = cx.state;
232 var state = cx.state;
233 if (state.lexical.prev) {
233 if (state.lexical.prev) {
234 if (state.lexical.type == ")")
234 if (state.lexical.type == ")")
235 state.indented = state.lexical.indented;
235 state.indented = state.lexical.indented;
236 state.lexical = state.lexical.prev;
236 state.lexical = state.lexical.prev;
237 }
237 }
238 }
238 }
239 poplex.lex = true;
239 poplex.lex = true;
240
240
241 function expect(wanted) {
241 function expect(wanted) {
242 function f(type) {
242 function f(type) {
243 if (type == wanted) return cont();
243 if (type == wanted) return cont();
244 else if (wanted == ";") return pass();
244 else if (wanted == ";") return pass();
245 else return cont(f);
245 else return cont(f);
246 }
246 }
247 return f;
247 return f;
248 }
248 }
249
249
250 function statement(type) {
250 function statement(type) {
251 if (type == "@") return cont(metadef);
251 if (type == "@") return cont(metadef);
252 if (type == "var") return cont(pushlex("vardef"), vardef1, expect(";"), poplex);
252 if (type == "var") return cont(pushlex("vardef"), vardef1, expect(";"), poplex);
253 if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
253 if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
254 if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
254 if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
255 if (type == "{") return cont(pushlex("}"), pushcontext, block, poplex, popcontext);
255 if (type == "{") return cont(pushlex("}"), pushcontext, block, poplex, popcontext);
256 if (type == ";") return cont();
256 if (type == ";") return cont();
257 if (type == "attribute") return cont(maybeattribute);
257 if (type == "attribute") return cont(maybeattribute);
258 if (type == "function") return cont(functiondef);
258 if (type == "function") return cont(functiondef);
259 if (type == "for") return cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"),
259 if (type == "for") return cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"),
260 poplex, statement, poplex);
260 poplex, statement, poplex);
261 if (type == "variable") return cont(pushlex("stat"), maybelabel);
261 if (type == "variable") return cont(pushlex("stat"), maybelabel);
262 if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
262 if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
263 block, poplex, poplex);
263 block, poplex, poplex);
264 if (type == "case") return cont(expression, expect(":"));
264 if (type == "case") return cont(expression, expect(":"));
265 if (type == "default") return cont(expect(":"));
265 if (type == "default") return cont(expect(":"));
266 if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
266 if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
267 statement, poplex, popcontext);
267 statement, poplex, popcontext);
268 if (type == "import") return cont(importdef, expect(";"));
268 if (type == "import") return cont(importdef, expect(";"));
269 if (type == "typedef") return cont(typedef);
269 if (type == "typedef") return cont(typedef);
270 return pass(pushlex("stat"), expression, expect(";"), poplex);
270 return pass(pushlex("stat"), expression, expect(";"), poplex);
271 }
271 }
272 function expression(type) {
272 function expression(type) {
273 if (atomicTypes.hasOwnProperty(type)) return cont(maybeoperator);
273 if (atomicTypes.hasOwnProperty(type)) return cont(maybeoperator);
274 if (type == "type" ) return cont(maybeoperator);
274 if (type == "type" ) return cont(maybeoperator);
275 if (type == "function") return cont(functiondef);
275 if (type == "function") return cont(functiondef);
276 if (type == "keyword c") return cont(maybeexpression);
276 if (type == "keyword c") return cont(maybeexpression);
277 if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeoperator);
277 if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeoperator);
278 if (type == "operator") return cont(expression);
278 if (type == "operator") return cont(expression);
279 if (type == "[") return cont(pushlex("]"), commasep(maybeexpression, "]"), poplex, maybeoperator);
279 if (type == "[") return cont(pushlex("]"), commasep(maybeexpression, "]"), poplex, maybeoperator);
280 if (type == "{") return cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);
280 if (type == "{") return cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);
281 return cont();
281 return cont();
282 }
282 }
283 function maybeexpression(type) {
283 function maybeexpression(type) {
284 if (type.match(/[;\}\)\],]/)) return pass();
284 if (type.match(/[;\}\)\],]/)) return pass();
285 return pass(expression);
285 return pass(expression);
286 }
286 }
287
287
288 function maybeoperator(type, value) {
288 function maybeoperator(type, value) {
289 if (type == "operator" && /\+\+|--/.test(value)) return cont(maybeoperator);
289 if (type == "operator" && /\+\+|--/.test(value)) return cont(maybeoperator);
290 if (type == "operator" || type == ":") return cont(expression);
290 if (type == "operator" || type == ":") return cont(expression);
291 if (type == ";") return;
291 if (type == ";") return;
292 if (type == "(") return cont(pushlex(")"), commasep(expression, ")"), poplex, maybeoperator);
292 if (type == "(") return cont(pushlex(")"), commasep(expression, ")"), poplex, maybeoperator);
293 if (type == ".") return cont(property, maybeoperator);
293 if (type == ".") return cont(property, maybeoperator);
294 if (type == "[") return cont(pushlex("]"), expression, expect("]"), poplex, maybeoperator);
294 if (type == "[") return cont(pushlex("]"), expression, expect("]"), poplex, maybeoperator);
295 }
295 }
296
296
297 function maybeattribute(type) {
297 function maybeattribute(type) {
298 if (type == "attribute") return cont(maybeattribute);
298 if (type == "attribute") return cont(maybeattribute);
299 if (type == "function") return cont(functiondef);
299 if (type == "function") return cont(functiondef);
300 if (type == "var") return cont(vardef1);
300 if (type == "var") return cont(vardef1);
301 }
301 }
302
302
303 function metadef(type) {
303 function metadef(type) {
304 if(type == ":") return cont(metadef);
304 if(type == ":") return cont(metadef);
305 if(type == "variable") return cont(metadef);
305 if(type == "variable") return cont(metadef);
306 if(type == "(") return cont(pushlex(")"), commasep(metaargs, ")"), poplex, statement);
306 if(type == "(") return cont(pushlex(")"), commasep(metaargs, ")"), poplex, statement);
307 }
307 }
308 function metaargs(type) {
308 function metaargs(type) {
309 if(type == "variable") return cont();
309 if(type == "variable") return cont();
310 }
310 }
311
311
312 function importdef (type, value) {
312 function importdef (type, value) {
313 if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); }
313 if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); }
314 else if(type == "variable" || type == "property" || type == "." || value == "*") return cont(importdef);
314 else if(type == "variable" || type == "property" || type == "." || value == "*") return cont(importdef);
315 }
315 }
316
316
317 function typedef (type, value)
317 function typedef (type, value)
318 {
318 {
319 if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); }
319 if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); }
320 else if (type == "type" && /[A-Z]/.test(value.charAt(0))) { return cont(); }
320 else if (type == "type" && /[A-Z]/.test(value.charAt(0))) { return cont(); }
321 }
321 }
322
322
323 function maybelabel(type) {
323 function maybelabel(type) {
324 if (type == ":") return cont(poplex, statement);
324 if (type == ":") return cont(poplex, statement);
325 return pass(maybeoperator, expect(";"), poplex);
325 return pass(maybeoperator, expect(";"), poplex);
326 }
326 }
327 function property(type) {
327 function property(type) {
328 if (type == "variable") {cx.marked = "property"; return cont();}
328 if (type == "variable") {cx.marked = "property"; return cont();}
329 }
329 }
330 function objprop(type) {
330 function objprop(type) {
331 if (type == "variable") cx.marked = "property";
331 if (type == "variable") cx.marked = "property";
332 if (atomicTypes.hasOwnProperty(type)) return cont(expect(":"), expression);
332 if (atomicTypes.hasOwnProperty(type)) return cont(expect(":"), expression);
333 }
333 }
334 function commasep(what, end) {
334 function commasep(what, end) {
335 function proceed(type) {
335 function proceed(type) {
336 if (type == ",") return cont(what, proceed);
336 if (type == ",") return cont(what, proceed);
337 if (type == end) return cont();
337 if (type == end) return cont();
338 return cont(expect(end));
338 return cont(expect(end));
339 }
339 }
340 return function(type) {
340 return function(type) {
341 if (type == end) return cont();
341 if (type == end) return cont();
342 else return pass(what, proceed);
342 else return pass(what, proceed);
343 };
343 };
344 }
344 }
345 function block(type) {
345 function block(type) {
346 if (type == "}") return cont();
346 if (type == "}") return cont();
347 return pass(statement, block);
347 return pass(statement, block);
348 }
348 }
349 function vardef1(type, value) {
349 function vardef1(type, value) {
350 if (type == "variable"){register(value); return cont(typeuse, vardef2);}
350 if (type == "variable"){register(value); return cont(typeuse, vardef2);}
351 return cont();
351 return cont();
352 }
352 }
353 function vardef2(type, value) {
353 function vardef2(type, value) {
354 if (value == "=") return cont(expression, vardef2);
354 if (value == "=") return cont(expression, vardef2);
355 if (type == ",") return cont(vardef1);
355 if (type == ",") return cont(vardef1);
356 }
356 }
357 function forspec1(type, value) {
357 function forspec1(type, value) {
358 if (type == "variable") {
358 if (type == "variable") {
359 register(value);
359 register(value);
360 return cont(forin, expression)
360 return cont(forin, expression)
361 } else {
361 } else {
362 return pass()
362 return pass()
363 }
363 }
364 }
364 }
365 function forin(_type, value) {
365 function forin(_type, value) {
366 if (value == "in") return cont();
366 if (value == "in") return cont();
367 }
367 }
368 function functiondef(type, value) {
368 function functiondef(type, value) {
369 //function names starting with upper-case letters are recognised as types, so cludging them together here.
369 //function names starting with upper-case letters are recognised as types, so cludging them together here.
370 if (type == "variable" || type == "type") {register(value); return cont(functiondef);}
370 if (type == "variable" || type == "type") {register(value); return cont(functiondef);}
371 if (value == "new") return cont(functiondef);
371 if (value == "new") return cont(functiondef);
372 if (type == "(") return cont(pushlex(")"), pushcontext, commasep(funarg, ")"), poplex, typeuse, statement, popcontext);
372 if (type == "(") return cont(pushlex(")"), pushcontext, commasep(funarg, ")"), poplex, typeuse, statement, popcontext);
373 }
373 }
374 function typeuse(type) {
374 function typeuse(type) {
375 if(type == ":") return cont(typestring);
375 if(type == ":") return cont(typestring);
376 }
376 }
377 function typestring(type) {
377 function typestring(type) {
378 if(type == "type") return cont();
378 if(type == "type") return cont();
379 if(type == "variable") return cont();
379 if(type == "variable") return cont();
380 if(type == "{") return cont(pushlex("}"), commasep(typeprop, "}"), poplex);
380 if(type == "{") return cont(pushlex("}"), commasep(typeprop, "}"), poplex);
381 }
381 }
382 function typeprop(type) {
382 function typeprop(type) {
383 if(type == "variable") return cont(typeuse);
383 if(type == "variable") return cont(typeuse);
384 }
384 }
385 function funarg(type, value) {
385 function funarg(type, value) {
386 if (type == "variable") {register(value); return cont(typeuse);}
386 if (type == "variable") {register(value); return cont(typeuse);}
387 }
387 }
388
388
389 // Interface
389 // Interface
390 return {
390 return {
391 startState: function(basecolumn) {
391 startState: function(basecolumn) {
392 var defaulttypes = ["Int", "Float", "String", "Void", "Std", "Bool", "Dynamic", "Array"];
392 var defaulttypes = ["Int", "Float", "String", "Void", "Std", "Bool", "Dynamic", "Array"];
393 var state = {
393 var state = {
394 tokenize: haxeTokenBase,
394 tokenize: haxeTokenBase,
395 reAllowed: true,
395 reAllowed: true,
396 kwAllowed: true,
396 kwAllowed: true,
397 cc: [],
397 cc: [],
398 lexical: new HaxeLexical((basecolumn || 0) - indentUnit, 0, "block", false),
398 lexical: new HaxeLexical((basecolumn || 0) - indentUnit, 0, "block", false),
399 localVars: parserConfig.localVars,
399 localVars: parserConfig.localVars,
400 importedtypes: defaulttypes,
400 importedtypes: defaulttypes,
401 context: parserConfig.localVars && {vars: parserConfig.localVars},
401 context: parserConfig.localVars && {vars: parserConfig.localVars},
402 indented: 0
402 indented: 0
403 };
403 };
404 if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
404 if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
405 state.globalVars = parserConfig.globalVars;
405 state.globalVars = parserConfig.globalVars;
406 return state;
406 return state;
407 },
407 },
408
408
409 token: function(stream, state) {
409 token: function(stream, state) {
410 if (stream.sol()) {
410 if (stream.sol()) {
411 if (!state.lexical.hasOwnProperty("align"))
411 if (!state.lexical.hasOwnProperty("align"))
412 state.lexical.align = false;
412 state.lexical.align = false;
413 state.indented = stream.indentation();
413 state.indented = stream.indentation();
414 }
414 }
415 if (stream.eatSpace()) return null;
415 if (stream.eatSpace()) return null;
416 var style = state.tokenize(stream, state);
416 var style = state.tokenize(stream, state);
417 if (type == "comment") return style;
417 if (type == "comment") return style;
418 state.reAllowed = !!(type == "operator" || type == "keyword c" || type.match(/^[\[{}\(,;:]$/));
418 state.reAllowed = !!(type == "operator" || type == "keyword c" || type.match(/^[\[{}\(,;:]$/));
419 state.kwAllowed = type != '.';
419 state.kwAllowed = type != '.';
420 return parseHaxe(state, style, type, content, stream);
420 return parseHaxe(state, style, type, content, stream);
421 },
421 },
422
422
423 indent: function(state, textAfter) {
423 indent: function(state, textAfter) {
424 if (state.tokenize != haxeTokenBase) return 0;
424 if (state.tokenize != haxeTokenBase) return 0;
425 var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
425 var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
426 if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
426 if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
427 var type = lexical.type, closing = firstChar == type;
427 var type = lexical.type, closing = firstChar == type;
428 if (type == "vardef") return lexical.indented + 4;
428 if (type == "vardef") return lexical.indented + 4;
429 else if (type == "form" && firstChar == "{") return lexical.indented;
429 else if (type == "form" && firstChar == "{") return lexical.indented;
430 else if (type == "stat" || type == "form") return lexical.indented + indentUnit;
430 else if (type == "stat" || type == "form") return lexical.indented + indentUnit;
431 else if (lexical.info == "switch" && !closing)
431 else if (lexical.info == "switch" && !closing)
432 return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
432 return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
433 else if (lexical.align) return lexical.column + (closing ? 0 : 1);
433 else if (lexical.align) return lexical.column + (closing ? 0 : 1);
434 else return lexical.indented + (closing ? 0 : indentUnit);
434 else return lexical.indented + (closing ? 0 : indentUnit);
435 },
435 },
436
436
437 electricChars: "{}",
437 electricChars: "{}",
438 blockCommentStart: "/*",
438 blockCommentStart: "/*",
439 blockCommentEnd: "*/",
439 blockCommentEnd: "*/",
440 lineComment: "//"
440 lineComment: "//"
441 };
441 };
442 });
442 });
443
443
444 CodeMirror.defineMIME("text/x-haxe", "haxe");
444 CodeMirror.defineMIME("text/x-haxe", "haxe");
445
445
446 CodeMirror.defineMode("hxml", function () {
446 CodeMirror.defineMode("hxml", function () {
447
447
448 return {
448 return {
449 startState: function () {
449 startState: function () {
450 return {
450 return {
451 define: false,
451 define: false,
452 inString: false
452 inString: false
453 };
453 };
454 },
454 },
455 token: function (stream, state) {
455 token: function (stream, state) {
456 var ch = stream.peek();
456 var ch = stream.peek();
457 var sol = stream.sol();
457 var sol = stream.sol();
458
458
459 ///* comments */
459 ///* comments */
460 if (ch == "#") {
460 if (ch == "#") {
461 stream.skipToEnd();
461 stream.skipToEnd();
462 return "comment";
462 return "comment";
463 }
463 }
464 if (sol && ch == "-") {
464 if (sol && ch == "-") {
465 var style = "variable-2";
465 var style = "variable-2";
466
466
467 stream.eat(/-/);
467 stream.eat(/-/);
468
468
469 if (stream.peek() == "-") {
469 if (stream.peek() == "-") {
470 stream.eat(/-/);
470 stream.eat(/-/);
471 style = "keyword a";
471 style = "keyword a";
472 }
472 }
473
473
474 if (stream.peek() == "D") {
474 if (stream.peek() == "D") {
475 stream.eat(/[D]/);
475 stream.eat(/[D]/);
476 style = "keyword c";
476 style = "keyword c";
477 state.define = true;
477 state.define = true;
478 }
478 }
479
479
480 stream.eatWhile(/[A-Z]/i);
480 stream.eatWhile(/[A-Z]/i);
481 return style;
481 return style;
482 }
482 }
483
483
484 var ch = stream.peek();
484 var ch = stream.peek();
485
485
486 if (state.inString == false && ch == "'") {
486 if (state.inString == false && ch == "'") {
487 state.inString = true;
487 state.inString = true;
488 ch = stream.next();
488 stream.next();
489 }
489 }
490
490
491 if (state.inString == true) {
491 if (state.inString == true) {
492 if (stream.skipTo("'")) {
492 if (stream.skipTo("'")) {
493
493
494 } else {
494 } else {
495 stream.skipToEnd();
495 stream.skipToEnd();
496 }
496 }
497
497
498 if (stream.peek() == "'") {
498 if (stream.peek() == "'") {
499 stream.next();
499 stream.next();
500 state.inString = false;
500 state.inString = false;
501 }
501 }
502
502
503 return "string";
503 return "string";
504 }
504 }
505
505
506 stream.next();
506 stream.next();
507 return null;
507 return null;
508 },
508 },
509 lineComment: "#"
509 lineComment: "#"
510 };
510 };
511 });
511 });
512
512
513 CodeMirror.defineMIME("text/x-hxml", "hxml");
513 CodeMirror.defineMIME("text/x-hxml", "hxml");
514
514
515 });
515 });
@@ -1,28 +1,37 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"),
6 mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"),
7 require("../../addon/mode/multiplex"));
7 require("../../addon/mode/multiplex"));
8 else if (typeof define == "function" && define.amd) // AMD
8 else if (typeof define == "function" && define.amd) // AMD
9 define(["../../lib/codemirror", "../htmlmixed/htmlmixed",
9 define(["../../lib/codemirror", "../htmlmixed/htmlmixed",
10 "../../addon/mode/multiplex"], mod);
10 "../../addon/mode/multiplex"], mod);
11 else // Plain browser env
11 else // Plain browser env
12 mod(CodeMirror);
12 mod(CodeMirror);
13 })(function(CodeMirror) {
13 })(function(CodeMirror) {
14 "use strict";
14 "use strict";
15
15
16 CodeMirror.defineMode("htmlembedded", function(config, parserConfig) {
16 CodeMirror.defineMode("htmlembedded", function(config, parserConfig) {
17 var closeComment = parserConfig.closeComment || "--%>"
17 return CodeMirror.multiplexingMode(CodeMirror.getMode(config, "htmlmixed"), {
18 return CodeMirror.multiplexingMode(CodeMirror.getMode(config, "htmlmixed"), {
19 open: parserConfig.openComment || "<%--",
20 close: closeComment,
21 delimStyle: "comment",
22 mode: {token: function(stream) {
23 stream.skipTo(closeComment) || stream.skipToEnd()
24 return "comment"
25 }}
26 }, {
18 open: parserConfig.open || parserConfig.scriptStartRegex || "<%",
27 open: parserConfig.open || parserConfig.scriptStartRegex || "<%",
19 close: parserConfig.close || parserConfig.scriptEndRegex || "%>",
28 close: parserConfig.close || parserConfig.scriptEndRegex || "%>",
20 mode: CodeMirror.getMode(config, parserConfig.scriptingModeSpec)
29 mode: CodeMirror.getMode(config, parserConfig.scriptingModeSpec)
21 });
30 });
22 }, "htmlmixed");
31 }, "htmlmixed");
23
32
24 CodeMirror.defineMIME("application/x-ejs", {name: "htmlembedded", scriptingModeSpec:"javascript"});
33 CodeMirror.defineMIME("application/x-ejs", {name: "htmlembedded", scriptingModeSpec:"javascript"});
25 CodeMirror.defineMIME("application/x-aspx", {name: "htmlembedded", scriptingModeSpec:"text/x-csharp"});
34 CodeMirror.defineMIME("application/x-aspx", {name: "htmlembedded", scriptingModeSpec:"text/x-csharp"});
26 CodeMirror.defineMIME("application/x-jsp", {name: "htmlembedded", scriptingModeSpec:"text/x-java"});
35 CodeMirror.defineMIME("application/x-jsp", {name: "htmlembedded", scriptingModeSpec:"text/x-java"});
27 CodeMirror.defineMIME("application/x-erb", {name: "htmlembedded", scriptingModeSpec:"ruby"});
36 CodeMirror.defineMIME("application/x-erb", {name: "htmlembedded", scriptingModeSpec:"ruby"});
28 });
37 });
@@ -1,150 +1,152 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"), require("../xml/xml"), require("../javascript/javascript"), require("../css/css"));
6 mod(require("../../lib/codemirror"), require("../xml/xml"), require("../javascript/javascript"), require("../css/css"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror", "../xml/xml", "../javascript/javascript", "../css/css"], mod);
8 define(["../../lib/codemirror", "../xml/xml", "../javascript/javascript", "../css/css"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 var defaultTags = {
14 var defaultTags = {
15 script: [
15 script: [
16 ["lang", /(javascript|babel)/i, "javascript"],
16 ["lang", /(javascript|babel)/i, "javascript"],
17 ["type", /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i, "javascript"],
17 ["type", /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i, "javascript"],
18 ["type", /./, "text/plain"],
18 ["type", /./, "text/plain"],
19 [null, null, "javascript"]
19 [null, null, "javascript"]
20 ],
20 ],
21 style: [
21 style: [
22 ["lang", /^css$/i, "css"],
22 ["lang", /^css$/i, "css"],
23 ["type", /^(text\/)?(x-)?(stylesheet|css)$/i, "css"],
23 ["type", /^(text\/)?(x-)?(stylesheet|css)$/i, "css"],
24 ["type", /./, "text/plain"],
24 ["type", /./, "text/plain"],
25 [null, null, "css"]
25 [null, null, "css"]
26 ]
26 ]
27 };
27 };
28
28
29 function maybeBackup(stream, pat, style) {
29 function maybeBackup(stream, pat, style) {
30 var cur = stream.current(), close = cur.search(pat);
30 var cur = stream.current(), close = cur.search(pat);
31 if (close > -1) {
31 if (close > -1) {
32 stream.backUp(cur.length - close);
32 stream.backUp(cur.length - close);
33 } else if (cur.match(/<\/?$/)) {
33 } else if (cur.match(/<\/?$/)) {
34 stream.backUp(cur.length);
34 stream.backUp(cur.length);
35 if (!stream.match(pat, false)) stream.match(cur);
35 if (!stream.match(pat, false)) stream.match(cur);
36 }
36 }
37 return style;
37 return style;
38 }
38 }
39
39
40 var attrRegexpCache = {};
40 var attrRegexpCache = {};
41 function getAttrRegexp(attr) {
41 function getAttrRegexp(attr) {
42 var regexp = attrRegexpCache[attr];
42 var regexp = attrRegexpCache[attr];
43 if (regexp) return regexp;
43 if (regexp) return regexp;
44 return attrRegexpCache[attr] = new RegExp("\\s+" + attr + "\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*");
44 return attrRegexpCache[attr] = new RegExp("\\s+" + attr + "\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*");
45 }
45 }
46
46
47 function getAttrValue(stream, attr) {
47 function getAttrValue(text, attr) {
48 var pos = stream.pos, match;
48 var match = text.match(getAttrRegexp(attr))
49 while (pos >= 0 && stream.string.charAt(pos) !== "<") pos--;
49 return match ? /^\s*(.*?)\s*$/.exec(match[2])[1] : ""
50 if (pos < 0) return pos;
51 if (match = stream.string.slice(pos, stream.pos).match(getAttrRegexp(attr)))
52 return match[2];
53 return "";
54 }
50 }
55
51
56 function getTagRegexp(tagName, anchored) {
52 function getTagRegexp(tagName, anchored) {
57 return new RegExp((anchored ? "^" : "") + "<\/\s*" + tagName + "\s*>", "i");
53 return new RegExp((anchored ? "^" : "") + "<\/\s*" + tagName + "\s*>", "i");
58 }
54 }
59
55
60 function addTags(from, to) {
56 function addTags(from, to) {
61 for (var tag in from) {
57 for (var tag in from) {
62 var dest = to[tag] || (to[tag] = []);
58 var dest = to[tag] || (to[tag] = []);
63 var source = from[tag];
59 var source = from[tag];
64 for (var i = source.length - 1; i >= 0; i--)
60 for (var i = source.length - 1; i >= 0; i--)
65 dest.unshift(source[i])
61 dest.unshift(source[i])
66 }
62 }
67 }
63 }
68
64
69 function findMatchingMode(tagInfo, stream) {
65 function findMatchingMode(tagInfo, tagText) {
70 for (var i = 0; i < tagInfo.length; i++) {
66 for (var i = 0; i < tagInfo.length; i++) {
71 var spec = tagInfo[i];
67 var spec = tagInfo[i];
72 if (!spec[0] || spec[1].test(getAttrValue(stream, spec[0]))) return spec[2];
68 if (!spec[0] || spec[1].test(getAttrValue(tagText, spec[0]))) return spec[2];
73 }
69 }
74 }
70 }
75
71
76 CodeMirror.defineMode("htmlmixed", function (config, parserConfig) {
72 CodeMirror.defineMode("htmlmixed", function (config, parserConfig) {
77 var htmlMode = CodeMirror.getMode(config, {
73 var htmlMode = CodeMirror.getMode(config, {
78 name: "xml",
74 name: "xml",
79 htmlMode: true,
75 htmlMode: true,
80 multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
76 multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
81 multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag
77 multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag
82 });
78 });
83
79
84 var tags = {};
80 var tags = {};
85 var configTags = parserConfig && parserConfig.tags, configScript = parserConfig && parserConfig.scriptTypes;
81 var configTags = parserConfig && parserConfig.tags, configScript = parserConfig && parserConfig.scriptTypes;
86 addTags(defaultTags, tags);
82 addTags(defaultTags, tags);
87 if (configTags) addTags(configTags, tags);
83 if (configTags) addTags(configTags, tags);
88 if (configScript) for (var i = configScript.length - 1; i >= 0; i--)
84 if (configScript) for (var i = configScript.length - 1; i >= 0; i--)
89 tags.script.unshift(["type", configScript[i].matches, configScript[i].mode])
85 tags.script.unshift(["type", configScript[i].matches, configScript[i].mode])
90
86
91 function html(stream, state) {
87 function html(stream, state) {
92 var tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase();
88 var style = htmlMode.token(stream, state.htmlState), tag = /\btag\b/.test(style), tagName
93 var tagInfo = tagName && tags.hasOwnProperty(tagName) && tags[tagName];
89 if (tag && !/[<>\s\/]/.test(stream.current()) &&
94
90 (tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase()) &&
95 var style = htmlMode.token(stream, state.htmlState), modeSpec;
91 tags.hasOwnProperty(tagName)) {
96
92 state.inTag = tagName + " "
97 if (tagInfo && /\btag\b/.test(style) && stream.current() === ">" &&
93 } else if (state.inTag && tag && />$/.test(stream.current())) {
98 (modeSpec = findMatchingMode(tagInfo, stream))) {
94 var inTag = /^([\S]+) (.*)/.exec(state.inTag)
99 var mode = CodeMirror.getMode(config, modeSpec);
95 state.inTag = null
100 var endTagA = getTagRegexp(tagName, true), endTag = getTagRegexp(tagName, false);
96 var modeSpec = stream.current() == ">" && findMatchingMode(tags[inTag[1]], inTag[2])
97 var mode = CodeMirror.getMode(config, modeSpec)
98 var endTagA = getTagRegexp(inTag[1], true), endTag = getTagRegexp(inTag[1], false);
101 state.token = function (stream, state) {
99 state.token = function (stream, state) {
102 if (stream.match(endTagA, false)) {
100 if (stream.match(endTagA, false)) {
103 state.token = html;
101 state.token = html;
104 state.localState = state.localMode = null;
102 state.localState = state.localMode = null;
105 return null;
103 return null;
106 }
104 }
107 return maybeBackup(stream, endTag, state.localMode.token(stream, state.localState));
105 return maybeBackup(stream, endTag, state.localMode.token(stream, state.localState));
108 };
106 };
109 state.localMode = mode;
107 state.localMode = mode;
110 state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, ""));
108 state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, "", ""));
109 } else if (state.inTag) {
110 state.inTag += stream.current()
111 if (stream.eol()) state.inTag += " "
111 }
112 }
112 return style;
113 return style;
113 };
114 };
114
115
115 return {
116 return {
116 startState: function () {
117 startState: function () {
117 var state = htmlMode.startState();
118 var state = CodeMirror.startState(htmlMode);
118 return {token: html, localMode: null, localState: null, htmlState: state};
119 return {token: html, inTag: null, localMode: null, localState: null, htmlState: state};
119 },
120 },
120
121
121 copyState: function (state) {
122 copyState: function (state) {
122 var local;
123 var local;
123 if (state.localState) {
124 if (state.localState) {
124 local = CodeMirror.copyState(state.localMode, state.localState);
125 local = CodeMirror.copyState(state.localMode, state.localState);
125 }
126 }
126 return {token: state.token, localMode: state.localMode, localState: local,
127 return {token: state.token, inTag: state.inTag,
128 localMode: state.localMode, localState: local,
127 htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
129 htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
128 },
130 },
129
131
130 token: function (stream, state) {
132 token: function (stream, state) {
131 return state.token(stream, state);
133 return state.token(stream, state);
132 },
134 },
133
135
134 indent: function (state, textAfter) {
136 indent: function (state, textAfter, line) {
135 if (!state.localMode || /^\s*<\//.test(textAfter))
137 if (!state.localMode || /^\s*<\//.test(textAfter))
136 return htmlMode.indent(state.htmlState, textAfter);
138 return htmlMode.indent(state.htmlState, textAfter, line);
137 else if (state.localMode.indent)
139 else if (state.localMode.indent)
138 return state.localMode.indent(state.localState, textAfter);
140 return state.localMode.indent(state.localState, textAfter, line);
139 else
141 else
140 return CodeMirror.Pass;
142 return CodeMirror.Pass;
141 },
143 },
142
144
143 innerMode: function (state) {
145 innerMode: function (state) {
144 return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode};
146 return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode};
145 }
147 }
146 };
148 };
147 }, "xml", "javascript", "css");
149 }, "xml", "javascript", "css");
148
150
149 CodeMirror.defineMIME("text/html", "htmlmixed");
151 CodeMirror.defineMIME("text/html", "htmlmixed");
150 });
152 });
@@ -1,113 +1,113 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("http", function() {
14 CodeMirror.defineMode("http", function() {
15 function failFirstLine(stream, state) {
15 function failFirstLine(stream, state) {
16 stream.skipToEnd();
16 stream.skipToEnd();
17 state.cur = header;
17 state.cur = header;
18 return "error";
18 return "error";
19 }
19 }
20
20
21 function start(stream, state) {
21 function start(stream, state) {
22 if (stream.match(/^HTTP\/\d\.\d/)) {
22 if (stream.match(/^HTTP\/\d\.\d/)) {
23 state.cur = responseStatusCode;
23 state.cur = responseStatusCode;
24 return "keyword";
24 return "keyword";
25 } else if (stream.match(/^[A-Z]+/) && /[ \t]/.test(stream.peek())) {
25 } else if (stream.match(/^[A-Z]+/) && /[ \t]/.test(stream.peek())) {
26 state.cur = requestPath;
26 state.cur = requestPath;
27 return "keyword";
27 return "keyword";
28 } else {
28 } else {
29 return failFirstLine(stream, state);
29 return failFirstLine(stream, state);
30 }
30 }
31 }
31 }
32
32
33 function responseStatusCode(stream, state) {
33 function responseStatusCode(stream, state) {
34 var code = stream.match(/^\d+/);
34 var code = stream.match(/^\d+/);
35 if (!code) return failFirstLine(stream, state);
35 if (!code) return failFirstLine(stream, state);
36
36
37 state.cur = responseStatusText;
37 state.cur = responseStatusText;
38 var status = Number(code[0]);
38 var status = Number(code[0]);
39 if (status >= 100 && status < 200) {
39 if (status >= 100 && status < 200) {
40 return "positive informational";
40 return "positive informational";
41 } else if (status >= 200 && status < 300) {
41 } else if (status >= 200 && status < 300) {
42 return "positive success";
42 return "positive success";
43 } else if (status >= 300 && status < 400) {
43 } else if (status >= 300 && status < 400) {
44 return "positive redirect";
44 return "positive redirect";
45 } else if (status >= 400 && status < 500) {
45 } else if (status >= 400 && status < 500) {
46 return "negative client-error";
46 return "negative client-error";
47 } else if (status >= 500 && status < 600) {
47 } else if (status >= 500 && status < 600) {
48 return "negative server-error";
48 return "negative server-error";
49 } else {
49 } else {
50 return "error";
50 return "error";
51 }
51 }
52 }
52 }
53
53
54 function responseStatusText(stream, state) {
54 function responseStatusText(stream, state) {
55 stream.skipToEnd();
55 stream.skipToEnd();
56 state.cur = header;
56 state.cur = header;
57 return null;
57 return null;
58 }
58 }
59
59
60 function requestPath(stream, state) {
60 function requestPath(stream, state) {
61 stream.eatWhile(/\S/);
61 stream.eatWhile(/\S/);
62 state.cur = requestProtocol;
62 state.cur = requestProtocol;
63 return "string-2";
63 return "string-2";
64 }
64 }
65
65
66 function requestProtocol(stream, state) {
66 function requestProtocol(stream, state) {
67 if (stream.match(/^HTTP\/\d\.\d$/)) {
67 if (stream.match(/^HTTP\/\d\.\d$/)) {
68 state.cur = header;
68 state.cur = header;
69 return "keyword";
69 return "keyword";
70 } else {
70 } else {
71 return failFirstLine(stream, state);
71 return failFirstLine(stream, state);
72 }
72 }
73 }
73 }
74
74
75 function header(stream) {
75 function header(stream) {
76 if (stream.sol() && !stream.eat(/[ \t]/)) {
76 if (stream.sol() && !stream.eat(/[ \t]/)) {
77 if (stream.match(/^.*?:/)) {
77 if (stream.match(/^.*?:/)) {
78 return "atom";
78 return "atom";
79 } else {
79 } else {
80 stream.skipToEnd();
80 stream.skipToEnd();
81 return "error";
81 return "error";
82 }
82 }
83 } else {
83 } else {
84 stream.skipToEnd();
84 stream.skipToEnd();
85 return "string";
85 return "string";
86 }
86 }
87 }
87 }
88
88
89 function body(stream) {
89 function body(stream) {
90 stream.skipToEnd();
90 stream.skipToEnd();
91 return null;
91 return null;
92 }
92 }
93
93
94 return {
94 return {
95 token: function(stream, state) {
95 token: function(stream, state) {
96 var cur = state.cur;
96 var cur = state.cur;
97 if (cur != header && cur != body && stream.eatSpace()) return null;
97 if (cur != header && cur != body && stream.eatSpace()) return null;
98 return cur(stream, state);
98 return cur(stream, state);
99 },
99 },
100
100
101 blankLine: function(state) {
101 blankLine: function(state) {
102 state.cur = body;
102 state.cur = body;
103 },
103 },
104
104
105 startState: function() {
105 startState: function() {
106 return {cur: start};
106 return {cur: start};
107 }
107 }
108 };
108 };
109 });
109 });
110
110
111 CodeMirror.defineMIME("message/http", "http");
111 CodeMirror.defineMIME("message/http", "http");
112
112
113 });
113 });
@@ -1,290 +1,290 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 function wordRegexp(words) {
14 function wordRegexp(words) {
15 return new RegExp('^((' + words.join(')|(') + '))\\b', 'i');
15 return new RegExp('^((' + words.join(')|(') + '))\\b', 'i');
16 };
16 };
17
17
18 var builtinArray = [
18 var builtinArray = [
19 'a_correlate', 'abs', 'acos', 'adapt_hist_equal', 'alog',
19 'a_correlate', 'abs', 'acos', 'adapt_hist_equal', 'alog',
20 'alog2', 'alog10', 'amoeba', 'annotate', 'app_user_dir',
20 'alog2', 'alog10', 'amoeba', 'annotate', 'app_user_dir',
21 'app_user_dir_query', 'arg_present', 'array_equal', 'array_indices',
21 'app_user_dir_query', 'arg_present', 'array_equal', 'array_indices',
22 'arrow', 'ascii_template', 'asin', 'assoc', 'atan',
22 'arrow', 'ascii_template', 'asin', 'assoc', 'atan',
23 'axis', 'axis', 'bandpass_filter', 'bandreject_filter', 'barplot',
23 'axis', 'axis', 'bandpass_filter', 'bandreject_filter', 'barplot',
24 'bar_plot', 'beseli', 'beselj', 'beselk', 'besely',
24 'bar_plot', 'beseli', 'beselj', 'beselk', 'besely',
25 'beta', 'biginteger', 'bilinear', 'bin_date', 'binary_template',
25 'beta', 'biginteger', 'bilinear', 'bin_date', 'binary_template',
26 'bindgen', 'binomial', 'bit_ffs', 'bit_population', 'blas_axpy',
26 'bindgen', 'binomial', 'bit_ffs', 'bit_population', 'blas_axpy',
27 'blk_con', 'boolarr', 'boolean', 'boxplot', 'box_cursor',
27 'blk_con', 'boolarr', 'boolean', 'boxplot', 'box_cursor',
28 'breakpoint', 'broyden', 'bubbleplot', 'butterworth', 'bytarr',
28 'breakpoint', 'broyden', 'bubbleplot', 'butterworth', 'bytarr',
29 'byte', 'byteorder', 'bytscl', 'c_correlate', 'calendar',
29 'byte', 'byteorder', 'bytscl', 'c_correlate', 'calendar',
30 'caldat', 'call_external', 'call_function', 'call_method',
30 'caldat', 'call_external', 'call_function', 'call_method',
31 'call_procedure', 'canny', 'catch', 'cd', 'cdf', 'ceil',
31 'call_procedure', 'canny', 'catch', 'cd', 'cdf', 'ceil',
32 'chebyshev', 'check_math', 'chisqr_cvf', 'chisqr_pdf', 'choldc',
32 'chebyshev', 'check_math', 'chisqr_cvf', 'chisqr_pdf', 'choldc',
33 'cholsol', 'cindgen', 'cir_3pnt', 'clipboard', 'close',
33 'cholsol', 'cindgen', 'cir_3pnt', 'clipboard', 'close',
34 'clust_wts', 'cluster', 'cluster_tree', 'cmyk_convert', 'code_coverage',
34 'clust_wts', 'cluster', 'cluster_tree', 'cmyk_convert', 'code_coverage',
35 'color_convert', 'color_exchange', 'color_quan', 'color_range_map',
35 'color_convert', 'color_exchange', 'color_quan', 'color_range_map',
36 'colorbar', 'colorize_sample', 'colormap_applicable',
36 'colorbar', 'colorize_sample', 'colormap_applicable',
37 'colormap_gradient', 'colormap_rotation', 'colortable',
37 'colormap_gradient', 'colormap_rotation', 'colortable',
38 'comfit', 'command_line_args', 'common', 'compile_opt', 'complex',
38 'comfit', 'command_line_args', 'common', 'compile_opt', 'complex',
39 'complexarr', 'complexround', 'compute_mesh_normals', 'cond', 'congrid',
39 'complexarr', 'complexround', 'compute_mesh_normals', 'cond', 'congrid',
40 'conj', 'constrained_min', 'contour', 'contour', 'convert_coord',
40 'conj', 'constrained_min', 'contour', 'contour', 'convert_coord',
41 'convol', 'convol_fft', 'coord2to3', 'copy_lun', 'correlate',
41 'convol', 'convol_fft', 'coord2to3', 'copy_lun', 'correlate',
42 'cos', 'cosh', 'cpu', 'cramer', 'createboxplotdata',
42 'cos', 'cosh', 'cpu', 'cramer', 'createboxplotdata',
43 'create_cursor', 'create_struct', 'create_view', 'crossp', 'crvlength',
43 'create_cursor', 'create_struct', 'create_view', 'crossp', 'crvlength',
44 'ct_luminance', 'cti_test', 'cursor', 'curvefit', 'cv_coord',
44 'ct_luminance', 'cti_test', 'cursor', 'curvefit', 'cv_coord',
45 'cvttobm', 'cw_animate', 'cw_animate_getp', 'cw_animate_load',
45 'cvttobm', 'cw_animate', 'cw_animate_getp', 'cw_animate_load',
46 'cw_animate_run', 'cw_arcball', 'cw_bgroup', 'cw_clr_index',
46 'cw_animate_run', 'cw_arcball', 'cw_bgroup', 'cw_clr_index',
47 'cw_colorsel', 'cw_defroi', 'cw_field', 'cw_filesel', 'cw_form',
47 'cw_colorsel', 'cw_defroi', 'cw_field', 'cw_filesel', 'cw_form',
48 'cw_fslider', 'cw_light_editor', 'cw_light_editor_get',
48 'cw_fslider', 'cw_light_editor', 'cw_light_editor_get',
49 'cw_light_editor_set', 'cw_orient', 'cw_palette_editor',
49 'cw_light_editor_set', 'cw_orient', 'cw_palette_editor',
50 'cw_palette_editor_get', 'cw_palette_editor_set', 'cw_pdmenu',
50 'cw_palette_editor_get', 'cw_palette_editor_set', 'cw_pdmenu',
51 'cw_rgbslider', 'cw_tmpl', 'cw_zoom', 'db_exists',
51 'cw_rgbslider', 'cw_tmpl', 'cw_zoom', 'db_exists',
52 'dblarr', 'dcindgen', 'dcomplex', 'dcomplexarr', 'define_key',
52 'dblarr', 'dcindgen', 'dcomplex', 'dcomplexarr', 'define_key',
53 'define_msgblk', 'define_msgblk_from_file', 'defroi', 'defsysv',
53 'define_msgblk', 'define_msgblk_from_file', 'defroi', 'defsysv',
54 'delvar', 'dendro_plot', 'dendrogram', 'deriv', 'derivsig',
54 'delvar', 'dendro_plot', 'dendrogram', 'deriv', 'derivsig',
55 'determ', 'device', 'dfpmin', 'diag_matrix', 'dialog_dbconnect',
55 'determ', 'device', 'dfpmin', 'diag_matrix', 'dialog_dbconnect',
56 'dialog_message', 'dialog_pickfile', 'dialog_printersetup',
56 'dialog_message', 'dialog_pickfile', 'dialog_printersetup',
57 'dialog_printjob', 'dialog_read_image',
57 'dialog_printjob', 'dialog_read_image',
58 'dialog_write_image', 'dictionary', 'digital_filter', 'dilate', 'dindgen',
58 'dialog_write_image', 'dictionary', 'digital_filter', 'dilate', 'dindgen',
59 'dissolve', 'dist', 'distance_measure', 'dlm_load', 'dlm_register',
59 'dissolve', 'dist', 'distance_measure', 'dlm_load', 'dlm_register',
60 'doc_library', 'double', 'draw_roi', 'edge_dog', 'efont',
60 'doc_library', 'double', 'draw_roi', 'edge_dog', 'efont',
61 'eigenql', 'eigenvec', 'ellipse', 'elmhes', 'emboss',
61 'eigenql', 'eigenvec', 'ellipse', 'elmhes', 'emboss',
62 'empty', 'enable_sysrtn', 'eof', 'eos', 'erase',
62 'empty', 'enable_sysrtn', 'eof', 'eos', 'erase',
63 'erf', 'erfc', 'erfcx', 'erode', 'errorplot',
63 'erf', 'erfc', 'erfcx', 'erode', 'errorplot',
64 'errplot', 'estimator_filter', 'execute', 'exit', 'exp',
64 'errplot', 'estimator_filter', 'execute', 'exit', 'exp',
65 'expand', 'expand_path', 'expint', 'extrac', 'extract_slice',
65 'expand', 'expand_path', 'expint', 'extrac', 'extract_slice',
66 'f_cvf', 'f_pdf', 'factorial', 'fft', 'file_basename',
66 'f_cvf', 'f_pdf', 'factorial', 'fft', 'file_basename',
67 'file_chmod', 'file_copy', 'file_delete', 'file_dirname',
67 'file_chmod', 'file_copy', 'file_delete', 'file_dirname',
68 'file_expand_path', 'file_gunzip', 'file_gzip', 'file_info',
68 'file_expand_path', 'file_gunzip', 'file_gzip', 'file_info',
69 'file_lines', 'file_link', 'file_mkdir', 'file_move',
69 'file_lines', 'file_link', 'file_mkdir', 'file_move',
70 'file_poll_input', 'file_readlink', 'file_same',
70 'file_poll_input', 'file_readlink', 'file_same',
71 'file_search', 'file_tar', 'file_test', 'file_untar', 'file_unzip',
71 'file_search', 'file_tar', 'file_test', 'file_untar', 'file_unzip',
72 'file_which', 'file_zip', 'filepath', 'findgen', 'finite',
72 'file_which', 'file_zip', 'filepath', 'findgen', 'finite',
73 'fix', 'flick', 'float', 'floor', 'flow3',
73 'fix', 'flick', 'float', 'floor', 'flow3',
74 'fltarr', 'flush', 'format_axis_values', 'forward_function', 'free_lun',
74 'fltarr', 'flush', 'format_axis_values', 'forward_function', 'free_lun',
75 'fstat', 'fulstr', 'funct', 'function', 'fv_test',
75 'fstat', 'fulstr', 'funct', 'function', 'fv_test',
76 'fx_root', 'fz_roots', 'gamma', 'gamma_ct', 'gauss_cvf',
76 'fx_root', 'fz_roots', 'gamma', 'gamma_ct', 'gauss_cvf',
77 'gauss_pdf', 'gauss_smooth', 'gauss2dfit', 'gaussfit',
77 'gauss_pdf', 'gauss_smooth', 'gauss2dfit', 'gaussfit',
78 'gaussian_function', 'gaussint', 'get_drive_list', 'get_dxf_objects',
78 'gaussian_function', 'gaussint', 'get_drive_list', 'get_dxf_objects',
79 'get_kbrd', 'get_login_info',
79 'get_kbrd', 'get_login_info',
80 'get_lun', 'get_screen_size', 'getenv', 'getwindows', 'greg2jul',
80 'get_lun', 'get_screen_size', 'getenv', 'getwindows', 'greg2jul',
81 'grib', 'grid_input', 'grid_tps', 'grid3', 'griddata',
81 'grib', 'grid_input', 'grid_tps', 'grid3', 'griddata',
82 'gs_iter', 'h_eq_ct', 'h_eq_int', 'hanning', 'hash',
82 'gs_iter', 'h_eq_ct', 'h_eq_int', 'hanning', 'hash',
83 'hdf', 'hdf5', 'heap_free', 'heap_gc', 'heap_nosave',
83 'hdf', 'hdf5', 'heap_free', 'heap_gc', 'heap_nosave',
84 'heap_refcount', 'heap_save', 'help', 'hilbert', 'hist_2d',
84 'heap_refcount', 'heap_save', 'help', 'hilbert', 'hist_2d',
85 'hist_equal', 'histogram', 'hls', 'hough', 'hqr',
85 'hist_equal', 'histogram', 'hls', 'hough', 'hqr',
86 'hsv', 'i18n_multibytetoutf8',
86 'hsv', 'i18n_multibytetoutf8',
87 'i18n_multibytetowidechar', 'i18n_utf8tomultibyte',
87 'i18n_multibytetowidechar', 'i18n_utf8tomultibyte',
88 'i18n_widechartomultibyte',
88 'i18n_widechartomultibyte',
89 'ibeta', 'icontour', 'iconvertcoord', 'idelete', 'identity',
89 'ibeta', 'icontour', 'iconvertcoord', 'idelete', 'identity',
90 'idl_base64', 'idl_container', 'idl_validname',
90 'idl_base64', 'idl_container', 'idl_validname',
91 'idlexbr_assistant', 'idlitsys_createtool',
91 'idlexbr_assistant', 'idlitsys_createtool',
92 'idlunit', 'iellipse', 'igamma', 'igetcurrent', 'igetdata',
92 'idlunit', 'iellipse', 'igamma', 'igetcurrent', 'igetdata',
93 'igetid', 'igetproperty', 'iimage', 'image', 'image_cont',
93 'igetid', 'igetproperty', 'iimage', 'image', 'image_cont',
94 'image_statistics', 'image_threshold', 'imaginary', 'imap', 'indgen',
94 'image_statistics', 'image_threshold', 'imaginary', 'imap', 'indgen',
95 'int_2d', 'int_3d', 'int_tabulated', 'intarr', 'interpol',
95 'int_2d', 'int_3d', 'int_tabulated', 'intarr', 'interpol',
96 'interpolate', 'interval_volume', 'invert', 'ioctl', 'iopen',
96 'interpolate', 'interval_volume', 'invert', 'ioctl', 'iopen',
97 'ir_filter', 'iplot', 'ipolygon', 'ipolyline', 'iputdata',
97 'ir_filter', 'iplot', 'ipolygon', 'ipolyline', 'iputdata',
98 'iregister', 'ireset', 'iresolve', 'irotate', 'isa',
98 'iregister', 'ireset', 'iresolve', 'irotate', 'isa',
99 'isave', 'iscale', 'isetcurrent', 'isetproperty', 'ishft',
99 'isave', 'iscale', 'isetcurrent', 'isetproperty', 'ishft',
100 'isocontour', 'isosurface', 'isurface', 'itext', 'itranslate',
100 'isocontour', 'isosurface', 'isurface', 'itext', 'itranslate',
101 'ivector', 'ivolume', 'izoom', 'journal', 'json_parse',
101 'ivector', 'ivolume', 'izoom', 'journal', 'json_parse',
102 'json_serialize', 'jul2greg', 'julday', 'keyword_set', 'krig2d',
102 'json_serialize', 'jul2greg', 'julday', 'keyword_set', 'krig2d',
103 'kurtosis', 'kw_test', 'l64indgen', 'la_choldc', 'la_cholmprove',
103 'kurtosis', 'kw_test', 'l64indgen', 'la_choldc', 'la_cholmprove',
104 'la_cholsol', 'la_determ', 'la_eigenproblem', 'la_eigenql', 'la_eigenvec',
104 'la_cholsol', 'la_determ', 'la_eigenproblem', 'la_eigenql', 'la_eigenvec',
105 'la_elmhes', 'la_gm_linear_model', 'la_hqr', 'la_invert',
105 'la_elmhes', 'la_gm_linear_model', 'la_hqr', 'la_invert',
106 'la_least_square_equality', 'la_least_squares', 'la_linear_equation',
106 'la_least_square_equality', 'la_least_squares', 'la_linear_equation',
107 'la_ludc', 'la_lumprove', 'la_lusol',
107 'la_ludc', 'la_lumprove', 'la_lusol',
108 'la_svd', 'la_tridc', 'la_trimprove', 'la_triql', 'la_trired',
108 'la_svd', 'la_tridc', 'la_trimprove', 'la_triql', 'la_trired',
109 'la_trisol', 'label_date', 'label_region', 'ladfit', 'laguerre',
109 'la_trisol', 'label_date', 'label_region', 'ladfit', 'laguerre',
110 'lambda', 'lambdap', 'lambertw', 'laplacian', 'least_squares_filter',
110 'lambda', 'lambdap', 'lambertw', 'laplacian', 'least_squares_filter',
111 'leefilt', 'legend', 'legendre', 'linbcg', 'lindgen',
111 'leefilt', 'legend', 'legendre', 'linbcg', 'lindgen',
112 'linfit', 'linkimage', 'list', 'll_arc_distance', 'lmfit',
112 'linfit', 'linkimage', 'list', 'll_arc_distance', 'lmfit',
113 'lmgr', 'lngamma', 'lnp_test', 'loadct', 'locale_get',
113 'lmgr', 'lngamma', 'lnp_test', 'loadct', 'locale_get',
114 'logical_and', 'logical_or', 'logical_true', 'lon64arr', 'lonarr',
114 'logical_and', 'logical_or', 'logical_true', 'lon64arr', 'lonarr',
115 'long', 'long64', 'lsode', 'lu_complex', 'ludc',
115 'long', 'long64', 'lsode', 'lu_complex', 'ludc',
116 'lumprove', 'lusol', 'm_correlate', 'machar', 'make_array',
116 'lumprove', 'lusol', 'm_correlate', 'machar', 'make_array',
117 'make_dll', 'make_rt', 'map', 'mapcontinents', 'mapgrid',
117 'make_dll', 'make_rt', 'map', 'mapcontinents', 'mapgrid',
118 'map_2points', 'map_continents', 'map_grid', 'map_image', 'map_patch',
118 'map_2points', 'map_continents', 'map_grid', 'map_image', 'map_patch',
119 'map_proj_forward', 'map_proj_image', 'map_proj_info',
119 'map_proj_forward', 'map_proj_image', 'map_proj_info',
120 'map_proj_init', 'map_proj_inverse',
120 'map_proj_init', 'map_proj_inverse',
121 'map_set', 'matrix_multiply', 'matrix_power', 'max', 'md_test',
121 'map_set', 'matrix_multiply', 'matrix_power', 'max', 'md_test',
122 'mean', 'meanabsdev', 'mean_filter', 'median', 'memory',
122 'mean', 'meanabsdev', 'mean_filter', 'median', 'memory',
123 'mesh_clip', 'mesh_decimate', 'mesh_issolid',
123 'mesh_clip', 'mesh_decimate', 'mesh_issolid',
124 'mesh_merge', 'mesh_numtriangles',
124 'mesh_merge', 'mesh_numtriangles',
125 'mesh_obj', 'mesh_smooth', 'mesh_surfacearea',
125 'mesh_obj', 'mesh_smooth', 'mesh_surfacearea',
126 'mesh_validate', 'mesh_volume',
126 'mesh_validate', 'mesh_volume',
127 'message', 'min', 'min_curve_surf', 'mk_html_help', 'modifyct',
127 'message', 'min', 'min_curve_surf', 'mk_html_help', 'modifyct',
128 'moment', 'morph_close', 'morph_distance',
128 'moment', 'morph_close', 'morph_distance',
129 'morph_gradient', 'morph_hitormiss',
129 'morph_gradient', 'morph_hitormiss',
130 'morph_open', 'morph_thin', 'morph_tophat', 'multi', 'n_elements',
130 'morph_open', 'morph_thin', 'morph_tophat', 'multi', 'n_elements',
131 'n_params', 'n_tags', 'ncdf', 'newton', 'noise_hurl',
131 'n_params', 'n_tags', 'ncdf', 'newton', 'noise_hurl',
132 'noise_pick', 'noise_scatter', 'noise_slur', 'norm', 'obj_class',
132 'noise_pick', 'noise_scatter', 'noise_slur', 'norm', 'obj_class',
133 'obj_destroy', 'obj_hasmethod', 'obj_isa', 'obj_new', 'obj_valid',
133 'obj_destroy', 'obj_hasmethod', 'obj_isa', 'obj_new', 'obj_valid',
134 'objarr', 'on_error', 'on_ioerror', 'online_help', 'openr',
134 'objarr', 'on_error', 'on_ioerror', 'online_help', 'openr',
135 'openu', 'openw', 'oplot', 'oploterr', 'orderedhash',
135 'openu', 'openw', 'oplot', 'oploterr', 'orderedhash',
136 'p_correlate', 'parse_url', 'particle_trace', 'path_cache', 'path_sep',
136 'p_correlate', 'parse_url', 'particle_trace', 'path_cache', 'path_sep',
137 'pcomp', 'plot', 'plot3d', 'plot', 'plot_3dbox',
137 'pcomp', 'plot', 'plot3d', 'plot', 'plot_3dbox',
138 'plot_field', 'ploterr', 'plots', 'polar_contour', 'polar_surface',
138 'plot_field', 'ploterr', 'plots', 'polar_contour', 'polar_surface',
139 'polyfill', 'polyshade', 'pnt_line', 'point_lun', 'polarplot',
139 'polyfill', 'polyshade', 'pnt_line', 'point_lun', 'polarplot',
140 'poly', 'poly_2d', 'poly_area', 'poly_fit', 'polyfillv',
140 'poly', 'poly_2d', 'poly_area', 'poly_fit', 'polyfillv',
141 'polygon', 'polyline', 'polywarp', 'popd', 'powell',
141 'polygon', 'polyline', 'polywarp', 'popd', 'powell',
142 'pref_commit', 'pref_get', 'pref_set', 'prewitt', 'primes',
142 'pref_commit', 'pref_get', 'pref_set', 'prewitt', 'primes',
143 'print', 'printf', 'printd', 'pro', 'product',
143 'print', 'printf', 'printd', 'pro', 'product',
144 'profile', 'profiler', 'profiles', 'project_vol', 'ps_show_fonts',
144 'profile', 'profiler', 'profiles', 'project_vol', 'ps_show_fonts',
145 'psafm', 'pseudo', 'ptr_free', 'ptr_new', 'ptr_valid',
145 'psafm', 'pseudo', 'ptr_free', 'ptr_new', 'ptr_valid',
146 'ptrarr', 'pushd', 'qgrid3', 'qhull', 'qromb',
146 'ptrarr', 'pushd', 'qgrid3', 'qhull', 'qromb',
147 'qromo', 'qsimp', 'query_*', 'query_ascii', 'query_bmp',
147 'qromo', 'qsimp', 'query_*', 'query_ascii', 'query_bmp',
148 'query_csv', 'query_dicom', 'query_gif', 'query_image', 'query_jpeg',
148 'query_csv', 'query_dicom', 'query_gif', 'query_image', 'query_jpeg',
149 'query_jpeg2000', 'query_mrsid', 'query_pict', 'query_png', 'query_ppm',
149 'query_jpeg2000', 'query_mrsid', 'query_pict', 'query_png', 'query_ppm',
150 'query_srf', 'query_tiff', 'query_video', 'query_wav', 'r_correlate',
150 'query_srf', 'query_tiff', 'query_video', 'query_wav', 'r_correlate',
151 'r_test', 'radon', 'randomn', 'randomu', 'ranks',
151 'r_test', 'radon', 'randomn', 'randomu', 'ranks',
152 'rdpix', 'read', 'readf', 'read_ascii', 'read_binary',
152 'rdpix', 'read', 'readf', 'read_ascii', 'read_binary',
153 'read_bmp', 'read_csv', 'read_dicom', 'read_gif', 'read_image',
153 'read_bmp', 'read_csv', 'read_dicom', 'read_gif', 'read_image',
154 'read_interfile', 'read_jpeg', 'read_jpeg2000', 'read_mrsid', 'read_pict',
154 'read_interfile', 'read_jpeg', 'read_jpeg2000', 'read_mrsid', 'read_pict',
155 'read_png', 'read_ppm', 'read_spr', 'read_srf', 'read_sylk',
155 'read_png', 'read_ppm', 'read_spr', 'read_srf', 'read_sylk',
156 'read_tiff', 'read_video', 'read_wav', 'read_wave', 'read_x11_bitmap',
156 'read_tiff', 'read_video', 'read_wav', 'read_wave', 'read_x11_bitmap',
157 'read_xwd', 'reads', 'readu', 'real_part', 'rebin',
157 'read_xwd', 'reads', 'readu', 'real_part', 'rebin',
158 'recall_commands', 'recon3', 'reduce_colors', 'reform', 'region_grow',
158 'recall_commands', 'recon3', 'reduce_colors', 'reform', 'region_grow',
159 'register_cursor', 'regress', 'replicate',
159 'register_cursor', 'regress', 'replicate',
160 'replicate_inplace', 'resolve_all',
160 'replicate_inplace', 'resolve_all',
161 'resolve_routine', 'restore', 'retall', 'return', 'reverse',
161 'resolve_routine', 'restore', 'retall', 'return', 'reverse',
162 'rk4', 'roberts', 'rot', 'rotate', 'round',
162 'rk4', 'roberts', 'rot', 'rotate', 'round',
163 'routine_filepath', 'routine_info', 'rs_test', 's_test', 'save',
163 'routine_filepath', 'routine_info', 'rs_test', 's_test', 'save',
164 'savgol', 'scale3', 'scale3d', 'scatterplot', 'scatterplot3d',
164 'savgol', 'scale3', 'scale3d', 'scatterplot', 'scatterplot3d',
165 'scope_level', 'scope_traceback', 'scope_varfetch',
165 'scope_level', 'scope_traceback', 'scope_varfetch',
166 'scope_varname', 'search2d',
166 'scope_varname', 'search2d',
167 'search3d', 'sem_create', 'sem_delete', 'sem_lock', 'sem_release',
167 'search3d', 'sem_create', 'sem_delete', 'sem_lock', 'sem_release',
168 'set_plot', 'set_shading', 'setenv', 'sfit', 'shade_surf',
168 'set_plot', 'set_shading', 'setenv', 'sfit', 'shade_surf',
169 'shade_surf_irr', 'shade_volume', 'shift', 'shift_diff', 'shmdebug',
169 'shade_surf_irr', 'shade_volume', 'shift', 'shift_diff', 'shmdebug',
170 'shmmap', 'shmunmap', 'shmvar', 'show3', 'showfont',
170 'shmmap', 'shmunmap', 'shmvar', 'show3', 'showfont',
171 'signum', 'simplex', 'sin', 'sindgen', 'sinh',
171 'signum', 'simplex', 'sin', 'sindgen', 'sinh',
172 'size', 'skewness', 'skip_lun', 'slicer3', 'slide_image',
172 'size', 'skewness', 'skip_lun', 'slicer3', 'slide_image',
173 'smooth', 'sobel', 'socket', 'sort', 'spawn',
173 'smooth', 'sobel', 'socket', 'sort', 'spawn',
174 'sph_4pnt', 'sph_scat', 'spher_harm', 'spl_init', 'spl_interp',
174 'sph_4pnt', 'sph_scat', 'spher_harm', 'spl_init', 'spl_interp',
175 'spline', 'spline_p', 'sprsab', 'sprsax', 'sprsin',
175 'spline', 'spline_p', 'sprsab', 'sprsax', 'sprsin',
176 'sprstp', 'sqrt', 'standardize', 'stddev', 'stop',
176 'sprstp', 'sqrt', 'standardize', 'stddev', 'stop',
177 'strarr', 'strcmp', 'strcompress', 'streamline', 'streamline',
177 'strarr', 'strcmp', 'strcompress', 'streamline', 'streamline',
178 'stregex', 'stretch', 'string', 'strjoin', 'strlen',
178 'stregex', 'stretch', 'string', 'strjoin', 'strlen',
179 'strlowcase', 'strmatch', 'strmessage', 'strmid', 'strpos',
179 'strlowcase', 'strmatch', 'strmessage', 'strmid', 'strpos',
180 'strput', 'strsplit', 'strtrim', 'struct_assign', 'struct_hide',
180 'strput', 'strsplit', 'strtrim', 'struct_assign', 'struct_hide',
181 'strupcase', 'surface', 'surface', 'surfr', 'svdc',
181 'strupcase', 'surface', 'surface', 'surfr', 'svdc',
182 'svdfit', 'svsol', 'swap_endian', 'swap_endian_inplace', 'symbol',
182 'svdfit', 'svsol', 'swap_endian', 'swap_endian_inplace', 'symbol',
183 'systime', 't_cvf', 't_pdf', 't3d', 'tag_names',
183 'systime', 't_cvf', 't_pdf', 't3d', 'tag_names',
184 'tan', 'tanh', 'tek_color', 'temporary', 'terminal_size',
184 'tan', 'tanh', 'tek_color', 'temporary', 'terminal_size',
185 'tetra_clip', 'tetra_surface', 'tetra_volume', 'text', 'thin',
185 'tetra_clip', 'tetra_surface', 'tetra_volume', 'text', 'thin',
186 'thread', 'threed', 'tic', 'time_test2', 'timegen',
186 'thread', 'threed', 'tic', 'time_test2', 'timegen',
187 'timer', 'timestamp', 'timestamptovalues', 'tm_test', 'toc',
187 'timer', 'timestamp', 'timestamptovalues', 'tm_test', 'toc',
188 'total', 'trace', 'transpose', 'tri_surf', 'triangulate',
188 'total', 'trace', 'transpose', 'tri_surf', 'triangulate',
189 'trigrid', 'triql', 'trired', 'trisol', 'truncate_lun',
189 'trigrid', 'triql', 'trired', 'trisol', 'truncate_lun',
190 'ts_coef', 'ts_diff', 'ts_fcast', 'ts_smooth', 'tv',
190 'ts_coef', 'ts_diff', 'ts_fcast', 'ts_smooth', 'tv',
191 'tvcrs', 'tvlct', 'tvrd', 'tvscl', 'typename',
191 'tvcrs', 'tvlct', 'tvrd', 'tvscl', 'typename',
192 'uindgen', 'uint', 'uintarr', 'ul64indgen', 'ulindgen',
192 'uindgen', 'uint', 'uintarr', 'ul64indgen', 'ulindgen',
193 'ulon64arr', 'ulonarr', 'ulong', 'ulong64', 'uniq',
193 'ulon64arr', 'ulonarr', 'ulong', 'ulong64', 'uniq',
194 'unsharp_mask', 'usersym', 'value_locate', 'variance', 'vector',
194 'unsharp_mask', 'usersym', 'value_locate', 'variance', 'vector',
195 'vector_field', 'vel', 'velovect', 'vert_t3d', 'voigt',
195 'vector_field', 'vel', 'velovect', 'vert_t3d', 'voigt',
196 'volume', 'voronoi', 'voxel_proj', 'wait', 'warp_tri',
196 'volume', 'voronoi', 'voxel_proj', 'wait', 'warp_tri',
197 'watershed', 'wdelete', 'wf_draw', 'where', 'widget_base',
197 'watershed', 'wdelete', 'wf_draw', 'where', 'widget_base',
198 'widget_button', 'widget_combobox', 'widget_control',
198 'widget_button', 'widget_combobox', 'widget_control',
199 'widget_displaycontextmenu', 'widget_draw',
199 'widget_displaycontextmenu', 'widget_draw',
200 'widget_droplist', 'widget_event', 'widget_info',
200 'widget_droplist', 'widget_event', 'widget_info',
201 'widget_label', 'widget_list',
201 'widget_label', 'widget_list',
202 'widget_propertysheet', 'widget_slider', 'widget_tab',
202 'widget_propertysheet', 'widget_slider', 'widget_tab',
203 'widget_table', 'widget_text',
203 'widget_table', 'widget_text',
204 'widget_tree', 'widget_tree_move', 'widget_window',
204 'widget_tree', 'widget_tree_move', 'widget_window',
205 'wiener_filter', 'window',
205 'wiener_filter', 'window',
206 'window', 'write_bmp', 'write_csv', 'write_gif', 'write_image',
206 'window', 'write_bmp', 'write_csv', 'write_gif', 'write_image',
207 'write_jpeg', 'write_jpeg2000', 'write_nrif', 'write_pict', 'write_png',
207 'write_jpeg', 'write_jpeg2000', 'write_nrif', 'write_pict', 'write_png',
208 'write_ppm', 'write_spr', 'write_srf', 'write_sylk', 'write_tiff',
208 'write_ppm', 'write_spr', 'write_srf', 'write_sylk', 'write_tiff',
209 'write_video', 'write_wav', 'write_wave', 'writeu', 'wset',
209 'write_video', 'write_wav', 'write_wave', 'writeu', 'wset',
210 'wshow', 'wtn', 'wv_applet', 'wv_cwt', 'wv_cw_wavelet',
210 'wshow', 'wtn', 'wv_applet', 'wv_cwt', 'wv_cw_wavelet',
211 'wv_denoise', 'wv_dwt', 'wv_fn_coiflet',
211 'wv_denoise', 'wv_dwt', 'wv_fn_coiflet',
212 'wv_fn_daubechies', 'wv_fn_gaussian',
212 'wv_fn_daubechies', 'wv_fn_gaussian',
213 'wv_fn_haar', 'wv_fn_morlet', 'wv_fn_paul',
213 'wv_fn_haar', 'wv_fn_morlet', 'wv_fn_paul',
214 'wv_fn_symlet', 'wv_import_data',
214 'wv_fn_symlet', 'wv_import_data',
215 'wv_import_wavelet', 'wv_plot3d_wps', 'wv_plot_multires',
215 'wv_import_wavelet', 'wv_plot3d_wps', 'wv_plot_multires',
216 'wv_pwt', 'wv_tool_denoise',
216 'wv_pwt', 'wv_tool_denoise',
217 'xbm_edit', 'xdisplayfile', 'xdxf', 'xfont', 'xinteranimate',
217 'xbm_edit', 'xdisplayfile', 'xdxf', 'xfont', 'xinteranimate',
218 'xloadct', 'xmanager', 'xmng_tmpl', 'xmtool', 'xobjview',
218 'xloadct', 'xmanager', 'xmng_tmpl', 'xmtool', 'xobjview',
219 'xobjview_rotate', 'xobjview_write_image',
219 'xobjview_rotate', 'xobjview_write_image',
220 'xpalette', 'xpcolor', 'xplot3d',
220 'xpalette', 'xpcolor', 'xplot3d',
221 'xregistered', 'xroi', 'xsq_test', 'xsurface', 'xvaredit',
221 'xregistered', 'xroi', 'xsq_test', 'xsurface', 'xvaredit',
222 'xvolume', 'xvolume_rotate', 'xvolume_write_image',
222 'xvolume', 'xvolume_rotate', 'xvolume_write_image',
223 'xyouts', 'zlib_compress', 'zlib_uncompress', 'zoom', 'zoom_24'
223 'xyouts', 'zlib_compress', 'zlib_uncompress', 'zoom', 'zoom_24'
224 ];
224 ];
225 var builtins = wordRegexp(builtinArray);
225 var builtins = wordRegexp(builtinArray);
226
226
227 var keywordArray = [
227 var keywordArray = [
228 'begin', 'end', 'endcase', 'endfor',
228 'begin', 'end', 'endcase', 'endfor',
229 'endwhile', 'endif', 'endrep', 'endforeach',
229 'endwhile', 'endif', 'endrep', 'endforeach',
230 'break', 'case', 'continue', 'for',
230 'break', 'case', 'continue', 'for',
231 'foreach', 'goto', 'if', 'then', 'else',
231 'foreach', 'goto', 'if', 'then', 'else',
232 'repeat', 'until', 'switch', 'while',
232 'repeat', 'until', 'switch', 'while',
233 'do', 'pro', 'function'
233 'do', 'pro', 'function'
234 ];
234 ];
235 var keywords = wordRegexp(keywordArray);
235 var keywords = wordRegexp(keywordArray);
236
236
237 CodeMirror.registerHelper("hintWords", "idl", builtinArray.concat(keywordArray));
237 CodeMirror.registerHelper("hintWords", "idl", builtinArray.concat(keywordArray));
238
238
239 var identifiers = new RegExp('^[_a-z\xa1-\uffff][_a-z0-9\xa1-\uffff]*', 'i');
239 var identifiers = new RegExp('^[_a-z\xa1-\uffff][_a-z0-9\xa1-\uffff]*', 'i');
240
240
241 var singleOperators = /[+\-*&=<>\/@#~$]/;
241 var singleOperators = /[+\-*&=<>\/@#~$]/;
242 var boolOperators = new RegExp('(and|or|eq|lt|le|gt|ge|ne|not)', 'i');
242 var boolOperators = new RegExp('(and|or|eq|lt|le|gt|ge|ne|not)', 'i');
243
243
244 function tokenBase(stream) {
244 function tokenBase(stream) {
245 // whitespaces
245 // whitespaces
246 if (stream.eatSpace()) return null;
246 if (stream.eatSpace()) return null;
247
247
248 // Handle one line Comments
248 // Handle one line Comments
249 if (stream.match(';')) {
249 if (stream.match(';')) {
250 stream.skipToEnd();
250 stream.skipToEnd();
251 return 'comment';
251 return 'comment';
252 }
252 }
253
253
254 // Handle Number Literals
254 // Handle Number Literals
255 if (stream.match(/^[0-9\.+-]/, false)) {
255 if (stream.match(/^[0-9\.+-]/, false)) {
256 if (stream.match(/^[+-]?0x[0-9a-fA-F]+/))
256 if (stream.match(/^[+-]?0x[0-9a-fA-F]+/))
257 return 'number';
257 return 'number';
258 if (stream.match(/^[+-]?\d*\.\d+([EeDd][+-]?\d+)?/))
258 if (stream.match(/^[+-]?\d*\.\d+([EeDd][+-]?\d+)?/))
259 return 'number';
259 return 'number';
260 if (stream.match(/^[+-]?\d+([EeDd][+-]?\d+)?/))
260 if (stream.match(/^[+-]?\d+([EeDd][+-]?\d+)?/))
261 return 'number';
261 return 'number';
262 }
262 }
263
263
264 // Handle Strings
264 // Handle Strings
265 if (stream.match(/^"([^"]|(""))*"/)) { return 'string'; }
265 if (stream.match(/^"([^"]|(""))*"/)) { return 'string'; }
266 if (stream.match(/^'([^']|(''))*'/)) { return 'string'; }
266 if (stream.match(/^'([^']|(''))*'/)) { return 'string'; }
267
267
268 // Handle words
268 // Handle words
269 if (stream.match(keywords)) { return 'keyword'; }
269 if (stream.match(keywords)) { return 'keyword'; }
270 if (stream.match(builtins)) { return 'builtin'; }
270 if (stream.match(builtins)) { return 'builtin'; }
271 if (stream.match(identifiers)) { return 'variable'; }
271 if (stream.match(identifiers)) { return 'variable'; }
272
272
273 if (stream.match(singleOperators) || stream.match(boolOperators)) {
273 if (stream.match(singleOperators) || stream.match(boolOperators)) {
274 return 'operator'; }
274 return 'operator'; }
275
275
276 // Handle non-detected items
276 // Handle non-detected items
277 stream.next();
277 stream.next();
278 return null;
278 return null;
279 };
279 };
280
280
281 CodeMirror.defineMode('idl', function() {
281 CodeMirror.defineMode('idl', function() {
282 return {
282 return {
283 token: function(stream) {
283 token: function(stream) {
284 return tokenBase(stream);
284 return tokenBase(stream);
285 }
285 }
286 };
286 };
287 });
287 });
288
288
289 CodeMirror.defineMIME('text/x-idl', 'idl');
289 CodeMirror.defineMIME('text/x-idl', 'idl');
290 });
290 });
This diff has been collapsed as it changes many lines, (520 lines changed) Show them Hide them
@@ -1,742 +1,930 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
4 // TODO actually recognize syntax of TypeScript constructs
5
3
6 (function(mod) {
4 (function(mod) {
7 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
8 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
9 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
10 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
11 else // Plain browser env
9 else // Plain browser env
12 mod(CodeMirror);
10 mod(CodeMirror);
13 })(function(CodeMirror) {
11 })(function(CodeMirror) {
14 "use strict";
12 "use strict";
15
13
16 function expressionAllowed(stream, state, backUp) {
17 return /^(?:operator|sof|keyword c|case|new|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
18 (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
19 }
20
21 CodeMirror.defineMode("javascript", function(config, parserConfig) {
14 CodeMirror.defineMode("javascript", function(config, parserConfig) {
22 var indentUnit = config.indentUnit;
15 var indentUnit = config.indentUnit;
23 var statementIndent = parserConfig.statementIndent;
16 var statementIndent = parserConfig.statementIndent;
24 var jsonldMode = parserConfig.jsonld;
17 var jsonldMode = parserConfig.jsonld;
25 var jsonMode = parserConfig.json || jsonldMode;
18 var jsonMode = parserConfig.json || jsonldMode;
26 var isTS = parserConfig.typescript;
19 var isTS = parserConfig.typescript;
27 var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
20 var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
28
21
29 // Tokenizer
22 // Tokenizer
30
23
31 var keywords = function(){
24 var keywords = function(){
32 function kw(type) {return {type: type, style: "keyword"};}
25 function kw(type) {return {type: type, style: "keyword"};}
33 var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
26 var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"), D = kw("keyword d");
34 var operator = kw("operator"), atom = {type: "atom", style: "atom"};
27 var operator = kw("operator"), atom = {type: "atom", style: "atom"};
35
28
36 var jsKeywords = {
29 return {
37 "if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
30 "if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
38 "return": C, "break": C, "continue": C, "new": kw("new"), "delete": C, "throw": C, "debugger": C,
31 "return": D, "break": D, "continue": D, "new": kw("new"), "delete": C, "void": C, "throw": C,
39 "var": kw("var"), "const": kw("var"), "let": kw("var"),
32 "debugger": kw("debugger"), "var": kw("var"), "const": kw("var"), "let": kw("var"),
40 "function": kw("function"), "catch": kw("catch"),
33 "function": kw("function"), "catch": kw("catch"),
41 "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
34 "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
42 "in": operator, "typeof": operator, "instanceof": operator,
35 "in": operator, "typeof": operator, "instanceof": operator,
43 "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
36 "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
44 "this": kw("this"), "class": kw("class"), "super": kw("atom"),
37 "this": kw("this"), "class": kw("class"), "super": kw("atom"),
45 "yield": C, "export": kw("export"), "import": kw("import"), "extends": C
38 "yield": C, "export": kw("export"), "import": kw("import"), "extends": C,
39 "await": C
46 };
40 };
47
48 // Extend the 'normal' keywords with the TypeScript language extensions
49 if (isTS) {
50 var type = {type: "variable", style: "variable-3"};
51 var tsKeywords = {
52 // object-like things
53 "interface": kw("class"),
54 "implements": C,
55 "namespace": C,
56 "module": kw("module"),
57 "enum": kw("module"),
58
59 // scope modifiers
60 "public": kw("modifier"),
61 "private": kw("modifier"),
62 "protected": kw("modifier"),
63 "abstract": kw("modifier"),
64
65 // operators
66 "as": operator,
67
68 // types
69 "string": type, "number": type, "boolean": type, "any": type
70 };
71
72 for (var attr in tsKeywords) {
73 jsKeywords[attr] = tsKeywords[attr];
74 }
75 }
76
77 return jsKeywords;
78 }();
41 }();
79
42
80 var isOperatorChar = /[+\-*&%=<>!?|~^]/;
43 var isOperatorChar = /[+\-*&%=<>!?|~^@]/;
81 var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
44 var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
82
45
83 function readRegexp(stream) {
46 function readRegexp(stream) {
84 var escaped = false, next, inSet = false;
47 var escaped = false, next, inSet = false;
85 while ((next = stream.next()) != null) {
48 while ((next = stream.next()) != null) {
86 if (!escaped) {
49 if (!escaped) {
87 if (next == "/" && !inSet) return;
50 if (next == "/" && !inSet) return;
88 if (next == "[") inSet = true;
51 if (next == "[") inSet = true;
89 else if (inSet && next == "]") inSet = false;
52 else if (inSet && next == "]") inSet = false;
90 }
53 }
91 escaped = !escaped && next == "\\";
54 escaped = !escaped && next == "\\";
92 }
55 }
93 }
56 }
94
57
95 // Used as scratch variables to communicate multiple values without
58 // Used as scratch variables to communicate multiple values without
96 // consing up tons of objects.
59 // consing up tons of objects.
97 var type, content;
60 var type, content;
98 function ret(tp, style, cont) {
61 function ret(tp, style, cont) {
99 type = tp; content = cont;
62 type = tp; content = cont;
100 return style;
63 return style;
101 }
64 }
102 function tokenBase(stream, state) {
65 function tokenBase(stream, state) {
103 var ch = stream.next();
66 var ch = stream.next();
104 if (ch == '"' || ch == "'") {
67 if (ch == '"' || ch == "'") {
105 state.tokenize = tokenString(ch);
68 state.tokenize = tokenString(ch);
106 return state.tokenize(stream, state);
69 return state.tokenize(stream, state);
107 } else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) {
70 } else if (ch == "." && stream.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/)) {
108 return ret("number", "number");
71 return ret("number", "number");
109 } else if (ch == "." && stream.match("..")) {
72 } else if (ch == "." && stream.match("..")) {
110 return ret("spread", "meta");
73 return ret("spread", "meta");
111 } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
74 } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
112 return ret(ch);
75 return ret(ch);
113 } else if (ch == "=" && stream.eat(">")) {
76 } else if (ch == "=" && stream.eat(">")) {
114 return ret("=>", "operator");
77 return ret("=>", "operator");
115 } else if (ch == "0" && stream.eat(/x/i)) {
78 } else if (ch == "0" && stream.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/)) {
116 stream.eatWhile(/[\da-f]/i);
117 return ret("number", "number");
118 } else if (ch == "0" && stream.eat(/o/i)) {
119 stream.eatWhile(/[0-7]/i);
120 return ret("number", "number");
121 } else if (ch == "0" && stream.eat(/b/i)) {
122 stream.eatWhile(/[01]/i);
123 return ret("number", "number");
79 return ret("number", "number");
124 } else if (/\d/.test(ch)) {
80 } else if (/\d/.test(ch)) {
125 stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
81 stream.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/);
126 return ret("number", "number");
82 return ret("number", "number");
127 } else if (ch == "/") {
83 } else if (ch == "/") {
128 if (stream.eat("*")) {
84 if (stream.eat("*")) {
129 state.tokenize = tokenComment;
85 state.tokenize = tokenComment;
130 return tokenComment(stream, state);
86 return tokenComment(stream, state);
131 } else if (stream.eat("/")) {
87 } else if (stream.eat("/")) {
132 stream.skipToEnd();
88 stream.skipToEnd();
133 return ret("comment", "comment");
89 return ret("comment", "comment");
134 } else if (expressionAllowed(stream, state, 1)) {
90 } else if (expressionAllowed(stream, state, 1)) {
135 readRegexp(stream);
91 readRegexp(stream);
136 stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/);
92 stream.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/);
137 return ret("regexp", "string-2");
93 return ret("regexp", "string-2");
138 } else {
94 } else {
139 stream.eatWhile(isOperatorChar);
95 stream.eat("=");
140 return ret("operator", "operator", stream.current());
96 return ret("operator", "operator", stream.current());
141 }
97 }
142 } else if (ch == "`") {
98 } else if (ch == "`") {
143 state.tokenize = tokenQuasi;
99 state.tokenize = tokenQuasi;
144 return tokenQuasi(stream, state);
100 return tokenQuasi(stream, state);
145 } else if (ch == "#") {
101 } else if (ch == "#") {
146 stream.skipToEnd();
102 stream.skipToEnd();
147 return ret("error", "error");
103 return ret("error", "error");
104 } else if (ch == "<" && stream.match("!--") || ch == "-" && stream.match("->")) {
105 stream.skipToEnd()
106 return ret("comment", "comment")
148 } else if (isOperatorChar.test(ch)) {
107 } else if (isOperatorChar.test(ch)) {
149 stream.eatWhile(isOperatorChar);
108 if (ch != ">" || !state.lexical || state.lexical.type != ">") {
109 if (stream.eat("=")) {
110 if (ch == "!" || ch == "=") stream.eat("=")
111 } else if (/[<>*+\-]/.test(ch)) {
112 stream.eat(ch)
113 if (ch == ">") stream.eat(ch)
114 }
115 }
150 return ret("operator", "operator", stream.current());
116 return ret("operator", "operator", stream.current());
151 } else if (wordRE.test(ch)) {
117 } else if (wordRE.test(ch)) {
152 stream.eatWhile(wordRE);
118 stream.eatWhile(wordRE);
153 var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
119 var word = stream.current()
154 return (known && state.lastType != ".") ? ret(known.type, known.style, word) :
120 if (state.lastType != ".") {
155 ret("variable", "variable", word);
121 if (keywords.propertyIsEnumerable(word)) {
122 var kw = keywords[word]
123 return ret(kw.type, kw.style, word)
124 }
125 if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false))
126 return ret("async", "keyword", word)
127 }
128 return ret("variable", "variable", word)
156 }
129 }
157 }
130 }
158
131
159 function tokenString(quote) {
132 function tokenString(quote) {
160 return function(stream, state) {
133 return function(stream, state) {
161 var escaped = false, next;
134 var escaped = false, next;
162 if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){
135 if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){
163 state.tokenize = tokenBase;
136 state.tokenize = tokenBase;
164 return ret("jsonld-keyword", "meta");
137 return ret("jsonld-keyword", "meta");
165 }
138 }
166 while ((next = stream.next()) != null) {
139 while ((next = stream.next()) != null) {
167 if (next == quote && !escaped) break;
140 if (next == quote && !escaped) break;
168 escaped = !escaped && next == "\\";
141 escaped = !escaped && next == "\\";
169 }
142 }
170 if (!escaped) state.tokenize = tokenBase;
143 if (!escaped) state.tokenize = tokenBase;
171 return ret("string", "string");
144 return ret("string", "string");
172 };
145 };
173 }
146 }
174
147
175 function tokenComment(stream, state) {
148 function tokenComment(stream, state) {
176 var maybeEnd = false, ch;
149 var maybeEnd = false, ch;
177 while (ch = stream.next()) {
150 while (ch = stream.next()) {
178 if (ch == "/" && maybeEnd) {
151 if (ch == "/" && maybeEnd) {
179 state.tokenize = tokenBase;
152 state.tokenize = tokenBase;
180 break;
153 break;
181 }
154 }
182 maybeEnd = (ch == "*");
155 maybeEnd = (ch == "*");
183 }
156 }
184 return ret("comment", "comment");
157 return ret("comment", "comment");
185 }
158 }
186
159
187 function tokenQuasi(stream, state) {
160 function tokenQuasi(stream, state) {
188 var escaped = false, next;
161 var escaped = false, next;
189 while ((next = stream.next()) != null) {
162 while ((next = stream.next()) != null) {
190 if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) {
163 if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) {
191 state.tokenize = tokenBase;
164 state.tokenize = tokenBase;
192 break;
165 break;
193 }
166 }
194 escaped = !escaped && next == "\\";
167 escaped = !escaped && next == "\\";
195 }
168 }
196 return ret("quasi", "string-2", stream.current());
169 return ret("quasi", "string-2", stream.current());
197 }
170 }
198
171
199 var brackets = "([{}])";
172 var brackets = "([{}])";
200 // This is a crude lookahead trick to try and notice that we're
173 // This is a crude lookahead trick to try and notice that we're
201 // parsing the argument patterns for a fat-arrow function before we
174 // parsing the argument patterns for a fat-arrow function before we
202 // actually hit the arrow token. It only works if the arrow is on
175 // actually hit the arrow token. It only works if the arrow is on
203 // the same line as the arguments and there's no strange noise
176 // the same line as the arguments and there's no strange noise
204 // (comments) in between. Fallback is to only notice when we hit the
177 // (comments) in between. Fallback is to only notice when we hit the
205 // arrow, and not declare the arguments as locals for the arrow
178 // arrow, and not declare the arguments as locals for the arrow
206 // body.
179 // body.
207 function findFatArrow(stream, state) {
180 function findFatArrow(stream, state) {
208 if (state.fatArrowAt) state.fatArrowAt = null;
181 if (state.fatArrowAt) state.fatArrowAt = null;
209 var arrow = stream.string.indexOf("=>", stream.start);
182 var arrow = stream.string.indexOf("=>", stream.start);
210 if (arrow < 0) return;
183 if (arrow < 0) return;
211
184
185 if (isTS) { // Try to skip TypeScript return type declarations after the arguments
186 var m = /:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(stream.string.slice(stream.start, arrow))
187 if (m) arrow = m.index
188 }
189
212 var depth = 0, sawSomething = false;
190 var depth = 0, sawSomething = false;
213 for (var pos = arrow - 1; pos >= 0; --pos) {
191 for (var pos = arrow - 1; pos >= 0; --pos) {
214 var ch = stream.string.charAt(pos);
192 var ch = stream.string.charAt(pos);
215 var bracket = brackets.indexOf(ch);
193 var bracket = brackets.indexOf(ch);
216 if (bracket >= 0 && bracket < 3) {
194 if (bracket >= 0 && bracket < 3) {
217 if (!depth) { ++pos; break; }
195 if (!depth) { ++pos; break; }
218 if (--depth == 0) break;
196 if (--depth == 0) { if (ch == "(") sawSomething = true; break; }
219 } else if (bracket >= 3 && bracket < 6) {
197 } else if (bracket >= 3 && bracket < 6) {
220 ++depth;
198 ++depth;
221 } else if (wordRE.test(ch)) {
199 } else if (wordRE.test(ch)) {
222 sawSomething = true;
200 sawSomething = true;
223 } else if (/["'\/]/.test(ch)) {
201 } else if (/["'\/`]/.test(ch)) {
224 return;
202 for (;; --pos) {
203 if (pos == 0) return
204 var next = stream.string.charAt(pos - 1)
205 if (next == ch && stream.string.charAt(pos - 2) != "\\") { pos--; break }
206 }
225 } else if (sawSomething && !depth) {
207 } else if (sawSomething && !depth) {
226 ++pos;
208 ++pos;
227 break;
209 break;
228 }
210 }
229 }
211 }
230 if (sawSomething && !depth) state.fatArrowAt = pos;
212 if (sawSomething && !depth) state.fatArrowAt = pos;
231 }
213 }
232
214
233 // Parser
215 // Parser
234
216
235 var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true};
217 var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true};
236
218
237 function JSLexical(indented, column, type, align, prev, info) {
219 function JSLexical(indented, column, type, align, prev, info) {
238 this.indented = indented;
220 this.indented = indented;
239 this.column = column;
221 this.column = column;
240 this.type = type;
222 this.type = type;
241 this.prev = prev;
223 this.prev = prev;
242 this.info = info;
224 this.info = info;
243 if (align != null) this.align = align;
225 if (align != null) this.align = align;
244 }
226 }
245
227
246 function inScope(state, varname) {
228 function inScope(state, varname) {
247 for (var v = state.localVars; v; v = v.next)
229 for (var v = state.localVars; v; v = v.next)
248 if (v.name == varname) return true;
230 if (v.name == varname) return true;
249 for (var cx = state.context; cx; cx = cx.prev) {
231 for (var cx = state.context; cx; cx = cx.prev) {
250 for (var v = cx.vars; v; v = v.next)
232 for (var v = cx.vars; v; v = v.next)
251 if (v.name == varname) return true;
233 if (v.name == varname) return true;
252 }
234 }
253 }
235 }
254
236
255 function parseJS(state, style, type, content, stream) {
237 function parseJS(state, style, type, content, stream) {
256 var cc = state.cc;
238 var cc = state.cc;
257 // Communicate our context to the combinators.
239 // Communicate our context to the combinators.
258 // (Less wasteful than consing up a hundred closures on every call.)
240 // (Less wasteful than consing up a hundred closures on every call.)
259 cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; cx.style = style;
241 cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; cx.style = style;
260
242
261 if (!state.lexical.hasOwnProperty("align"))
243 if (!state.lexical.hasOwnProperty("align"))
262 state.lexical.align = true;
244 state.lexical.align = true;
263
245
264 while(true) {
246 while(true) {
265 var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
247 var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
266 if (combinator(type, content)) {
248 if (combinator(type, content)) {
267 while(cc.length && cc[cc.length - 1].lex)
249 while(cc.length && cc[cc.length - 1].lex)
268 cc.pop()();
250 cc.pop()();
269 if (cx.marked) return cx.marked;
251 if (cx.marked) return cx.marked;
270 if (type == "variable" && inScope(state, content)) return "variable-2";
252 if (type == "variable" && inScope(state, content)) return "variable-2";
271 return style;
253 return style;
272 }
254 }
273 }
255 }
274 }
256 }
275
257
276 // Combinator utils
258 // Combinator utils
277
259
278 var cx = {state: null, column: null, marked: null, cc: null};
260 var cx = {state: null, column: null, marked: null, cc: null};
279 function pass() {
261 function pass() {
280 for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
262 for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
281 }
263 }
282 function cont() {
264 function cont() {
283 pass.apply(null, arguments);
265 pass.apply(null, arguments);
284 return true;
266 return true;
285 }
267 }
286 function register(varname) {
268 function inList(name, list) {
287 function inList(list) {
269 for (var v = list; v; v = v.next) if (v.name == name) return true
288 for (var v = list; v; v = v.next)
289 if (v.name == varname) return true;
290 return false;
270 return false;
291 }
271 }
272 function register(varname) {
292 var state = cx.state;
273 var state = cx.state;
293 cx.marked = "def";
274 cx.marked = "def";
294 if (state.context) {
275 if (state.context) {
295 if (inList(state.localVars)) return;
276 if (state.lexical.info == "var" && state.context && state.context.block) {
296 state.localVars = {name: varname, next: state.localVars};
277 // FIXME function decls are also not block scoped
278 var newContext = registerVarScoped(varname, state.context)
279 if (newContext != null) {
280 state.context = newContext
281 return
282 }
283 } else if (!inList(varname, state.localVars)) {
284 state.localVars = new Var(varname, state.localVars)
285 return
286 }
287 }
288 // Fall through means this is global
289 if (parserConfig.globalVars && !inList(varname, state.globalVars))
290 state.globalVars = new Var(varname, state.globalVars)
291 }
292 function registerVarScoped(varname, context) {
293 if (!context) {
294 return null
295 } else if (context.block) {
296 var inner = registerVarScoped(varname, context.prev)
297 if (!inner) return null
298 if (inner == context.prev) return context
299 return new Context(inner, context.vars, true)
300 } else if (inList(varname, context.vars)) {
301 return context
297 } else {
302 } else {
298 if (inList(state.globalVars)) return;
303 return new Context(context.prev, new Var(varname, context.vars), false)
299 if (parserConfig.globalVars)
304 }
300 state.globalVars = {name: varname, next: state.globalVars};
301 }
305 }
306
307 function isModifier(name) {
308 return name == "public" || name == "private" || name == "protected" || name == "abstract" || name == "readonly"
302 }
309 }
303
310
304 // Combinators
311 // Combinators
305
312
306 var defaultVars = {name: "this", next: {name: "arguments"}};
313 function Context(prev, vars, block) { this.prev = prev; this.vars = vars; this.block = block }
314 function Var(name, next) { this.name = name; this.next = next }
315
316 var defaultVars = new Var("this", new Var("arguments", null))
307 function pushcontext() {
317 function pushcontext() {
308 cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
318 cx.state.context = new Context(cx.state.context, cx.state.localVars, false)
309 cx.state.localVars = defaultVars;
319 cx.state.localVars = defaultVars
320 }
321 function pushblockcontext() {
322 cx.state.context = new Context(cx.state.context, cx.state.localVars, true)
323 cx.state.localVars = null
310 }
324 }
311 function popcontext() {
325 function popcontext() {
312 cx.state.localVars = cx.state.context.vars;
326 cx.state.localVars = cx.state.context.vars
313 cx.state.context = cx.state.context.prev;
327 cx.state.context = cx.state.context.prev
314 }
328 }
329 popcontext.lex = true
315 function pushlex(type, info) {
330 function pushlex(type, info) {
316 var result = function() {
331 var result = function() {
317 var state = cx.state, indent = state.indented;
332 var state = cx.state, indent = state.indented;
318 if (state.lexical.type == "stat") indent = state.lexical.indented;
333 if (state.lexical.type == "stat") indent = state.lexical.indented;
319 else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev)
334 else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev)
320 indent = outer.indented;
335 indent = outer.indented;
321 state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
336 state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
322 };
337 };
323 result.lex = true;
338 result.lex = true;
324 return result;
339 return result;
325 }
340 }
326 function poplex() {
341 function poplex() {
327 var state = cx.state;
342 var state = cx.state;
328 if (state.lexical.prev) {
343 if (state.lexical.prev) {
329 if (state.lexical.type == ")")
344 if (state.lexical.type == ")")
330 state.indented = state.lexical.indented;
345 state.indented = state.lexical.indented;
331 state.lexical = state.lexical.prev;
346 state.lexical = state.lexical.prev;
332 }
347 }
333 }
348 }
334 poplex.lex = true;
349 poplex.lex = true;
335
350
336 function expect(wanted) {
351 function expect(wanted) {
337 function exp(type) {
352 function exp(type) {
338 if (type == wanted) return cont();
353 if (type == wanted) return cont();
339 else if (wanted == ";") return pass();
354 else if (wanted == ";" || type == "}" || type == ")" || type == "]") return pass();
340 else return cont(exp);
355 else return cont(exp);
341 };
356 };
342 return exp;
357 return exp;
343 }
358 }
344
359
345 function statement(type, value) {
360 function statement(type, value) {
346 if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex);
361 if (type == "var") return cont(pushlex("vardef", value), vardef, expect(";"), poplex);
347 if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
362 if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
348 if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
363 if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
349 if (type == "{") return cont(pushlex("}"), block, poplex);
364 if (type == "keyword d") return cx.stream.match(/^\s*$/, false) ? cont() : cont(pushlex("stat"), maybeexpression, expect(";"), poplex);
365 if (type == "debugger") return cont(expect(";"));
366 if (type == "{") return cont(pushlex("}"), pushblockcontext, block, poplex, popcontext);
350 if (type == ";") return cont();
367 if (type == ";") return cont();
351 if (type == "if") {
368 if (type == "if") {
352 if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
369 if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
353 cx.state.cc.pop()();
370 cx.state.cc.pop()();
354 return cont(pushlex("form"), expression, statement, poplex, maybeelse);
371 return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
355 }
372 }
356 if (type == "function") return cont(functiondef);
373 if (type == "function") return cont(functiondef);
357 if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
374 if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
358 if (type == "variable") return cont(pushlex("stat"), maybelabel);
375 if (type == "class" || (isTS && value == "interface")) {
359 if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
376 cx.marked = "keyword"
360 block, poplex, poplex);
377 return cont(pushlex("form", type == "class" ? type : value), className, poplex)
378 }
379 if (type == "variable") {
380 if (isTS && value == "declare") {
381 cx.marked = "keyword"
382 return cont(statement)
383 } else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) {
384 cx.marked = "keyword"
385 if (value == "enum") return cont(enumdef);
386 else if (value == "type") return cont(typename, expect("operator"), typeexpr, expect(";"));
387 else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex)
388 } else if (isTS && value == "namespace") {
389 cx.marked = "keyword"
390 return cont(pushlex("form"), expression, statement, poplex)
391 } else if (isTS && value == "abstract") {
392 cx.marked = "keyword"
393 return cont(statement)
394 } else {
395 return cont(pushlex("stat"), maybelabel);
396 }
397 }
398 if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"), pushblockcontext,
399 block, poplex, poplex, popcontext);
361 if (type == "case") return cont(expression, expect(":"));
400 if (type == "case") return cont(expression, expect(":"));
362 if (type == "default") return cont(expect(":"));
401 if (type == "default") return cont(expect(":"));
363 if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
402 if (type == "catch") return cont(pushlex("form"), pushcontext, maybeCatchBinding, statement, poplex, popcontext);
364 statement, poplex, popcontext);
365 if (type == "class") return cont(pushlex("form"), className, poplex);
366 if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
403 if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
367 if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
404 if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
368 if (type == "module") return cont(pushlex("form"), pattern, pushlex("}"), expect("{"), block, poplex, poplex)
405 if (type == "async") return cont(statement)
406 if (value == "@") return cont(expression, statement)
369 return pass(pushlex("stat"), expression, expect(";"), poplex);
407 return pass(pushlex("stat"), expression, expect(";"), poplex);
370 }
408 }
371 function expression(type) {
409 function maybeCatchBinding(type) {
372 return expressionInner(type, false);
410 if (type == "(") return cont(funarg, expect(")"))
411 }
412 function expression(type, value) {
413 return expressionInner(type, value, false);
373 }
414 }
374 function expressionNoComma(type) {
415 function expressionNoComma(type, value) {
375 return expressionInner(type, true);
416 return expressionInner(type, value, true);
376 }
417 }
377 function expressionInner(type, noComma) {
418 function parenExpr(type) {
419 if (type != "(") return pass()
420 return cont(pushlex(")"), expression, expect(")"), poplex)
421 }
422 function expressionInner(type, value, noComma) {
378 if (cx.state.fatArrowAt == cx.stream.start) {
423 if (cx.state.fatArrowAt == cx.stream.start) {
379 var body = noComma ? arrowBodyNoComma : arrowBody;
424 var body = noComma ? arrowBodyNoComma : arrowBody;
380 if (type == "(") return cont(pushcontext, pushlex(")"), commasep(pattern, ")"), poplex, expect("=>"), body, popcontext);
425 if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, expect("=>"), body, popcontext);
381 else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
426 else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
382 }
427 }
383
428
384 var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
429 var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
385 if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
430 if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
386 if (type == "function") return cont(functiondef, maybeop);
431 if (type == "function") return cont(functiondef, maybeop);
387 if (type == "keyword c") return cont(noComma ? maybeexpressionNoComma : maybeexpression);
432 if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), classExpression, poplex); }
388 if (type == "(") return cont(pushlex(")"), maybeexpression, comprehension, expect(")"), poplex, maybeop);
433 if (type == "keyword c" || type == "async") return cont(noComma ? expressionNoComma : expression);
434 if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
389 if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
435 if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
390 if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
436 if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
391 if (type == "{") return contCommasep(objprop, "}", null, maybeop);
437 if (type == "{") return contCommasep(objprop, "}", null, maybeop);
392 if (type == "quasi") return pass(quasi, maybeop);
438 if (type == "quasi") return pass(quasi, maybeop);
393 if (type == "new") return cont(maybeTarget(noComma));
439 if (type == "new") return cont(maybeTarget(noComma));
440 if (type == "import") return cont(expression);
394 return cont();
441 return cont();
395 }
442 }
396 function maybeexpression(type) {
443 function maybeexpression(type) {
397 if (type.match(/[;\}\)\],]/)) return pass();
444 if (type.match(/[;\}\)\],]/)) return pass();
398 return pass(expression);
445 return pass(expression);
399 }
446 }
400 function maybeexpressionNoComma(type) {
401 if (type.match(/[;\}\)\],]/)) return pass();
402 return pass(expressionNoComma);
403 }
404
447
405 function maybeoperatorComma(type, value) {
448 function maybeoperatorComma(type, value) {
406 if (type == ",") return cont(expression);
449 if (type == ",") return cont(expression);
407 return maybeoperatorNoComma(type, value, false);
450 return maybeoperatorNoComma(type, value, false);
408 }
451 }
409 function maybeoperatorNoComma(type, value, noComma) {
452 function maybeoperatorNoComma(type, value, noComma) {
410 var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
453 var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
411 var expr = noComma == false ? expression : expressionNoComma;
454 var expr = noComma == false ? expression : expressionNoComma;
412 if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
455 if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
413 if (type == "operator") {
456 if (type == "operator") {
414 if (/\+\+|--/.test(value)) return cont(me);
457 if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me);
458 if (isTS && value == "<" && cx.stream.match(/^([^>]|<.*?>)*>\s*\(/, false))
459 return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me);
415 if (value == "?") return cont(expression, expect(":"), expr);
460 if (value == "?") return cont(expression, expect(":"), expr);
416 return cont(expr);
461 return cont(expr);
417 }
462 }
418 if (type == "quasi") { return pass(quasi, me); }
463 if (type == "quasi") { return pass(quasi, me); }
419 if (type == ";") return;
464 if (type == ";") return;
420 if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
465 if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
421 if (type == ".") return cont(property, me);
466 if (type == ".") return cont(property, me);
422 if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
467 if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
468 if (isTS && value == "as") { cx.marked = "keyword"; return cont(typeexpr, me) }
469 if (type == "regexp") {
470 cx.state.lastType = cx.marked = "operator"
471 cx.stream.backUp(cx.stream.pos - cx.stream.start - 1)
472 return cont(expr)
473 }
423 }
474 }
424 function quasi(type, value) {
475 function quasi(type, value) {
425 if (type != "quasi") return pass();
476 if (type != "quasi") return pass();
426 if (value.slice(value.length - 2) != "${") return cont(quasi);
477 if (value.slice(value.length - 2) != "${") return cont(quasi);
427 return cont(expression, continueQuasi);
478 return cont(expression, continueQuasi);
428 }
479 }
429 function continueQuasi(type) {
480 function continueQuasi(type) {
430 if (type == "}") {
481 if (type == "}") {
431 cx.marked = "string-2";
482 cx.marked = "string-2";
432 cx.state.tokenize = tokenQuasi;
483 cx.state.tokenize = tokenQuasi;
433 return cont(quasi);
484 return cont(quasi);
434 }
485 }
435 }
486 }
436 function arrowBody(type) {
487 function arrowBody(type) {
437 findFatArrow(cx.stream, cx.state);
488 findFatArrow(cx.stream, cx.state);
438 return pass(type == "{" ? statement : expression);
489 return pass(type == "{" ? statement : expression);
439 }
490 }
440 function arrowBodyNoComma(type) {
491 function arrowBodyNoComma(type) {
441 findFatArrow(cx.stream, cx.state);
492 findFatArrow(cx.stream, cx.state);
442 return pass(type == "{" ? statement : expressionNoComma);
493 return pass(type == "{" ? statement : expressionNoComma);
443 }
494 }
444 function maybeTarget(noComma) {
495 function maybeTarget(noComma) {
445 return function(type) {
496 return function(type) {
446 if (type == ".") return cont(noComma ? targetNoComma : target);
497 if (type == ".") return cont(noComma ? targetNoComma : target);
498 else if (type == "variable" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma)
447 else return pass(noComma ? expressionNoComma : expression);
499 else return pass(noComma ? expressionNoComma : expression);
448 };
500 };
449 }
501 }
450 function target(_, value) {
502 function target(_, value) {
451 if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorComma); }
503 if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorComma); }
452 }
504 }
453 function targetNoComma(_, value) {
505 function targetNoComma(_, value) {
454 if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorNoComma); }
506 if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorNoComma); }
455 }
507 }
456 function maybelabel(type) {
508 function maybelabel(type) {
457 if (type == ":") return cont(poplex, statement);
509 if (type == ":") return cont(poplex, statement);
458 return pass(maybeoperatorComma, expect(";"), poplex);
510 return pass(maybeoperatorComma, expect(";"), poplex);
459 }
511 }
460 function property(type) {
512 function property(type) {
461 if (type == "variable") {cx.marked = "property"; return cont();}
513 if (type == "variable") {cx.marked = "property"; return cont();}
462 }
514 }
463 function objprop(type, value) {
515 function objprop(type, value) {
464 if (type == "variable" || cx.style == "keyword") {
516 if (type == "async") {
517 cx.marked = "property";
518 return cont(objprop);
519 } else if (type == "variable" || cx.style == "keyword") {
465 cx.marked = "property";
520 cx.marked = "property";
466 if (value == "get" || value == "set") return cont(getterSetter);
521 if (value == "get" || value == "set") return cont(getterSetter);
522 var m // Work around fat-arrow-detection complication for detecting typescript typed arrow params
523 if (isTS && cx.state.fatArrowAt == cx.stream.start && (m = cx.stream.match(/^\s*:\s*/, false)))
524 cx.state.fatArrowAt = cx.stream.pos + m[0].length
467 return cont(afterprop);
525 return cont(afterprop);
468 } else if (type == "number" || type == "string") {
526 } else if (type == "number" || type == "string") {
469 cx.marked = jsonldMode ? "property" : (cx.style + " property");
527 cx.marked = jsonldMode ? "property" : (cx.style + " property");
470 return cont(afterprop);
528 return cont(afterprop);
471 } else if (type == "jsonld-keyword") {
529 } else if (type == "jsonld-keyword") {
472 return cont(afterprop);
530 return cont(afterprop);
473 } else if (type == "modifier") {
531 } else if (isTS && isModifier(value)) {
532 cx.marked = "keyword"
474 return cont(objprop)
533 return cont(objprop)
475 } else if (type == "[") {
534 } else if (type == "[") {
476 return cont(expression, expect("]"), afterprop);
535 return cont(expression, maybetype, expect("]"), afterprop);
477 } else if (type == "spread") {
536 } else if (type == "spread") {
478 return cont(expression);
537 return cont(expressionNoComma, afterprop);
538 } else if (value == "*") {
539 cx.marked = "keyword";
540 return cont(objprop);
541 } else if (type == ":") {
542 return pass(afterprop)
479 }
543 }
480 }
544 }
481 function getterSetter(type) {
545 function getterSetter(type) {
482 if (type != "variable") return pass(afterprop);
546 if (type != "variable") return pass(afterprop);
483 cx.marked = "property";
547 cx.marked = "property";
484 return cont(functiondef);
548 return cont(functiondef);
485 }
549 }
486 function afterprop(type) {
550 function afterprop(type) {
487 if (type == ":") return cont(expressionNoComma);
551 if (type == ":") return cont(expressionNoComma);
488 if (type == "(") return pass(functiondef);
552 if (type == "(") return pass(functiondef);
489 }
553 }
490 function commasep(what, end) {
554 function commasep(what, end, sep) {
491 function proceed(type) {
555 function proceed(type, value) {
492 if (type == ",") {
556 if (sep ? sep.indexOf(type) > -1 : type == ",") {
493 var lex = cx.state.lexical;
557 var lex = cx.state.lexical;
494 if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
558 if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
495 return cont(what, proceed);
559 return cont(function(type, value) {
560 if (type == end || value == end) return pass()
561 return pass(what)
562 }, proceed);
496 }
563 }
497 if (type == end) return cont();
564 if (type == end || value == end) return cont();
565 if (sep && sep.indexOf(";") > -1) return pass(what)
498 return cont(expect(end));
566 return cont(expect(end));
499 }
567 }
500 return function(type) {
568 return function(type, value) {
501 if (type == end) return cont();
569 if (type == end || value == end) return cont();
502 return pass(what, proceed);
570 return pass(what, proceed);
503 };
571 };
504 }
572 }
505 function contCommasep(what, end, info) {
573 function contCommasep(what, end, info) {
506 for (var i = 3; i < arguments.length; i++)
574 for (var i = 3; i < arguments.length; i++)
507 cx.cc.push(arguments[i]);
575 cx.cc.push(arguments[i]);
508 return cont(pushlex(end, info), commasep(what, end), poplex);
576 return cont(pushlex(end, info), commasep(what, end), poplex);
509 }
577 }
510 function block(type) {
578 function block(type) {
511 if (type == "}") return cont();
579 if (type == "}") return cont();
512 return pass(statement, block);
580 return pass(statement, block);
513 }
581 }
514 function maybetype(type) {
582 function maybetype(type, value) {
515 if (isTS && type == ":") return cont(typedef);
583 if (isTS) {
584 if (type == ":") return cont(typeexpr);
585 if (value == "?") return cont(maybetype);
586 }
587 }
588 function maybetypeOrIn(type, value) {
589 if (isTS && (type == ":" || value == "in")) return cont(typeexpr)
590 }
591 function mayberettype(type) {
592 if (isTS && type == ":") {
593 if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr)
594 else return cont(typeexpr)
595 }
596 }
597 function isKW(_, value) {
598 if (value == "is") {
599 cx.marked = "keyword"
600 return cont()
601 }
602 }
603 function typeexpr(type, value) {
604 if (value == "keyof" || value == "typeof" || value == "infer") {
605 cx.marked = "keyword"
606 return cont(value == "typeof" ? expressionNoComma : typeexpr)
607 }
608 if (type == "variable" || value == "void") {
609 cx.marked = "type"
610 return cont(afterType)
611 }
612 if (value == "|" || value == "&") return cont(typeexpr)
613 if (type == "string" || type == "number" || type == "atom") return cont(afterType);
614 if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)
615 if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType)
616 if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType)
617 if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr)
516 }
618 }
517 function maybedefault(_, value) {
619 function maybeReturnType(type) {
518 if (value == "=") return cont(expressionNoComma);
620 if (type == "=>") return cont(typeexpr)
621 }
622 function typeprop(type, value) {
623 if (type == "variable" || cx.style == "keyword") {
624 cx.marked = "property"
625 return cont(typeprop)
626 } else if (value == "?" || type == "number" || type == "string") {
627 return cont(typeprop)
628 } else if (type == ":") {
629 return cont(typeexpr)
630 } else if (type == "[") {
631 return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop)
632 } else if (type == "(") {
633 return pass(functiondecl, typeprop)
634 }
519 }
635 }
520 function typedef(type) {
636 function typearg(type, value) {
521 if (type == "variable") {cx.marked = "variable-3"; return cont();}
637 if (type == "variable" && cx.stream.match(/^\s*[?:]/, false) || value == "?") return cont(typearg)
638 if (type == ":") return cont(typeexpr)
639 if (type == "spread") return cont(typearg)
640 return pass(typeexpr)
522 }
641 }
523 function vardef() {
642 function afterType(type, value) {
643 if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
644 if (value == "|" || type == "." || value == "&") return cont(typeexpr)
645 if (type == "[") return cont(typeexpr, expect("]"), afterType)
646 if (value == "extends" || value == "implements") { cx.marked = "keyword"; return cont(typeexpr) }
647 if (value == "?") return cont(typeexpr, expect(":"), typeexpr)
648 }
649 function maybeTypeArgs(_, value) {
650 if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
651 }
652 function typeparam() {
653 return pass(typeexpr, maybeTypeDefault)
654 }
655 function maybeTypeDefault(_, value) {
656 if (value == "=") return cont(typeexpr)
657 }
658 function vardef(_, value) {
659 if (value == "enum") {cx.marked = "keyword"; return cont(enumdef)}
524 return pass(pattern, maybetype, maybeAssign, vardefCont);
660 return pass(pattern, maybetype, maybeAssign, vardefCont);
525 }
661 }
526 function pattern(type, value) {
662 function pattern(type, value) {
527 if (type == "modifier") return cont(pattern)
663 if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(pattern) }
528 if (type == "variable") { register(value); return cont(); }
664 if (type == "variable") { register(value); return cont(); }
529 if (type == "spread") return cont(pattern);
665 if (type == "spread") return cont(pattern);
530 if (type == "[") return contCommasep(pattern, "]");
666 if (type == "[") return contCommasep(eltpattern, "]");
531 if (type == "{") return contCommasep(proppattern, "}");
667 if (type == "{") return contCommasep(proppattern, "}");
532 }
668 }
533 function proppattern(type, value) {
669 function proppattern(type, value) {
534 if (type == "variable" && !cx.stream.match(/^\s*:/, false)) {
670 if (type == "variable" && !cx.stream.match(/^\s*:/, false)) {
535 register(value);
671 register(value);
536 return cont(maybeAssign);
672 return cont(maybeAssign);
537 }
673 }
538 if (type == "variable") cx.marked = "property";
674 if (type == "variable") cx.marked = "property";
539 if (type == "spread") return cont(pattern);
675 if (type == "spread") return cont(pattern);
540 if (type == "}") return pass();
676 if (type == "}") return pass();
677 if (type == "[") return cont(expression, expect(']'), expect(':'), proppattern);
541 return cont(expect(":"), pattern, maybeAssign);
678 return cont(expect(":"), pattern, maybeAssign);
542 }
679 }
680 function eltpattern() {
681 return pass(pattern, maybeAssign)
682 }
543 function maybeAssign(_type, value) {
683 function maybeAssign(_type, value) {
544 if (value == "=") return cont(expressionNoComma);
684 if (value == "=") return cont(expressionNoComma);
545 }
685 }
546 function vardefCont(type) {
686 function vardefCont(type) {
547 if (type == ",") return cont(vardef);
687 if (type == ",") return cont(vardef);
548 }
688 }
549 function maybeelse(type, value) {
689 function maybeelse(type, value) {
550 if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
690 if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
551 }
691 }
552 function forspec(type) {
692 function forspec(type, value) {
553 if (type == "(") return cont(pushlex(")"), forspec1, expect(")"), poplex);
693 if (value == "await") return cont(forspec);
694 if (type == "(") return cont(pushlex(")"), forspec1, poplex);
554 }
695 }
555 function forspec1(type) {
696 function forspec1(type) {
556 if (type == "var") return cont(vardef, expect(";"), forspec2);
697 if (type == "var") return cont(vardef, forspec2);
557 if (type == ";") return cont(forspec2);
698 if (type == "variable") return cont(forspec2);
558 if (type == "variable") return cont(formaybeinof);
699 return pass(forspec2)
559 return pass(expression, expect(";"), forspec2);
560 }
561 function formaybeinof(_type, value) {
562 if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
563 return cont(maybeoperatorComma, forspec2);
564 }
700 }
565 function forspec2(type, value) {
701 function forspec2(type, value) {
566 if (type == ";") return cont(forspec3);
702 if (type == ")") return cont()
567 if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
703 if (type == ";") return cont(forspec2)
568 return pass(expression, expect(";"), forspec3);
704 if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression, forspec2) }
569 }
705 return pass(expression, forspec2)
570 function forspec3(type) {
571 if (type != ")") cont(expression);
572 }
706 }
573 function functiondef(type, value) {
707 function functiondef(type, value) {
574 if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
708 if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
575 if (type == "variable") {register(value); return cont(functiondef);}
709 if (type == "variable") {register(value); return cont(functiondef);}
576 if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, statement, popcontext);
710 if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext);
711 if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef)
712 }
713 function functiondecl(type, value) {
714 if (value == "*") {cx.marked = "keyword"; return cont(functiondecl);}
715 if (type == "variable") {register(value); return cont(functiondecl);}
716 if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, popcontext);
717 if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondecl)
577 }
718 }
578 function funarg(type) {
719 function typename(type, value) {
720 if (type == "keyword" || type == "variable") {
721 cx.marked = "type"
722 return cont(typename)
723 } else if (value == "<") {
724 return cont(pushlex(">"), commasep(typeparam, ">"), poplex)
725 }
726 }
727 function funarg(type, value) {
728 if (value == "@") cont(expression, funarg)
579 if (type == "spread") return cont(funarg);
729 if (type == "spread") return cont(funarg);
580 return pass(pattern, maybetype, maybedefault);
730 if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(funarg); }
731 if (isTS && type == "this") return cont(maybetype, maybeAssign)
732 return pass(pattern, maybetype, maybeAssign);
733 }
734 function classExpression(type, value) {
735 // Class expressions may have an optional name.
736 if (type == "variable") return className(type, value);
737 return classNameAfter(type, value);
581 }
738 }
582 function className(type, value) {
739 function className(type, value) {
583 if (type == "variable") {register(value); return cont(classNameAfter);}
740 if (type == "variable") {register(value); return cont(classNameAfter);}
584 }
741 }
585 function classNameAfter(type, value) {
742 function classNameAfter(type, value) {
586 if (value == "extends") return cont(expression, classNameAfter);
743 if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, classNameAfter)
744 if (value == "extends" || value == "implements" || (isTS && type == ",")) {
745 if (value == "implements") cx.marked = "keyword";
746 return cont(isTS ? typeexpr : expression, classNameAfter);
747 }
587 if (type == "{") return cont(pushlex("}"), classBody, poplex);
748 if (type == "{") return cont(pushlex("}"), classBody, poplex);
588 }
749 }
589 function classBody(type, value) {
750 function classBody(type, value) {
590 if (type == "variable" || cx.style == "keyword") {
751 if (type == "async" ||
591 if (value == "static") {
752 (type == "variable" &&
753 (value == "static" || value == "get" || value == "set" || (isTS && isModifier(value))) &&
754 cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) {
592 cx.marked = "keyword";
755 cx.marked = "keyword";
593 return cont(classBody);
756 return cont(classBody);
594 }
757 }
758 if (type == "variable" || cx.style == "keyword") {
595 cx.marked = "property";
759 cx.marked = "property";
596 if (value == "get" || value == "set") return cont(classGetterSetter, functiondef, classBody);
760 return cont(isTS ? classfield : functiondef, classBody);
597 return cont(functiondef, classBody);
598 }
761 }
762 if (type == "number" || type == "string") return cont(isTS ? classfield : functiondef, classBody);
763 if (type == "[")
764 return cont(expression, maybetype, expect("]"), isTS ? classfield : functiondef, classBody)
599 if (value == "*") {
765 if (value == "*") {
600 cx.marked = "keyword";
766 cx.marked = "keyword";
601 return cont(classBody);
767 return cont(classBody);
602 }
768 }
603 if (type == ";") return cont(classBody);
769 if (isTS && type == "(") return pass(functiondecl, classBody)
770 if (type == ";" || type == ",") return cont(classBody);
604 if (type == "}") return cont();
771 if (type == "}") return cont();
772 if (value == "@") return cont(expression, classBody)
605 }
773 }
606 function classGetterSetter(type) {
774 function classfield(type, value) {
607 if (type != "variable") return pass();
775 if (value == "?") return cont(classfield)
608 cx.marked = "property";
776 if (type == ":") return cont(typeexpr, maybeAssign)
609 return cont();
777 if (value == "=") return cont(expressionNoComma)
778 var context = cx.state.lexical.prev, isInterface = context && context.info == "interface"
779 return pass(isInterface ? functiondecl : functiondef)
610 }
780 }
611 function afterExport(_type, value) {
781 function afterExport(type, value) {
612 if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
782 if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
613 if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
783 if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
784 if (type == "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";"));
614 return pass(statement);
785 return pass(statement);
615 }
786 }
787 function exportField(type, value) {
788 if (value == "as") { cx.marked = "keyword"; return cont(expect("variable")); }
789 if (type == "variable") return pass(expressionNoComma, exportField);
790 }
616 function afterImport(type) {
791 function afterImport(type) {
617 if (type == "string") return cont();
792 if (type == "string") return cont();
618 return pass(importSpec, maybeFrom);
793 if (type == "(") return pass(expression);
794 return pass(importSpec, maybeMoreImports, maybeFrom);
619 }
795 }
620 function importSpec(type, value) {
796 function importSpec(type, value) {
621 if (type == "{") return contCommasep(importSpec, "}");
797 if (type == "{") return contCommasep(importSpec, "}");
622 if (type == "variable") register(value);
798 if (type == "variable") register(value);
623 if (value == "*") cx.marked = "keyword";
799 if (value == "*") cx.marked = "keyword";
624 return cont(maybeAs);
800 return cont(maybeAs);
625 }
801 }
802 function maybeMoreImports(type) {
803 if (type == ",") return cont(importSpec, maybeMoreImports)
804 }
626 function maybeAs(_type, value) {
805 function maybeAs(_type, value) {
627 if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
806 if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
628 }
807 }
629 function maybeFrom(_type, value) {
808 function maybeFrom(_type, value) {
630 if (value == "from") { cx.marked = "keyword"; return cont(expression); }
809 if (value == "from") { cx.marked = "keyword"; return cont(expression); }
631 }
810 }
632 function arrayLiteral(type) {
811 function arrayLiteral(type) {
633 if (type == "]") return cont();
812 if (type == "]") return cont();
634 return pass(expressionNoComma, maybeArrayComprehension);
635 }
636 function maybeArrayComprehension(type) {
637 if (type == "for") return pass(comprehension, expect("]"));
638 if (type == ",") return cont(commasep(maybeexpressionNoComma, "]"));
639 return pass(commasep(expressionNoComma, "]"));
813 return pass(commasep(expressionNoComma, "]"));
640 }
814 }
641 function comprehension(type) {
815 function enumdef() {
642 if (type == "for") return cont(forspec, comprehension);
816 return pass(pushlex("form"), pattern, expect("{"), pushlex("}"), commasep(enummember, "}"), poplex, poplex)
643 if (type == "if") return cont(expression, comprehension);
817 }
818 function enummember() {
819 return pass(pattern, maybeAssign);
644 }
820 }
645
821
646 function isContinuedStatement(state, textAfter) {
822 function isContinuedStatement(state, textAfter) {
647 return state.lastType == "operator" || state.lastType == "," ||
823 return state.lastType == "operator" || state.lastType == "," ||
648 isOperatorChar.test(textAfter.charAt(0)) ||
824 isOperatorChar.test(textAfter.charAt(0)) ||
649 /[,.]/.test(textAfter.charAt(0));
825 /[,.]/.test(textAfter.charAt(0));
650 }
826 }
651
827
828 function expressionAllowed(stream, state, backUp) {
829 return state.tokenize == tokenBase &&
830 /^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
831 (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
832 }
833
652 // Interface
834 // Interface
653
835
654 return {
836 return {
655 startState: function(basecolumn) {
837 startState: function(basecolumn) {
656 var state = {
838 var state = {
657 tokenize: tokenBase,
839 tokenize: tokenBase,
658 lastType: "sof",
840 lastType: "sof",
659 cc: [],
841 cc: [],
660 lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
842 lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
661 localVars: parserConfig.localVars,
843 localVars: parserConfig.localVars,
662 context: parserConfig.localVars && {vars: parserConfig.localVars},
844 context: parserConfig.localVars && new Context(null, null, false),
663 indented: basecolumn || 0
845 indented: basecolumn || 0
664 };
846 };
665 if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
847 if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
666 state.globalVars = parserConfig.globalVars;
848 state.globalVars = parserConfig.globalVars;
667 return state;
849 return state;
668 },
850 },
669
851
670 token: function(stream, state) {
852 token: function(stream, state) {
671 if (stream.sol()) {
853 if (stream.sol()) {
672 if (!state.lexical.hasOwnProperty("align"))
854 if (!state.lexical.hasOwnProperty("align"))
673 state.lexical.align = false;
855 state.lexical.align = false;
674 state.indented = stream.indentation();
856 state.indented = stream.indentation();
675 findFatArrow(stream, state);
857 findFatArrow(stream, state);
676 }
858 }
677 if (state.tokenize != tokenComment && stream.eatSpace()) return null;
859 if (state.tokenize != tokenComment && stream.eatSpace()) return null;
678 var style = state.tokenize(stream, state);
860 var style = state.tokenize(stream, state);
679 if (type == "comment") return style;
861 if (type == "comment") return style;
680 state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
862 state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
681 return parseJS(state, style, type, content, stream);
863 return parseJS(state, style, type, content, stream);
682 },
864 },
683
865
684 indent: function(state, textAfter) {
866 indent: function(state, textAfter) {
685 if (state.tokenize == tokenComment) return CodeMirror.Pass;
867 if (state.tokenize == tokenComment) return CodeMirror.Pass;
686 if (state.tokenize != tokenBase) return 0;
868 if (state.tokenize != tokenBase) return 0;
687 var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
869 var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top
688 // Kludge to prevent 'maybelse' from blocking lexical scope pops
870 // Kludge to prevent 'maybelse' from blocking lexical scope pops
689 if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
871 if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
690 var c = state.cc[i];
872 var c = state.cc[i];
691 if (c == poplex) lexical = lexical.prev;
873 if (c == poplex) lexical = lexical.prev;
692 else if (c != maybeelse) break;
874 else if (c != maybeelse) break;
693 }
875 }
694 if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
876 while ((lexical.type == "stat" || lexical.type == "form") &&
877 (firstChar == "}" || ((top = state.cc[state.cc.length - 1]) &&
878 (top == maybeoperatorComma || top == maybeoperatorNoComma) &&
879 !/^[,\.=+\-*:?[\(]/.test(textAfter))))
880 lexical = lexical.prev;
695 if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
881 if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
696 lexical = lexical.prev;
882 lexical = lexical.prev;
697 var type = lexical.type, closing = firstChar == type;
883 var type = lexical.type, closing = firstChar == type;
698
884
699 if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info + 1 : 0);
885 if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info.length + 1 : 0);
700 else if (type == "form" && firstChar == "{") return lexical.indented;
886 else if (type == "form" && firstChar == "{") return lexical.indented;
701 else if (type == "form") return lexical.indented + indentUnit;
887 else if (type == "form") return lexical.indented + indentUnit;
702 else if (type == "stat")
888 else if (type == "stat")
703 return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0);
889 return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0);
704 else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
890 else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
705 return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
891 return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
706 else if (lexical.align) return lexical.column + (closing ? 0 : 1);
892 else if (lexical.align) return lexical.column + (closing ? 0 : 1);
707 else return lexical.indented + (closing ? 0 : indentUnit);
893 else return lexical.indented + (closing ? 0 : indentUnit);
708 },
894 },
709
895
710 electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
896 electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
711 blockCommentStart: jsonMode ? null : "/*",
897 blockCommentStart: jsonMode ? null : "/*",
712 blockCommentEnd: jsonMode ? null : "*/",
898 blockCommentEnd: jsonMode ? null : "*/",
899 blockCommentContinue: jsonMode ? null : " * ",
713 lineComment: jsonMode ? null : "//",
900 lineComment: jsonMode ? null : "//",
714 fold: "brace",
901 fold: "brace",
715 closeBrackets: "()[]{}''\"\"``",
902 closeBrackets: "()[]{}''\"\"``",
716
903
717 helperType: jsonMode ? "json" : "javascript",
904 helperType: jsonMode ? "json" : "javascript",
718 jsonldMode: jsonldMode,
905 jsonldMode: jsonldMode,
719 jsonMode: jsonMode,
906 jsonMode: jsonMode,
720
907
721 expressionAllowed: expressionAllowed,
908 expressionAllowed: expressionAllowed,
909
722 skipExpression: function(state) {
910 skipExpression: function(state) {
723 var top = state.cc[state.cc.length - 1]
911 var top = state.cc[state.cc.length - 1]
724 if (top == expression || top == expressionNoComma) state.cc.pop()
912 if (top == expression || top == expressionNoComma) state.cc.pop()
725 }
913 }
726 };
914 };
727 });
915 });
728
916
729 CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);
917 CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);
730
918
731 CodeMirror.defineMIME("text/javascript", "javascript");
919 CodeMirror.defineMIME("text/javascript", "javascript");
732 CodeMirror.defineMIME("text/ecmascript", "javascript");
920 CodeMirror.defineMIME("text/ecmascript", "javascript");
733 CodeMirror.defineMIME("application/javascript", "javascript");
921 CodeMirror.defineMIME("application/javascript", "javascript");
734 CodeMirror.defineMIME("application/x-javascript", "javascript");
922 CodeMirror.defineMIME("application/x-javascript", "javascript");
735 CodeMirror.defineMIME("application/ecmascript", "javascript");
923 CodeMirror.defineMIME("application/ecmascript", "javascript");
736 CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
924 CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
737 CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
925 CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
738 CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true});
926 CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true});
739 CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
927 CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
740 CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
928 CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
741
929
742 });
930 });
@@ -1,142 +1,146 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror);
10 mod(CodeMirror);
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict";
12 "use strict";
13
13
14 CodeMirror.defineMode("jinja2", function() {
14 CodeMirror.defineMode("jinja2", function() {
15 var keywords = ["and", "as", "block", "endblock", "by", "cycle", "debug", "else", "elif",
15 var keywords = ["and", "as", "block", "endblock", "by", "cycle", "debug", "else", "elif",
16 "extends", "filter", "endfilter", "firstof", "for",
16 "extends", "filter", "endfilter", "firstof", "for",
17 "endfor", "if", "endif", "ifchanged", "endifchanged",
17 "endfor", "if", "endif", "ifchanged", "endifchanged",
18 "ifequal", "endifequal", "ifnotequal",
18 "ifequal", "endifequal", "ifnotequal",
19 "endifnotequal", "in", "include", "load", "not", "now", "or",
19 "endifnotequal", "in", "include", "load", "not", "now", "or",
20 "parsed", "regroup", "reversed", "spaceless",
20 "parsed", "regroup", "reversed", "spaceless",
21 "endspaceless", "ssi", "templatetag", "openblock",
21 "endspaceless", "ssi", "templatetag", "openblock",
22 "closeblock", "openvariable", "closevariable",
22 "closeblock", "openvariable", "closevariable",
23 "openbrace", "closebrace", "opencomment",
23 "openbrace", "closebrace", "opencomment",
24 "closecomment", "widthratio", "url", "with", "endwith",
24 "closecomment", "widthratio", "url", "with", "endwith",
25 "get_current_language", "trans", "endtrans", "noop", "blocktrans",
25 "get_current_language", "trans", "endtrans", "noop", "blocktrans",
26 "endblocktrans", "get_available_languages",
26 "endblocktrans", "get_available_languages",
27 "get_current_language_bidi", "plural"],
27 "get_current_language_bidi", "plural"],
28 operator = /^[+\-*&%=<>!?|~^]/,
28 operator = /^[+\-*&%=<>!?|~^]/,
29 sign = /^[:\[\(\{]/,
29 sign = /^[:\[\(\{]/,
30 atom = ["true", "false"],
30 atom = ["true", "false"],
31 number = /^(\d[+\-\*\/])?\d+(\.\d+)?/;
31 number = /^(\d[+\-\*\/])?\d+(\.\d+)?/;
32
32
33 keywords = new RegExp("((" + keywords.join(")|(") + "))\\b");
33 keywords = new RegExp("((" + keywords.join(")|(") + "))\\b");
34 atom = new RegExp("((" + atom.join(")|(") + "))\\b");
34 atom = new RegExp("((" + atom.join(")|(") + "))\\b");
35
35
36 function tokenBase (stream, state) {
36 function tokenBase (stream, state) {
37 var ch = stream.peek();
37 var ch = stream.peek();
38
38
39 //Comment
39 //Comment
40 if (state.incomment) {
40 if (state.incomment) {
41 if(!stream.skipTo("#}")) {
41 if(!stream.skipTo("#}")) {
42 stream.skipToEnd();
42 stream.skipToEnd();
43 } else {
43 } else {
44 stream.eatWhile(/\#|}/);
44 stream.eatWhile(/\#|}/);
45 state.incomment = false;
45 state.incomment = false;
46 }
46 }
47 return "comment";
47 return "comment";
48 //Tag
48 //Tag
49 } else if (state.intag) {
49 } else if (state.intag) {
50 //After operator
50 //After operator
51 if(state.operator) {
51 if(state.operator) {
52 state.operator = false;
52 state.operator = false;
53 if(stream.match(atom)) {
53 if(stream.match(atom)) {
54 return "atom";
54 return "atom";
55 }
55 }
56 if(stream.match(number)) {
56 if(stream.match(number)) {
57 return "number";
57 return "number";
58 }
58 }
59 }
59 }
60 //After sign
60 //After sign
61 if(state.sign) {
61 if(state.sign) {
62 state.sign = false;
62 state.sign = false;
63 if(stream.match(atom)) {
63 if(stream.match(atom)) {
64 return "atom";
64 return "atom";
65 }
65 }
66 if(stream.match(number)) {
66 if(stream.match(number)) {
67 return "number";
67 return "number";
68 }
68 }
69 }
69 }
70
70
71 if(state.instring) {
71 if(state.instring) {
72 if(ch == state.instring) {
72 if(ch == state.instring) {
73 state.instring = false;
73 state.instring = false;
74 }
74 }
75 stream.next();
75 stream.next();
76 return "string";
76 return "string";
77 } else if(ch == "'" || ch == '"') {
77 } else if(ch == "'" || ch == '"') {
78 state.instring = ch;
78 state.instring = ch;
79 stream.next();
79 stream.next();
80 return "string";
80 return "string";
81 } else if(stream.match(state.intag + "}") || stream.eat("-") && stream.match(state.intag + "}")) {
81 } else if(stream.match(state.intag + "}") || stream.eat("-") && stream.match(state.intag + "}")) {
82 state.intag = false;
82 state.intag = false;
83 return "tag";
83 return "tag";
84 } else if(stream.match(operator)) {
84 } else if(stream.match(operator)) {
85 state.operator = true;
85 state.operator = true;
86 return "operator";
86 return "operator";
87 } else if(stream.match(sign)) {
87 } else if(stream.match(sign)) {
88 state.sign = true;
88 state.sign = true;
89 } else {
89 } else {
90 if(stream.eat(" ") || stream.sol()) {
90 if(stream.eat(" ") || stream.sol()) {
91 if(stream.match(keywords)) {
91 if(stream.match(keywords)) {
92 return "keyword";
92 return "keyword";
93 }
93 }
94 if(stream.match(atom)) {
94 if(stream.match(atom)) {
95 return "atom";
95 return "atom";
96 }
96 }
97 if(stream.match(number)) {
97 if(stream.match(number)) {
98 return "number";
98 return "number";
99 }
99 }
100 if(stream.sol()) {
100 if(stream.sol()) {
101 stream.next();
101 stream.next();
102 }
102 }
103 } else {
103 } else {
104 stream.next();
104 stream.next();
105 }
105 }
106
106
107 }
107 }
108 return "variable";
108 return "variable";
109 } else if (stream.eat("{")) {
109 } else if (stream.eat("{")) {
110 if (ch = stream.eat("#")) {
110 if (stream.eat("#")) {
111 state.incomment = true;
111 state.incomment = true;
112 if(!stream.skipTo("#}")) {
112 if(!stream.skipTo("#}")) {
113 stream.skipToEnd();
113 stream.skipToEnd();
114 } else {
114 } else {
115 stream.eatWhile(/\#|}/);
115 stream.eatWhile(/\#|}/);
116 state.incomment = false;
116 state.incomment = false;
117 }
117 }
118 return "comment";
118 return "comment";
119 //Open tag
119 //Open tag
120 } else if (ch = stream.eat(/\{|%/)) {
120 } else if (ch = stream.eat(/\{|%/)) {
121 //Cache close tag
121 //Cache close tag
122 state.intag = ch;
122 state.intag = ch;
123 if(ch == "{") {
123 if(ch == "{") {
124 state.intag = "}";
124 state.intag = "}";
125 }
125 }
126 stream.eat("-");
126 stream.eat("-");
127 return "tag";
127 return "tag";
128 }
128 }
129 }
129 }
130 stream.next();
130 stream.next();
131 };
131 };
132
132
133 return {
133 return {
134 startState: function () {
134 startState: function () {
135 return {tokenize: tokenBase};
135 return {tokenize: tokenBase};
136 },
136 },
137 token: function (stream, state) {
137 token: function (stream, state) {
138 return state.tokenize(stream, state);
138 return state.tokenize(stream, state);
139 }
139 },
140 blockCommentStart: "{#",
141 blockCommentEnd: "#}"
140 };
142 };
141 });
143 });
144
145 CodeMirror.defineMIME("text/jinja2", "jinja2");
142 });
146 });
@@ -1,147 +1,148 b''
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
2 // Distributed under an MIT license: https://codemirror.net/LICENSE
3
3
4 (function(mod) {
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"), require("../xml/xml"), require("../javascript/javascript"))
6 mod(require("../../lib/codemirror"), require("../xml/xml"), require("../javascript/javascript"))
7 else if (typeof define == "function" && define.amd) // AMD
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror", "../xml/xml", "../javascript/javascript"], mod)
8 define(["../../lib/codemirror", "../xml/xml", "../javascript/javascript"], mod)
9 else // Plain browser env
9 else // Plain browser env
10 mod(CodeMirror)
10 mod(CodeMirror)
11 })(function(CodeMirror) {
11 })(function(CodeMirror) {
12 "use strict"
12 "use strict"
13
13
14 // Depth means the amount of open braces in JS context, in XML
14 // Depth means the amount of open braces in JS context, in XML
15 // context 0 means not in tag, 1 means in tag, and 2 means in tag
15 // context 0 means not in tag, 1 means in tag, and 2 means in tag
16 // and js block comment.
16 // and js block comment.
17 function Context(state, mode, depth, prev) {
17 function Context(state, mode, depth, prev) {
18 this.state = state; this.mode = mode; this.depth = depth; this.prev = prev
18 this.state = state; this.mode = mode; this.depth = depth; this.prev = prev
19 }
19 }
20
20
21 function copyContext(context) {
21 function copyContext(context) {
22 return new Context(CodeMirror.copyState(context.mode, context.state),
22 return new Context(CodeMirror.copyState(context.mode, context.state),
23 context.mode,
23 context.mode,
24 context.depth,
24 context.depth,
25 context.prev && copyContext(context.prev))
25 context.prev && copyContext(context.prev))
26 }
26 }
27
27
28 CodeMirror.defineMode("jsx", function(config) {
28 CodeMirror.defineMode("jsx", function(config, modeConfig) {
29 var xmlMode = CodeMirror.getMode(config, {name: "xml", allowMissing: true, multilineTagIndentPastTag: false})
29 var xmlMode = CodeMirror.getMode(config, {name: "xml", allowMissing: true, multilineTagIndentPastTag: false, allowMissingTagName: true})
30 var jsMode = CodeMirror.getMode(config, "javascript")
30 var jsMode = CodeMirror.getMode(config, modeConfig && modeConfig.base || "javascript")
31
31
32 function flatXMLIndent(state) {
32 function flatXMLIndent(state) {
33 var tagName = state.tagName
33 var tagName = state.tagName
34 state.tagName = null
34 state.tagName = null
35 var result = xmlMode.indent(state, "")
35 var result = xmlMode.indent(state, "", "")
36 state.tagName = tagName
36 state.tagName = tagName
37 return result
37 return result
38 }
38 }
39
39
40 function token(stream, state) {
40 function token(stream, state) {
41 if (state.context.mode == xmlMode)
41 if (state.context.mode == xmlMode)
42 return xmlToken(stream, state, state.context)
42 return xmlToken(stream, state, state.context)
43 else
43 else
44 return jsToken(stream, state, state.context)
44 return jsToken(stream, state, state.context)
45 }
45 }
46
46
47 function xmlToken(stream, state, cx) {
47 function xmlToken(stream, state, cx) {
48 if (cx.depth == 2) { // Inside a JS /* */ comment
48 if (cx.depth == 2) { // Inside a JS /* */ comment
49 if (stream.match(/^.*?\*\//)) cx.depth = 1
49 if (stream.match(/^.*?\*\//)) cx.depth = 1
50 else stream.skipToEnd()
50 else stream.skipToEnd()
51 return "comment"
51 return "comment"
52 }
52 }
53
53
54 if (stream.peek() == "{") {
54 if (stream.peek() == "{") {
55 xmlMode.skipAttribute(cx.state)
55 xmlMode.skipAttribute(cx.state)
56
56
57 var indent = flatXMLIndent(cx.state), xmlContext = cx.state.context
57 var indent = flatXMLIndent(cx.state), xmlContext = cx.state.context
58 // If JS starts on same line as tag
58 // If JS starts on same line as tag
59 if (xmlContext && stream.match(/^[^>]*>\s*$/, false)) {
59 if (xmlContext && stream.match(/^[^>]*>\s*$/, false)) {
60 while (xmlContext.prev && !xmlContext.startOfLine)
60 while (xmlContext.prev && !xmlContext.startOfLine)
61 xmlContext = xmlContext.prev
61 xmlContext = xmlContext.prev
62 // If tag starts the line, use XML indentation level
62 // If tag starts the line, use XML indentation level
63 if (xmlContext.startOfLine) indent -= config.indentUnit
63 if (xmlContext.startOfLine) indent -= config.indentUnit
64 // Else use JS indentation level
64 // Else use JS indentation level
65 else if (cx.prev.state.lexical) indent = cx.prev.state.lexical.indented
65 else if (cx.prev.state.lexical) indent = cx.prev.state.lexical.indented
66 // Else if inside of tag
66 // Else if inside of tag
67 } else if (cx.depth == 1) {
67 } else if (cx.depth == 1) {
68 indent += config.indentUnit
68 indent += config.indentUnit
69 }
69 }
70
70
71 state.context = new Context(CodeMirror.startState(jsMode, indent),
71 state.context = new Context(CodeMirror.startState(jsMode, indent),
72 jsMode, 0, state.context)
72 jsMode, 0, state.context)
73 return null
73 return null
74 }
74 }
75
75
76 if (cx.depth == 1) { // Inside of tag
76 if (cx.depth == 1) { // Inside of tag
77 if (stream.peek() == "<") { // Tag inside of tag
77 if (stream.peek() == "<") { // Tag inside of tag
78 xmlMode.skipAttribute(cx.state)
78 xmlMode.skipAttribute(cx.state)
79 state.context = new Context(CodeMirror.startState(xmlMode, flatXMLIndent(cx.state)),
79 state.context = new Context(CodeMirror.startState(xmlMode, flatXMLIndent(cx.state)),
80 xmlMode, 0, state.context)
80 xmlMode, 0, state.context)
81 return null
81 return null
82 } else if (stream.match("//")) {
82 } else if (stream.match("//")) {
83 stream.skipToEnd()
83 stream.skipToEnd()
84 return "comment"
84 return "comment"
85 } else if (stream.match("/*")) {
85 } else if (stream.match("/*")) {
86 cx.depth = 2
86 cx.depth = 2
87 return token(stream, state)
87 return token(stream, state)
88 }
88 }
89 }
89 }
90
90
91 var style = xmlMode.token(stream, cx.state), cur = stream.current(), stop
91 var style = xmlMode.token(stream, cx.state), cur = stream.current(), stop
92 if (/\btag\b/.test(style)) {
92 if (/\btag\b/.test(style)) {
93 if (/>$/.test(cur)) {
93 if (/>$/.test(cur)) {
94 if (cx.state.context) cx.depth = 0
94 if (cx.state.context) cx.depth = 0
95 else state.context = state.context.prev
95 else state.context = state.context.prev
96 } else if (/^</.test(cur)) {
96 } else if (/^</.test(cur)) {
97 cx.depth = 1
97 cx.depth = 1
98 }
98 }
99 } else if (!style && (stop = cur.indexOf("{")) > -1) {
99 } else if (!style && (stop = cur.indexOf("{")) > -1) {
100 stream.backUp(cur.length - stop)
100 stream.backUp(cur.length - stop)
101 }
101 }
102 return style
102 return style
103 }
103 }
104
104
105 function jsToken(stream, state, cx) {
105 function jsToken(stream, state, cx) {
106 if (stream.peek() == "<" && jsMode.expressionAllowed(stream, cx.state)) {
106 if (stream.peek() == "<" && jsMode.expressionAllowed(stream, cx.state)) {
107 jsMode.skipExpression(cx.state)
107 jsMode.skipExpression(cx.state)
108 state.context = new Context(CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "")),
108 state.context = new Context(CodeMirror.startState(xmlMode, jsMode.indent(cx.state, "", "")),
109 xmlMode, 0, state.context)
109 xmlMode, 0, state.context)
110 return null
110 return null
111 }
111 }
112
112
113 var style = jsMode.token(stream, cx.state)
113 var style = jsMode.token(stream, cx.state)
114 if (!style && cx.depth != null) {
114 if (!style && cx.depth != null) {
115 var cur = stream.current()
115 var cur = stream.current()
116 if (cur == "{") {
116 if (cur == "{") {
117 cx.depth++
117 cx.depth++
118 } else if (cur == "}") {
118 } else if (cur == "}") {
119 if (--cx.depth == 0) state.context = state.context.prev
119 if (--cx.depth == 0) state.context = state.context.prev
120 }
120 }
121 }
121 }
122 return style
122 return style
123 }
123 }
124
124
125 return {
125 return {
126 startState: function() {
126 startState: function() {
127 return {context: new Context(CodeMirror.startState(jsMode), jsMode)}
127 return {context: new Context(CodeMirror.startState(jsMode), jsMode)}
128 },
128 },
129
129
130 copyState: function(state) {
130 copyState: function(state) {
131 return {context: copyContext(state.context)}
131 return {context: copyContext(state.context)}
132 },
132 },
133
133
134 token: token,
134 token: token,
135
135
136 indent: function(state, textAfter, fullLine) {
136 indent: function(state, textAfter, fullLine) {
137 return state.context.mode.indent(state.context.state, textAfter, fullLine)
137 return state.context.mode.indent(state.context.state, textAfter, fullLine)
138 },
138 },
139
139
140 innerMode: function(state) {
140 innerMode: function(state) {
141 return state.context
141 return state.context
142 }
142 }
143 }
143 }
144 }, "xml", "javascript")
144 }, "xml", "javascript")
145
145
146 CodeMirror.defineMIME("text/jsx", "jsx")
146 CodeMirror.defineMIME("text/jsx", "jsx")
147 })
147 CodeMirror.defineMIME("text/typescript-jsx", {name: "jsx", base: {name: "javascript", typescript: true}})
148 });
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
General Comments 0
You need to be logged in to leave comments. Login now