OLD | NEW |
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: http://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.contex
t); |
| 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 == "variable-3") return t
rue; |
| 37 if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, pos))) return tru
e; |
| 38 if (state.typeAtEndOfLine && stream.column() == stream.indentation()) return t
rue; |
| 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 || {}, |
| 54 types = parserConfig.types || {}, |
19 builtin = parserConfig.builtin || {}, | 55 builtin = parserConfig.builtin || {}, |
20 blockKeywords = parserConfig.blockKeywords || {}, | 56 blockKeywords = parserConfig.blockKeywords || {}, |
| 57 defKeywords = parserConfig.defKeywords || {}, |
21 atoms = parserConfig.atoms || {}, | 58 atoms = parserConfig.atoms || {}, |
22 hooks = parserConfig.hooks || {}, | 59 hooks = parserConfig.hooks || {}, |
23 multiLineStrings = parserConfig.multiLineStrings; | 60 multiLineStrings = parserConfig.multiLineStrings, |
24 var isOperatorChar = /[+\-*&%=<>!?|\/]/; | 61 indentStatements = parserConfig.indentStatements !== false, |
| 62 indentSwitch = parserConfig.indentSwitch !== false, |
| 63 namespaceSeparator = parserConfig.namespaceSeparator, |
| 64 isPunctuationChar = parserConfig.isPunctuationChar || /[\[\]{}\(\),;\:\.]/
, |
| 65 numberStart = parserConfig.numberStart || /[\d\.]/, |
| 66 number = parserConfig.number || /^(?:0x[a-f\d]+|0b[01]+|(?:\d+\.?\d*|\.\d+
)(?:e[-+]?\d+)?)(u|ll?|l|f)?/i, |
| 67 isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/, |
| 68 endStatement = parserConfig.endStatement || /^[;:,]$/; |
25 | 69 |
26 var curPunc; | 70 var curPunc, isDefKeyword; |
27 | 71 |
28 function tokenBase(stream, state) { | 72 function tokenBase(stream, state) { |
29 var ch = stream.next(); | 73 var ch = stream.next(); |
30 if (hooks[ch]) { | 74 if (hooks[ch]) { |
31 var result = hooks[ch](stream, state); | 75 var result = hooks[ch](stream, state); |
32 if (result !== false) return result; | 76 if (result !== false) return result; |
33 } | 77 } |
34 if (ch == '"' || ch == "'") { | 78 if (ch == '"' || ch == "'") { |
35 state.tokenize = tokenString(ch); | 79 state.tokenize = tokenString(ch); |
36 return state.tokenize(stream, state); | 80 return state.tokenize(stream, state); |
37 } | 81 } |
38 if (/[\[\]{}\(\),;\:\.]/.test(ch)) { | 82 if (isPunctuationChar.test(ch)) { |
39 curPunc = ch; | 83 curPunc = ch; |
40 return null; | 84 return null; |
41 } | 85 } |
42 if (/\d/.test(ch)) { | 86 if (numberStart.test(ch)) { |
43 stream.eatWhile(/[\w\.]/); | 87 stream.backUp(1) |
44 return "number"; | 88 if (stream.match(number)) return "number" |
| 89 stream.next() |
45 } | 90 } |
46 if (ch == "/") { | 91 if (ch == "/") { |
47 if (stream.eat("*")) { | 92 if (stream.eat("*")) { |
48 state.tokenize = tokenComment; | 93 state.tokenize = tokenComment; |
49 return tokenComment(stream, state); | 94 return tokenComment(stream, state); |
50 } | 95 } |
51 if (stream.eat("/")) { | 96 if (stream.eat("/")) { |
52 stream.skipToEnd(); | 97 stream.skipToEnd(); |
53 return "comment"; | 98 return "comment"; |
54 } | 99 } |
55 } | 100 } |
56 if (isOperatorChar.test(ch)) { | 101 if (isOperatorChar.test(ch)) { |
57 stream.eatWhile(isOperatorChar); | 102 while (!stream.match(/^\/[\/*]/, false) && stream.eat(isOperatorChar)) {} |
58 return "operator"; | 103 return "operator"; |
59 } | 104 } |
60 stream.eatWhile(/[\w\$_]/); | 105 stream.eatWhile(/[\w\$_\xa1-\uffff]/); |
| 106 if (namespaceSeparator) while (stream.match(namespaceSeparator)) |
| 107 stream.eatWhile(/[\w\$_\xa1-\uffff]/); |
| 108 |
61 var cur = stream.current(); | 109 var cur = stream.current(); |
62 if (keywords.propertyIsEnumerable(cur)) { | 110 if (contains(keywords, cur)) { |
63 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement"; | 111 if (contains(blockKeywords, cur)) curPunc = "newstatement"; |
| 112 if (contains(defKeywords, cur)) isDefKeyword = true; |
64 return "keyword"; | 113 return "keyword"; |
65 } | 114 } |
66 if (builtin.propertyIsEnumerable(cur)) { | 115 if (contains(types, cur)) return "variable-3"; |
67 if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement"; | 116 if (contains(builtin, cur)) { |
| 117 if (contains(blockKeywords, cur)) curPunc = "newstatement"; |
68 return "builtin"; | 118 return "builtin"; |
69 } | 119 } |
70 if (atoms.propertyIsEnumerable(cur)) return "atom"; | 120 if (contains(atoms, cur)) return "atom"; |
71 return "variable"; | 121 return "variable"; |
72 } | 122 } |
73 | 123 |
74 function tokenString(quote) { | 124 function tokenString(quote) { |
75 return function(stream, state) { | 125 return function(stream, state) { |
76 var escaped = false, next, end = false; | 126 var escaped = false, next, end = false; |
77 while ((next = stream.next()) != null) { | 127 while ((next = stream.next()) != null) { |
78 if (next == quote && !escaped) {end = true; break;} | 128 if (next == quote && !escaped) {end = true; break;} |
79 escaped = !escaped && next == "\\"; | 129 escaped = !escaped && next == "\\"; |
80 } | 130 } |
81 if (end || !(escaped || multiLineStrings)) | 131 if (end || !(escaped || multiLineStrings)) |
82 state.tokenize = null; | 132 state.tokenize = null; |
83 return "string"; | 133 return "string"; |
84 }; | 134 }; |
85 } | 135 } |
86 | 136 |
87 function tokenComment(stream, state) { | 137 function tokenComment(stream, state) { |
88 var maybeEnd = false, ch; | 138 var maybeEnd = false, ch; |
89 while (ch = stream.next()) { | 139 while (ch = stream.next()) { |
90 if (ch == "/" && maybeEnd) { | 140 if (ch == "/" && maybeEnd) { |
91 state.tokenize = null; | 141 state.tokenize = null; |
92 break; | 142 break; |
93 } | 143 } |
94 maybeEnd = (ch == "*"); | 144 maybeEnd = (ch == "*"); |
95 } | 145 } |
96 return "comment"; | 146 return "comment"; |
97 } | 147 } |
98 | 148 |
99 function Context(indented, column, type, align, prev) { | 149 function maybeEOL(stream, state) { |
100 this.indented = indented; | 150 if (parserConfig.typeFirstDefinitions && stream.eol() && isTopScope(state.co
ntext)) |
101 this.column = column; | 151 state.typeAtEndOfLine = typeBefore(stream, state, stream.pos) |
102 this.type = type; | |
103 this.align = align; | |
104 this.prev = prev; | |
105 } | |
106 function pushContext(state, col, type) { | |
107 var indent = state.indented; | |
108 if (state.context && state.context.type == "statement") | |
109 indent = state.context.indented; | |
110 return state.context = new Context(indent, col, type, null, state.context); | |
111 } | |
112 function popContext(state) { | |
113 var t = state.context.type; | |
114 if (t == ")" || t == "]" || t == "}") | |
115 state.indented = state.context.indented; | |
116 return state.context = state.context.prev; | |
117 } | 152 } |
118 | 153 |
119 // Interface | 154 // Interface |
120 | 155 |
121 return { | 156 return { |
122 startState: function(basecolumn) { | 157 startState: function(basecolumn) { |
123 return { | 158 return { |
124 tokenize: null, | 159 tokenize: null, |
125 context: new Context((basecolumn || 0) - indentUnit, 0, "top", false), | 160 context: new Context((basecolumn || 0) - indentUnit, 0, "top", null, fal
se), |
126 indented: 0, | 161 indented: 0, |
127 startOfLine: true | 162 startOfLine: true, |
| 163 prevToken: null |
128 }; | 164 }; |
129 }, | 165 }, |
130 | 166 |
131 token: function(stream, state) { | 167 token: function(stream, state) { |
132 var ctx = state.context; | 168 var ctx = state.context; |
133 if (stream.sol()) { | 169 if (stream.sol()) { |
134 if (ctx.align == null) ctx.align = false; | 170 if (ctx.align == null) ctx.align = false; |
135 state.indented = stream.indentation(); | 171 state.indented = stream.indentation(); |
136 state.startOfLine = true; | 172 state.startOfLine = true; |
137 } | 173 } |
138 if (stream.eatSpace()) return null; | 174 if (stream.eatSpace()) { maybeEOL(stream, state); return null; } |
139 curPunc = null; | 175 curPunc = isDefKeyword = null; |
140 var style = (state.tokenize || tokenBase)(stream, state); | 176 var style = (state.tokenize || tokenBase)(stream, state); |
141 if (style == "comment" || style == "meta") return style; | 177 if (style == "comment" || style == "meta") return style; |
142 if (ctx.align == null) ctx.align = true; | 178 if (ctx.align == null) ctx.align = true; |
143 | 179 |
144 if ((curPunc == ";" || curPunc == ":" || curPunc == ",") && ctx.type == "s
tatement") popContext(state); | 180 if (endStatement.test(curPunc)) while (state.context.type == "statement")
popContext(state); |
145 else if (curPunc == "{") pushContext(state, stream.column(), "}"); | 181 else if (curPunc == "{") pushContext(state, stream.column(), "}"); |
146 else if (curPunc == "[") pushContext(state, stream.column(), "]"); | 182 else if (curPunc == "[") pushContext(state, stream.column(), "]"); |
147 else if (curPunc == "(") pushContext(state, stream.column(), ")"); | 183 else if (curPunc == "(") pushContext(state, stream.column(), ")"); |
148 else if (curPunc == "}") { | 184 else if (curPunc == "}") { |
149 while (ctx.type == "statement") ctx = popContext(state); | 185 while (ctx.type == "statement") ctx = popContext(state); |
150 if (ctx.type == "}") ctx = popContext(state); | 186 if (ctx.type == "}") ctx = popContext(state); |
151 while (ctx.type == "statement") ctx = popContext(state); | 187 while (ctx.type == "statement") ctx = popContext(state); |
152 } | 188 } |
153 else if (curPunc == ctx.type) popContext(state); | 189 else if (curPunc == ctx.type) popContext(state); |
154 else if (((ctx.type == "}" || ctx.type == "top") && curPunc != ';') || (ct
x.type == "statement" && curPunc == "newstatement")) | 190 else if (indentStatements && |
155 pushContext(state, stream.column(), "statement"); | 191 (((ctx.type == "}" || ctx.type == "top") && curPunc != ";") || |
| 192 (ctx.type == "statement" && curPunc == "newstatement"))) { |
| 193 pushContext(state, stream.column(), "statement", stream.current()); |
| 194 } |
| 195 |
| 196 if (style == "variable" && |
| 197 ((state.prevToken == "def" || |
| 198 (parserConfig.typeFirstDefinitions && typeBefore(stream, state, stre
am.start) && |
| 199 isTopScope(state.context) && stream.match(/^\s*\(/, false))))) |
| 200 style = "def"; |
| 201 |
| 202 if (hooks.token) { |
| 203 var result = hooks.token(stream, state, style); |
| 204 if (result !== undefined) style = result; |
| 205 } |
| 206 |
| 207 if (style == "def" && parserConfig.styleDefs === false) style = "variable"
; |
| 208 |
156 state.startOfLine = false; | 209 state.startOfLine = false; |
| 210 state.prevToken = isDefKeyword ? "def" : style || curPunc; |
| 211 maybeEOL(stream, state); |
157 return style; | 212 return style; |
158 }, | 213 }, |
159 | 214 |
160 indent: function(state, textAfter) { | 215 indent: function(state, textAfter) { |
161 if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirr
or.Pass; | 216 if (state.tokenize != tokenBase && state.tokenize != null || state.typeAtE
ndOfLine) return CodeMirror.Pass; |
162 var ctx = state.context, firstChar = textAfter && textAfter.charAt(0); | 217 var ctx = state.context, firstChar = textAfter && textAfter.charAt(0); |
163 if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev; | 218 if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev; |
| 219 if (parserConfig.dontIndentStatements) |
| 220 while (ctx.type == "statement" && parserConfig.dontIndentStatements.test
(ctx.info)) |
| 221 ctx = ctx.prev |
| 222 if (hooks.indent) { |
| 223 var hook = hooks.indent(state, ctx, textAfter); |
| 224 if (typeof hook == "number") return hook |
| 225 } |
164 var closing = firstChar == ctx.type; | 226 var closing = firstChar == ctx.type; |
165 if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 :
statementIndentUnit); | 227 var switchBlock = ctx.prev && ctx.prev.info == "switch"; |
166 else if (ctx.align && (!dontAlignCalls || ctx.type != ")")) return ctx.col
umn + (closing ? 0 : 1); | 228 if (parserConfig.allmanIndentation && /[{(]/.test(firstChar)) { |
167 else if (ctx.type == ")" && !closing) return ctx.indented + statementInden
tUnit; | 229 while (ctx.type != "top" && ctx.type != "}") ctx = ctx.prev |
168 else return ctx.indented + (closing ? 0 : indentUnit); | 230 return ctx.indented |
| 231 } |
| 232 if (ctx.type == "statement") |
| 233 return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit); |
| 234 if (ctx.align && (!dontAlignCalls || ctx.type != ")")) |
| 235 return ctx.column + (closing ? 0 : 1); |
| 236 if (ctx.type == ")" && !closing) |
| 237 return ctx.indented + statementIndentUnit; |
| 238 |
| 239 return ctx.indented + (closing ? 0 : indentUnit) + |
| 240 (!closing && switchBlock && !/^(?:case|default)\b/.test(textAfter) ? ind
entUnit : 0); |
169 }, | 241 }, |
170 | 242 |
171 electricChars: "{}", | 243 electricInput: indentSwitch ? /^\s*(?:case .*?:|default:|\{\}?|\})$/ : /^\s*
[{}]$/, |
172 blockCommentStart: "/*", | 244 blockCommentStart: "/*", |
173 blockCommentEnd: "*/", | 245 blockCommentEnd: "*/", |
174 lineComment: "//", | 246 lineComment: "//", |
175 fold: "brace" | 247 fold: "brace" |
176 }; | 248 }; |
177 }); | 249 }); |
178 | 250 |
179 function words(str) { | 251 function words(str) { |
180 var obj = {}, words = str.split(" "); | 252 var obj = {}, words = str.split(" "); |
181 for (var i = 0; i < words.length; ++i) obj[words[i]] = true; | 253 for (var i = 0; i < words.length; ++i) obj[words[i]] = true; |
182 return obj; | 254 return obj; |
183 } | 255 } |
184 var cKeywords = "auto if break int case long char register continue return def
ault short do sizeof " + | 256 function contains(words, word) { |
185 "double static else struct entry switch extern typedef float union for unsig
ned " + | 257 if (typeof words === "function") { |
186 "goto while enum void const signed volatile"; | 258 return words(word); |
| 259 } else { |
| 260 return words.propertyIsEnumerable(word); |
| 261 } |
| 262 } |
| 263 var cKeywords = "auto if break case register continue return default do sizeof
" + |
| 264 "static else struct switch extern typedef union for goto while enum const vo
latile"; |
| 265 var cTypes = "int long char short double float unsigned signed void size_t ptr
diff_t"; |
187 | 266 |
188 function cppHook(stream, state) { | 267 function cppHook(stream, state) { |
189 if (!state.startOfLine) return false; | 268 if (!state.startOfLine) return false |
190 for (;;) { | 269 for (var ch, next = null; ch = stream.peek();) { |
191 if (stream.skipTo("\\")) { | 270 if (ch == "\\" && stream.match(/^.$/)) { |
192 stream.next(); | 271 next = cppHook |
193 if (stream.eol()) { | 272 break |
194 state.tokenize = cppHook; | 273 } else if (ch == "/" && stream.match(/^\/[\/\*]/, false)) { |
195 break; | 274 break |
196 } | |
197 } else { | |
198 stream.skipToEnd(); | |
199 state.tokenize = null; | |
200 break; | |
201 } | 275 } |
| 276 stream.next() |
202 } | 277 } |
203 return "meta"; | 278 state.tokenize = next |
| 279 return "meta" |
| 280 } |
| 281 |
| 282 function pointerHook(_stream, state) { |
| 283 if (state.prevToken == "variable-3") return "variable-3"; |
| 284 return false; |
| 285 } |
| 286 |
| 287 function cpp14Literal(stream) { |
| 288 stream.eatWhile(/[\w\.']/); |
| 289 return "number"; |
204 } | 290 } |
205 | 291 |
206 function cpp11StringHook(stream, state) { | 292 function cpp11StringHook(stream, state) { |
207 stream.backUp(1); | 293 stream.backUp(1); |
208 // Raw strings. | 294 // Raw strings. |
209 if (stream.match(/(R|u8R|uR|UR|LR)/)) { | 295 if (stream.match(/(R|u8R|uR|UR|LR)/)) { |
210 var match = stream.match(/"([^\s\\()]{0,16})\(/); | 296 var match = stream.match(/"([^\s\\()]{0,16})\(/); |
211 if (!match) { | 297 if (!match) { |
212 return false; | 298 return false; |
213 } | 299 } |
214 state.cpp11RawStringDelim = match[1]; | 300 state.cpp11RawStringDelim = match[1]; |
215 state.tokenize = tokenRawString; | 301 state.tokenize = tokenRawString; |
216 return tokenRawString(stream, state); | 302 return tokenRawString(stream, state); |
217 } | 303 } |
218 // Unicode strings/chars. | 304 // Unicode strings/chars. |
219 if (stream.match(/(u8|u|U|L)/)) { | 305 if (stream.match(/(u8|u|U|L)/)) { |
220 if (stream.match(/["']/, /* eat */ false)) { | 306 if (stream.match(/["']/, /* eat */ false)) { |
221 return "string"; | 307 return "string"; |
222 } | 308 } |
223 return false; | 309 return false; |
224 } | 310 } |
225 // Ignore this hook. | 311 // Ignore this hook. |
226 stream.next(); | 312 stream.next(); |
227 return false; | 313 return false; |
228 } | 314 } |
229 | 315 |
| 316 function cppLooksLikeConstructor(word) { |
| 317 var lastTwo = /(\w+)::(\w+)$/.exec(word); |
| 318 return lastTwo && lastTwo[1] == lastTwo[2]; |
| 319 } |
| 320 |
230 // C#-style strings where "" escapes a quote. | 321 // C#-style strings where "" escapes a quote. |
231 function tokenAtString(stream, state) { | 322 function tokenAtString(stream, state) { |
232 var next; | 323 var next; |
233 while ((next = stream.next()) != null) { | 324 while ((next = stream.next()) != null) { |
234 if (next == '"' && !stream.eat('"')) { | 325 if (next == '"' && !stream.eat('"')) { |
235 state.tokenize = null; | 326 state.tokenize = null; |
236 break; | 327 break; |
237 } | 328 } |
238 } | 329 } |
239 return "string"; | 330 return "string"; |
(...skipping 13 matching lines...) Expand all Loading... |
253 } | 344 } |
254 | 345 |
255 function def(mimes, mode) { | 346 function def(mimes, mode) { |
256 if (typeof mimes == "string") mimes = [mimes]; | 347 if (typeof mimes == "string") mimes = [mimes]; |
257 var words = []; | 348 var words = []; |
258 function add(obj) { | 349 function add(obj) { |
259 if (obj) for (var prop in obj) if (obj.hasOwnProperty(prop)) | 350 if (obj) for (var prop in obj) if (obj.hasOwnProperty(prop)) |
260 words.push(prop); | 351 words.push(prop); |
261 } | 352 } |
262 add(mode.keywords); | 353 add(mode.keywords); |
| 354 add(mode.types); |
263 add(mode.builtin); | 355 add(mode.builtin); |
264 add(mode.atoms); | 356 add(mode.atoms); |
265 if (words.length) { | 357 if (words.length) { |
266 mode.helperType = mimes[0]; | 358 mode.helperType = mimes[0]; |
267 CodeMirror.registerHelper("hintWords", mimes[0], words); | 359 CodeMirror.registerHelper("hintWords", mimes[0], words); |
268 } | 360 } |
269 | 361 |
270 for (var i = 0; i < mimes.length; ++i) | 362 for (var i = 0; i < mimes.length; ++i) |
271 CodeMirror.defineMIME(mimes[i], mode); | 363 CodeMirror.defineMIME(mimes[i], mode); |
272 } | 364 } |
273 | 365 |
274 def(["text/x-csrc", "text/x-c", "text/x-chdr"], { | 366 def(["text/x-csrc", "text/x-c", "text/x-chdr"], { |
275 name: "clike", | 367 name: "clike", |
276 keywords: words(cKeywords), | 368 keywords: words(cKeywords), |
| 369 types: words(cTypes + " bool _Complex _Bool float_t double_t intptr_t intmax
_t " + |
| 370 "int8_t int16_t int32_t int64_t uintptr_t uintmax_t uint8_t uin
t16_t " + |
| 371 "uint32_t uint64_t"), |
277 blockKeywords: words("case do else for if switch while struct"), | 372 blockKeywords: words("case do else for if switch while struct"), |
278 atoms: words("null"), | 373 defKeywords: words("struct"), |
279 hooks: {"#": cppHook}, | 374 typeFirstDefinitions: true, |
| 375 atoms: words("null true false"), |
| 376 hooks: {"#": cppHook, "*": pointerHook}, |
280 modeProps: {fold: ["brace", "include"]} | 377 modeProps: {fold: ["brace", "include"]} |
281 }); | 378 }); |
282 | 379 |
283 def(["text/x-c++src", "text/x-c++hdr"], { | 380 def(["text/x-c++src", "text/x-c++hdr"], { |
284 name: "clike", | 381 name: "clike", |
285 keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast tr
y bool explicit new " + | 382 keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast tr
y explicit new " + |
286 "static_cast typeid catch operator template typename class f
riend private " + | 383 "static_cast typeid catch operator template typename class f
riend private " + |
287 "this using const_cast inline public throw virtual delete mu
table protected " + | 384 "this using const_cast inline public throw virtual delete mu
table protected " + |
288 "wchar_t alignas alignof constexpr decltype nullptr noexcept
thread_local final " + | 385 "alignas alignof constexpr decltype nullptr noexcept thread_
local final " + |
289 "static_assert override"), | 386 "static_assert override"), |
| 387 types: words(cTypes + " bool wchar_t"), |
290 blockKeywords: words("catch class do else finally for if struct switch try w
hile"), | 388 blockKeywords: words("catch class do else finally for if struct switch try w
hile"), |
| 389 defKeywords: words("class namespace struct enum union"), |
| 390 typeFirstDefinitions: true, |
291 atoms: words("true false null"), | 391 atoms: words("true false null"), |
| 392 dontIndentStatements: /^template$/, |
292 hooks: { | 393 hooks: { |
293 "#": cppHook, | 394 "#": cppHook, |
| 395 "*": pointerHook, |
294 "u": cpp11StringHook, | 396 "u": cpp11StringHook, |
295 "U": cpp11StringHook, | 397 "U": cpp11StringHook, |
296 "L": cpp11StringHook, | 398 "L": cpp11StringHook, |
297 "R": cpp11StringHook | 399 "R": cpp11StringHook, |
| 400 "0": cpp14Literal, |
| 401 "1": cpp14Literal, |
| 402 "2": cpp14Literal, |
| 403 "3": cpp14Literal, |
| 404 "4": cpp14Literal, |
| 405 "5": cpp14Literal, |
| 406 "6": cpp14Literal, |
| 407 "7": cpp14Literal, |
| 408 "8": cpp14Literal, |
| 409 "9": cpp14Literal, |
| 410 token: function(stream, state, style) { |
| 411 if (style == "variable" && stream.peek() == "(" && |
| 412 (state.prevToken == ";" || state.prevToken == null || |
| 413 state.prevToken == "}") && |
| 414 cppLooksLikeConstructor(stream.current())) |
| 415 return "def"; |
| 416 } |
298 }, | 417 }, |
| 418 namespaceSeparator: "::", |
299 modeProps: {fold: ["brace", "include"]} | 419 modeProps: {fold: ["brace", "include"]} |
300 }); | 420 }); |
| 421 |
301 def("text/x-java", { | 422 def("text/x-java", { |
302 name: "clike", | 423 name: "clike", |
303 keywords: words("abstract assert boolean break byte case catch char class co
nst continue default " + | 424 keywords: words("abstract assert break case catch class const continue defau
lt " + |
304 "do double else enum extends final finally float for goto if
implements import " + | 425 "do else enum extends final finally float for goto if implem
ents import " + |
305 "instanceof int interface long native new package private pr
otected public " + | 426 "instanceof interface native new package private protected p
ublic " + |
306 "return short static strictfp super switch synchronized this
throw throws transient " + | 427 "return static strictfp super switch synchronized this throw
throws transient " + |
307 "try void volatile while"), | 428 "try volatile while"), |
| 429 types: words("byte short int long float double boolean char void Boolean Byt
e Character Double Float " + |
| 430 "Integer Long Number Object Short String StringBuffer StringBui
lder Void"), |
308 blockKeywords: words("catch class do else finally for if switch try while"), | 431 blockKeywords: words("catch class do else finally for if switch try while"), |
| 432 defKeywords: words("class interface package enum"), |
| 433 typeFirstDefinitions: true, |
309 atoms: words("true false null"), | 434 atoms: words("true false null"), |
| 435 endStatement: /^[;:]$/, |
| 436 number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+\.?\d*|\.\d+)(?:e[-+]?[\d_]+)?)(u
|ll?|l|f)?/i, |
310 hooks: { | 437 hooks: { |
311 "@": function(stream) { | 438 "@": function(stream) { |
312 stream.eatWhile(/[\w\$_]/); | 439 stream.eatWhile(/[\w\$_]/); |
313 return "meta"; | 440 return "meta"; |
314 } | 441 } |
315 }, | 442 }, |
316 modeProps: {fold: ["brace", "import"]} | 443 modeProps: {fold: ["brace", "import"]} |
317 }); | 444 }); |
| 445 |
318 def("text/x-csharp", { | 446 def("text/x-csharp", { |
319 name: "clike", | 447 name: "clike", |
320 keywords: words("abstract as base break case catch checked class const conti
nue" + | 448 keywords: words("abstract as async await base break case catch checked class
const continue" + |
321 " default delegate do else enum event explicit extern finall
y fixed for" + | 449 " default delegate do else enum event explicit extern finall
y fixed for" + |
322 " foreach goto if implicit in interface internal is lock nam
espace new" + | 450 " foreach goto if implicit in interface internal is lock nam
espace new" + |
323 " operator out override params private protected public read
only ref return sealed" + | 451 " operator out override params private protected public read
only ref return sealed" + |
324 " sizeof stackalloc static struct switch this throw try type
of unchecked" + | 452 " sizeof stackalloc static struct switch this throw try type
of unchecked" + |
325 " unsafe using virtual void volatile while add alias ascendi
ng descending dynamic from get" + | 453 " unsafe using virtual void volatile while add alias ascendi
ng descending dynamic from get" + |
326 " global group into join let orderby partial remove select s
et value var yield"), | 454 " global group into join let orderby partial remove select s
et value var yield"), |
| 455 types: words("Action Boolean Byte Char DateTime DateTimeOffset Decimal Doubl
e Func" + |
| 456 " Guid Int16 Int32 Int64 Object SByte Single String Task TimeSp
an UInt16 UInt32" + |
| 457 " UInt64 bool byte char decimal double short int long object"
+ |
| 458 " sbyte float string ushort uint ulong"), |
327 blockKeywords: words("catch class do else finally for foreach if struct swit
ch try while"), | 459 blockKeywords: words("catch class do else finally for foreach if struct swit
ch try while"), |
328 builtin: words("Boolean Byte Char DateTime DateTimeOffset Decimal Double" + | 460 defKeywords: words("class interface namespace struct var"), |
329 " Guid Int16 Int32 Int64 Object SByte Single String TimeSpan
UInt16 UInt32" + | 461 typeFirstDefinitions: true, |
330 " UInt64 bool byte char decimal double short int long object
" + | |
331 " sbyte float string ushort uint ulong"), | |
332 atoms: words("true false null"), | 462 atoms: words("true false null"), |
333 hooks: { | 463 hooks: { |
334 "@": function(stream, state) { | 464 "@": function(stream, state) { |
335 if (stream.eat('"')) { | 465 if (stream.eat('"')) { |
336 state.tokenize = tokenAtString; | 466 state.tokenize = tokenAtString; |
337 return tokenAtString(stream, state); | 467 return tokenAtString(stream, state); |
338 } | 468 } |
339 stream.eatWhile(/[\w\$_]/); | 469 stream.eatWhile(/[\w\$_]/); |
340 return "meta"; | 470 return "meta"; |
341 } | 471 } |
342 } | 472 } |
343 }); | 473 }); |
| 474 |
| 475 function tokenTripleString(stream, state) { |
| 476 var escaped = false; |
| 477 while (!stream.eol()) { |
| 478 if (!escaped && stream.match('"""')) { |
| 479 state.tokenize = null; |
| 480 break; |
| 481 } |
| 482 escaped = stream.next() == "\\" && !escaped; |
| 483 } |
| 484 return "string"; |
| 485 } |
| 486 |
344 def("text/x-scala", { | 487 def("text/x-scala", { |
345 name: "clike", | 488 name: "clike", |
346 keywords: words( | 489 keywords: words( |
347 | 490 |
348 /* scala */ | 491 /* scala */ |
349 "abstract case catch class def do else extends false final finally for for
Some if " + | 492 "abstract case catch class def do else extends final finally for forSome i
f " + |
350 "implicit import lazy match new null object override package private prote
cted return " + | 493 "implicit import lazy match new null object override package private prote
cted return " + |
351 "sealed super this throw trait try trye type val var while with yield _ :
= => <- <: " + | 494 "sealed super this throw trait try type val var while with yield _ : = =>
<- <: " + |
352 "<% >: # @ " + | 495 "<% >: # @ " + |
353 | 496 |
354 /* package scala */ | 497 /* package scala */ |
355 "assert assume require print println printf readLine readBoolean readByte
readShort " + | 498 "assert assume require print println printf readLine readBoolean readByte
readShort " + |
356 "readChar readInt readLong readFloat readDouble " + | 499 "readChar readInt readLong readFloat readDouble " + |
357 | 500 |
| 501 ":: #:: " |
| 502 ), |
| 503 types: words( |
358 "AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Cons
ole Either " + | 504 "AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Cons
ole Either " + |
359 "Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral
Iterable " + | 505 "Enumeration Equiv Error Exception Fractional Function IndexedSeq Int Inte
gral Iterable " + |
360 "Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunc
tion PartialOrdering " + | 506 "Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunc
tion PartialOrdering " + |
361 "Product Proxy Range Responder Seq Serializable Set Specializable Stream S
tringBuilder " + | 507 "Product Proxy Range Responder Seq Serializable Set Specializable Stream S
tringBuilder " + |
362 "StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vec
tor :: #:: " + | 508 "StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vec
tor " + |
363 | 509 |
364 /* package java.lang */ | 510 /* package java.lang */ |
365 "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparabl
e " + | 511 "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparabl
e " + |
366 "Compiler Double Exception Float Integer Long Math Number Object Package P
air Process " + | 512 "Compiler Double Exception Float Integer Long Math Number Object Package P
air Process " + |
367 "Runtime Runnable SecurityManager Short StackTraceElement StrictMath Strin
g " + | 513 "Runtime Runnable SecurityManager Short StackTraceElement StrictMath Strin
g " + |
368 "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void" | 514 "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void" |
369 | |
370 | |
371 ), | 515 ), |
| 516 multiLineStrings: true, |
372 blockKeywords: words("catch class do else finally for forSome if match switc
h try while"), | 517 blockKeywords: words("catch class do else finally for forSome if match switc
h try while"), |
| 518 defKeywords: words("class def object package trait type val var"), |
373 atoms: words("true false null"), | 519 atoms: words("true false null"), |
| 520 indentStatements: false, |
| 521 indentSwitch: false, |
374 hooks: { | 522 hooks: { |
375 "@": function(stream) { | 523 "@": function(stream) { |
376 stream.eatWhile(/[\w\$_]/); | 524 stream.eatWhile(/[\w\$_]/); |
377 return "meta"; | 525 return "meta"; |
| 526 }, |
| 527 '"': function(stream, state) { |
| 528 if (!stream.match('""')) return false; |
| 529 state.tokenize = tokenTripleString; |
| 530 return state.tokenize(stream, state); |
| 531 }, |
| 532 "'": function(stream) { |
| 533 stream.eatWhile(/[\w\$_\xa1-\uffff]/); |
| 534 return "atom"; |
| 535 }, |
| 536 "=": function(stream, state) { |
| 537 var cx = state.context |
| 538 if (cx.type == "}" && cx.align && stream.eat(">")) { |
| 539 state.context = new Context(cx.indented, cx.column, cx.type, cx.info,
null, cx.prev) |
| 540 return "operator" |
| 541 } else { |
| 542 return false |
| 543 } |
378 } | 544 } |
| 545 }, |
| 546 modeProps: {closeBrackets: {triples: '"'}} |
| 547 }); |
| 548 |
| 549 function tokenKotlinString(tripleString){ |
| 550 return function (stream, state) { |
| 551 var escaped = false, next, end = false; |
| 552 while (!stream.eol()) { |
| 553 if (!tripleString && !escaped && stream.match('"') ) {end = true; break;
} |
| 554 if (tripleString && stream.match('"""')) {end = true; break;} |
| 555 next = stream.next(); |
| 556 if(!escaped && next == "$" && stream.match('{')) |
| 557 stream.skipTo("}"); |
| 558 escaped = !escaped && next == "\\" && !tripleString; |
| 559 } |
| 560 if (end || !tripleString) |
| 561 state.tokenize = null; |
| 562 return "string"; |
379 } | 563 } |
| 564 } |
| 565 |
| 566 def("text/x-kotlin", { |
| 567 name: "clike", |
| 568 keywords: words( |
| 569 /*keywords*/ |
| 570 "package as typealias class interface this super val " + |
| 571 "var fun for is in This throw return " + |
| 572 "break continue object if else while do try when !in !is as? " + |
| 573 |
| 574 /*soft keywords*/ |
| 575 "file import where by get set abstract enum open inner override private pu
blic internal " + |
| 576 "protected catch finally out final vararg reified dynamic companion constr
uctor init " + |
| 577 "sealed field property receiver param sparam lateinit data inline noinline
tailrec " + |
| 578 "external annotation crossinline const operator infix" |
| 579 ), |
| 580 types: words( |
| 581 /* package java.lang */ |
| 582 "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparabl
e " + |
| 583 "Compiler Double Exception Float Integer Long Math Number Object Package P
air Process " + |
| 584 "Runtime Runnable SecurityManager Short StackTraceElement StrictMath Strin
g " + |
| 585 "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void" |
| 586 ), |
| 587 intendSwitch: false, |
| 588 indentStatements: false, |
| 589 multiLineStrings: true, |
| 590 blockKeywords: words("catch class do else finally for if where try while enu
m"), |
| 591 defKeywords: words("class val var object package interface fun"), |
| 592 atoms: words("true false null this"), |
| 593 hooks: { |
| 594 '"': function(stream, state) { |
| 595 state.tokenize = tokenKotlinString(stream.match('""')); |
| 596 return state.tokenize(stream, state); |
| 597 } |
| 598 }, |
| 599 modeProps: {closeBrackets: {triples: '"'}} |
380 }); | 600 }); |
| 601 |
381 def(["x-shader/x-vertex", "x-shader/x-fragment"], { | 602 def(["x-shader/x-vertex", "x-shader/x-fragment"], { |
382 name: "clike", | 603 name: "clike", |
383 keywords: words("float int bool void " + | 604 keywords: words("sampler1D sampler2D sampler3D samplerCube " + |
384 "vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " + | 605 "sampler1DShadow sampler2DShadow " + |
385 "mat2 mat3 mat4 " + | |
386 "sampler1D sampler2D sampler3D samplerCube " + | |
387 "sampler1DShadow sampler2DShadow" + | |
388 "const attribute uniform varying " + | 606 "const attribute uniform varying " + |
389 "break continue discard return " + | 607 "break continue discard return " + |
390 "for while do if else struct " + | 608 "for while do if else struct " + |
391 "in out inout"), | 609 "in out inout"), |
| 610 types: words("float int bool void " + |
| 611 "vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " + |
| 612 "mat2 mat3 mat4"), |
392 blockKeywords: words("for while do if else struct"), | 613 blockKeywords: words("for while do if else struct"), |
393 builtin: words("radians degrees sin cos tan asin acos atan " + | 614 builtin: words("radians degrees sin cos tan asin acos atan " + |
394 "pow exp log exp2 sqrt inversesqrt " + | 615 "pow exp log exp2 sqrt inversesqrt " + |
395 "abs sign floor ceil fract mod min max clamp mix step smoots
tep " + | 616 "abs sign floor ceil fract mod min max clamp mix step smooth
step " + |
396 "length distance dot cross normalize ftransform faceforward
" + | 617 "length distance dot cross normalize ftransform faceforward
" + |
397 "reflect refract matrixCompMult " + | 618 "reflect refract matrixCompMult " + |
398 "lessThan lessThanEqual greaterThan greaterThanEqual " + | 619 "lessThan lessThanEqual greaterThan greaterThanEqual " + |
399 "equal notEqual any all not " + | 620 "equal notEqual any all not " + |
400 "texture1D texture1DProj texture1DLod texture1DProjLod " + | 621 "texture1D texture1DProj texture1DLod texture1DProjLod " + |
401 "texture2D texture2DProj texture2DLod texture2DProjLod " + | 622 "texture2D texture2DProj texture2DLod texture2DProjLod " + |
402 "texture3D texture3DProj texture3DLod texture3DProjLod " + | 623 "texture3D texture3DProj texture3DLod texture3DProjLod " + |
403 "textureCube textureCubeLod " + | 624 "textureCube textureCubeLod " + |
404 "shadow1D shadow2D shadow1DProj shadow2DProj " + | 625 "shadow1D shadow2D shadow1DProj shadow2DProj " + |
405 "shadow1DLod shadow2DLod shadow1DProjLod shadow2DProjLod " + | 626 "shadow1DLod shadow2DLod shadow1DProjLod shadow2DProjLod " + |
406 "dFdx dFdy fwidth " + | 627 "dFdx dFdy fwidth " + |
407 "noise1 noise2 noise3 noise4"), | 628 "noise1 noise2 noise3 noise4"), |
408 atoms: words("true false " + | 629 atoms: words("true false " + |
409 "gl_FragColor gl_SecondaryColor gl_Normal gl_Vertex " + | 630 "gl_FragColor gl_SecondaryColor gl_Normal gl_Vertex " + |
410 "gl_MultiTexCoord0 gl_MultiTexCoord1 gl_MultiTexCoord2 gl_MultiT
exCoord3 " + | 631 "gl_MultiTexCoord0 gl_MultiTexCoord1 gl_MultiTexCoord2 gl_MultiT
exCoord3 " + |
411 "gl_MultiTexCoord4 gl_MultiTexCoord5 gl_MultiTexCoord6 gl_MultiT
exCoord7 " + | 632 "gl_MultiTexCoord4 gl_MultiTexCoord5 gl_MultiTexCoord6 gl_MultiT
exCoord7 " + |
412 "gl_FogCoord " + | 633 "gl_FogCoord gl_PointCoord " + |
413 "gl_Position gl_PointSize gl_ClipVertex " + | 634 "gl_Position gl_PointSize gl_ClipVertex " + |
414 "gl_FrontColor gl_BackColor gl_FrontSecondaryColor gl_BackSecond
aryColor " + | 635 "gl_FrontColor gl_BackColor gl_FrontSecondaryColor gl_BackSecond
aryColor " + |
415 "gl_TexCoord gl_FogFragCoord " + | 636 "gl_TexCoord gl_FogFragCoord " + |
416 "gl_FragCoord gl_FrontFacing " + | 637 "gl_FragCoord gl_FrontFacing " + |
417 "gl_FragColor gl_FragData gl_FragDepth " + | 638 "gl_FragData gl_FragDepth " + |
418 "gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMa
trix " + | 639 "gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMa
trix " + |
419 "gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " + | 640 "gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " + |
420 "gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse
" + | 641 "gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse
" + |
421 "gl_TexureMatrixTranspose gl_ModelViewMatrixInverseTranspose " + | 642 "gl_TexureMatrixTranspose gl_ModelViewMatrixInverseTranspose " + |
422 "gl_ProjectionMatrixInverseTranspose " + | 643 "gl_ProjectionMatrixInverseTranspose " + |
423 "gl_ModelViewProjectionMatrixInverseTranspose " + | 644 "gl_ModelViewProjectionMatrixInverseTranspose " + |
424 "gl_TextureMatrixInverseTranspose " + | 645 "gl_TextureMatrixInverseTranspose " + |
425 "gl_NormalScale gl_DepthRange gl_ClipPlane " + | 646 "gl_NormalScale gl_DepthRange gl_ClipPlane " + |
426 "gl_Point gl_FrontMaterial gl_BackMaterial gl_LightSource gl_Lig
htModel " + | 647 "gl_Point gl_FrontMaterial gl_BackMaterial gl_LightSource gl_Lig
htModel " + |
427 "gl_FrontLightModelProduct gl_BackLightModelProduct " + | 648 "gl_FrontLightModelProduct gl_BackLightModelProduct " + |
428 "gl_TextureColor gl_EyePlaneS gl_EyePlaneT gl_EyePlaneR gl_EyePl
aneQ " + | 649 "gl_TextureColor gl_EyePlaneS gl_EyePlaneT gl_EyePlaneR gl_EyePl
aneQ " + |
429 "gl_FogParameters " + | 650 "gl_FogParameters " + |
430 "gl_MaxLights gl_MaxClipPlanes gl_MaxTextureUnits gl_MaxTextureC
oords " + | 651 "gl_MaxLights gl_MaxClipPlanes gl_MaxTextureUnits gl_MaxTextureC
oords " + |
431 "gl_MaxVertexAttribs gl_MaxVertexUniformComponents gl_MaxVarying
Floats " + | 652 "gl_MaxVertexAttribs gl_MaxVertexUniformComponents gl_MaxVarying
Floats " + |
432 "gl_MaxVertexTextureImageUnits gl_MaxTextureImageUnits " + | 653 "gl_MaxVertexTextureImageUnits gl_MaxTextureImageUnits " + |
433 "gl_MaxFragmentUniformComponents gl_MaxCombineTextureImageUnits
" + | 654 "gl_MaxFragmentUniformComponents gl_MaxCombineTextureImageUnits
" + |
434 "gl_MaxDrawBuffers"), | 655 "gl_MaxDrawBuffers"), |
| 656 indentSwitch: false, |
435 hooks: {"#": cppHook}, | 657 hooks: {"#": cppHook}, |
436 modeProps: {fold: ["brace", "include"]} | 658 modeProps: {fold: ["brace", "include"]} |
437 }); | 659 }); |
438 | 660 |
| 661 def("text/x-nesc", { |
| 662 name: "clike", |
| 663 keywords: words(cKeywords + "as atomic async call command component componen
ts configuration event generic " + |
| 664 "implementation includes interface module new norace nx_stru
ct nx_union post provides " + |
| 665 "signal task uses abstract extends"), |
| 666 types: words(cTypes), |
| 667 blockKeywords: words("case do else for if switch while struct"), |
| 668 atoms: words("null true false"), |
| 669 hooks: {"#": cppHook}, |
| 670 modeProps: {fold: ["brace", "include"]} |
| 671 }); |
| 672 |
| 673 def("text/x-objectivec", { |
| 674 name: "clike", |
| 675 keywords: words(cKeywords + "inline restrict _Bool _Complex _Imaginary BOOL
Class bycopy byref id IMP in " + |
| 676 "inout nil oneway out Protocol SEL self super atomic nonatom
ic retain copy readwrite readonly"), |
| 677 types: words(cTypes), |
| 678 atoms: words("YES NO NULL NILL ON OFF true false"), |
| 679 hooks: { |
| 680 "@": function(stream) { |
| 681 stream.eatWhile(/[\w\$]/); |
| 682 return "keyword"; |
| 683 }, |
| 684 "#": cppHook, |
| 685 indent: function(_state, ctx, textAfter) { |
| 686 if (ctx.type == "statement" && /^@\w/.test(textAfter)) return ctx.indent
ed |
| 687 } |
| 688 }, |
| 689 modeProps: {fold: "brace"} |
| 690 }); |
| 691 |
| 692 def("text/x-squirrel", { |
| 693 name: "clike", |
| 694 keywords: words("base break clone continue const default delete enum extends
function in class" + |
| 695 " foreach local resume return this throw typeof yield constr
uctor instanceof static"), |
| 696 types: words(cTypes), |
| 697 blockKeywords: words("case catch class else for foreach if switch try while"
), |
| 698 defKeywords: words("function local class"), |
| 699 typeFirstDefinitions: true, |
| 700 atoms: words("true false null"), |
| 701 hooks: {"#": cppHook}, |
| 702 modeProps: {fold: ["brace", "include"]} |
| 703 }); |
| 704 |
| 705 // Ceylon Strings need to deal with interpolation |
| 706 var stringTokenizer = null; |
| 707 function tokenCeylonString(type) { |
| 708 return function(stream, state) { |
| 709 var escaped = false, next, end = false; |
| 710 while (!stream.eol()) { |
| 711 if (!escaped && stream.match('"') && |
| 712 (type == "single" || stream.match('""'))) { |
| 713 end = true; |
| 714 break; |
| 715 } |
| 716 if (!escaped && stream.match('``')) { |
| 717 stringTokenizer = tokenCeylonString(type); |
| 718 end = true; |
| 719 break; |
| 720 } |
| 721 next = stream.next(); |
| 722 escaped = type == "single" && !escaped && next == "\\"; |
| 723 } |
| 724 if (end) |
| 725 state.tokenize = null; |
| 726 return "string"; |
| 727 } |
| 728 } |
| 729 |
| 730 def("text/x-ceylon", { |
| 731 name: "clike", |
| 732 keywords: words("abstracts alias assembly assert assign break case catch cla
ss continue dynamic else" + |
| 733 " exists extends finally for function given if import in int
erface is let module new" + |
| 734 " nonempty object of out outer package return satisfies supe
r switch then this throw" + |
| 735 " try value void while"), |
| 736 types: function(word) { |
| 737 // In Ceylon all identifiers that start with an uppercase are types |
| 738 var first = word.charAt(0); |
| 739 return (first === first.toUpperCase() && first !== first.toLowerCase()); |
| 740 }, |
| 741 blockKeywords: words("case catch class dynamic else finally for function if
interface module new object switch try while"), |
| 742 defKeywords: words("class dynamic function interface module object package v
alue"), |
| 743 builtin: words("abstract actual aliased annotation by default deprecated doc
final formal late license" + |
| 744 " native optional sealed see serializable shared suppressWarn
ings tagged throws variable"), |
| 745 isPunctuationChar: /[\[\]{}\(\),;\:\.`]/, |
| 746 isOperatorChar: /[+\-*&%=<>!?|^~:\/]/, |
| 747 numberStart: /[\d#$]/, |
| 748 number: /^(?:#[\da-fA-F_]+|\$[01_]+|[\d_]+[kMGTPmunpf]?|[\d_]+\.[\d_]+(?:[eE
][-+]?\d+|[kMGTPmunpf]|)|)/i, |
| 749 multiLineStrings: true, |
| 750 typeFirstDefinitions: true, |
| 751 atoms: words("true false null larger smaller equal empty finished"), |
| 752 indentSwitch: false, |
| 753 styleDefs: false, |
| 754 hooks: { |
| 755 "@": function(stream) { |
| 756 stream.eatWhile(/[\w\$_]/); |
| 757 return "meta"; |
| 758 }, |
| 759 '"': function(stream, state) { |
| 760 state.tokenize = tokenCeylonString(stream.match('""') ? "triple" : "si
ngle"); |
| 761 return state.tokenize(stream, state); |
| 762 }, |
| 763 '`': function(stream, state) { |
| 764 if (!stringTokenizer || !stream.match('`')) return false; |
| 765 state.tokenize = stringTokenizer; |
| 766 stringTokenizer = null; |
| 767 return state.tokenize(stream, state); |
| 768 }, |
| 769 "'": function(stream) { |
| 770 stream.eatWhile(/[\w\$_\xa1-\uffff]/); |
| 771 return "atom"; |
| 772 }, |
| 773 token: function(_stream, state, style) { |
| 774 if ((style == "variable" || style == "variable-3") && |
| 775 state.prevToken == ".") { |
| 776 return "variable-2"; |
| 777 } |
| 778 } |
| 779 }, |
| 780 modeProps: { |
| 781 fold: ["brace", "import"], |
| 782 closeBrackets: {triples: '"'} |
| 783 } |
| 784 }); |
| 785 |
439 }); | 786 }); |
OLD | NEW |