PluginProbe
Smart Grid-Layout Design for Contact Form 7 / 4.5
Smart Grid-Layout Design for Contact Form 7 v4.5
4.18.0 4.17.0 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 4.0.0 4.0.1 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10 4.11 4.12 4.13 4.14 All 119 releases
← All changes | assets/codemirror/mode/javascript/javascript.js +132 -191 4.104.5 View file →
@@ -1,6 +1,6 @@
1 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 -// Distributed under an MIT license: https://codemirror.net/LICENSE
2 +// Distributed under an MIT license: http://codemirror.net/LICENSE
3 3
4 4 (function(mod) {
5 5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 6 mod(require("../../lib/codemirror"));
@@ -25,9 +25,9 @@
25 25 function kw(type) {return {type: type, style: "keyword"};}
26 26 var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"), D = kw("keyword d");
27 27 var operator = kw("operator"), atom = {type: "atom", style: "atom"};
28 28
29 - return {
29 + var jsKeywords = {
30 30 "if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
31 31 "return": D, "break": D, "continue": D, "new": kw("new"), "delete": C, "void": C, "throw": C,
32 32 "debugger": kw("debugger"), "var": kw("var"), "const": kw("var"), "let": kw("var"),
33 33 "function": kw("function"), "catch": kw("catch"),
@@ -37,8 +37,35 @@
37 37 "this": kw("this"), "class": kw("class"), "super": kw("atom"),
38 38 "yield": C, "export": kw("export"), "import": kw("import"), "extends": C,
39 39 "await": C
40 40 };
41 +
42 + // Extend the 'normal' keywords with the TypeScript language extensions
43 + if (isTS) {
44 + var type = {type: "variable", style: "type"};
45 + var tsKeywords = {
46 + // object-like things
47 + "interface": kw("class"),
48 + "implements": C,
49 + "namespace": C,
50 +
51 + // scope modifiers
52 + "public": kw("modifier"),
53 + "private": kw("modifier"),
54 + "protected": kw("modifier"),
55 + "abstract": kw("modifier"),
56 + "readonly": kw("modifier"),
57 +
58 + // types
59 + "string": type, "number": type, "boolean": type, "any": type
60 + };
61 +
62 + for (var attr in tsKeywords) {
63 + jsKeywords[attr] = tsKeywords[attr];
64 + }
65 + }
66 +
67 + return jsKeywords;
41 68 }();
42 69
43 70 var isOperatorChar = /[+\-*&%=<>!?|~^@]/;
44 71 var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
@@ -66,9 +93,9 @@
66 93 var ch = stream.next();
67 94 if (ch == '"' || ch == "'") {
68 95 state.tokenize = tokenString(ch);
69 96 return state.tokenize(stream, state);
70 - } else if (ch == "." && stream.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/)) {
97 + } else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) {
71 98 return ret("number", "number");
72 99 } else if (ch == "." && stream.match("..")) {
73 100 return ret("spread", "meta");
74 101 } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
@@ -74,12 +101,19 @@
74 101 } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
75 102 return ret(ch);
76 103 } else if (ch == "=" && stream.eat(">")) {
77 104 return ret("=>", "operator");
78 - } else if (ch == "0" && stream.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/)) {
105 + } else if (ch == "0" && stream.eat(/x/i)) {
106 + stream.eatWhile(/[\da-f]/i);
79 107 return ret("number", "number");
108 + } else if (ch == "0" && stream.eat(/o/i)) {
109 + stream.eatWhile(/[0-7]/i);
110 + return ret("number", "number");
111 + } else if (ch == "0" && stream.eat(/b/i)) {
112 + stream.eatWhile(/[01]/i);
113 + return ret("number", "number");
80 114 } else if (/\d/.test(ch)) {
81 - stream.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/);
115 + stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
82 116 return ret("number", "number");
83 117 } else if (ch == "/") {
84 118 if (stream.eat("*")) {
85 119 state.tokenize = tokenComment;
@@ -88,9 +122,9 @@
88 122 stream.skipToEnd();
89 123 return ret("comment", "comment");
90 124 } else if (expressionAllowed(stream, state, 1)) {
91 125 readRegexp(stream);
92 - stream.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/);
126 + stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/);
93 127 return ret("regexp", "string-2");
94 128 } else {
95 129 stream.eat("=");
96 130 return ret("operator", "operator", stream.current());
@@ -97,27 +131,20 @@
97 131 }
98 132 } else if (ch == "`") {
99 133 state.tokenize = tokenQuasi;
100 134 return tokenQuasi(stream, state);
101 - } else if (ch == "#" && stream.peek() == "!") {
135 + } else if (ch == "#") {
102 136 stream.skipToEnd();
103 - return ret("meta", "meta");
104 - } else if (ch == "#" && stream.eatWhile(wordRE)) {
105 - return ret("variable", "property")
106 - } else if (ch == "<" && stream.match("!--") ||
107 - (ch == "-" && stream.match("->") && !/\S/.test(stream.string.slice(0, stream.start)))) {
108 - stream.skipToEnd()
109 - return ret("comment", "comment")
137 + return ret("error", "error");
110 138 } else if (isOperatorChar.test(ch)) {
111 139 if (ch != ">" || !state.lexical || state.lexical.type != ">") {
112 140 if (stream.eat("=")) {
113 141 if (ch == "!" || ch == "=") stream.eat("=")
114 - } else if (/[<>*+\-|&?]/.test(ch)) {
142 + } else if (/[<>*+\-]/.test(ch)) {
115 143 stream.eat(ch)
116 144 if (ch == ">") stream.eat(ch)
117 145 }
118 146 }
119 - if (ch == "?" && stream.eat(".")) return ret(".")
120 147 return ret("operator", "operator", stream.current());
121 148 } else if (wordRE.test(ch)) {
122 149 stream.eatWhile(wordRE);
123 150 var word = stream.current()
@@ -125,9 +152,9 @@
125 152 if (keywords.propertyIsEnumerable(word)) {
126 153 var kw = keywords[word]
127 154 return ret(kw.type, kw.style, word)
128 155 }
129 - if (word == "async" && stream.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/, false))
156 + if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\(\w]/, false))
130 157 return ret("async", "keyword", word)
131 158 }
132 159 return ret("variable", "variable", word)
133 160 }
@@ -201,14 +228,10 @@
201 228 } else if (bracket >= 3 && bracket < 6) {
202 229 ++depth;
203 230 } else if (wordRE.test(ch)) {
204 231 sawSomething = true;
205 - } else if (/["'\/`]/.test(ch)) {
206 - for (;; --pos) {
207 - if (pos == 0) return
208 - var next = stream.string.charAt(pos - 1)
209 - if (next == ch && stream.string.charAt(pos - 2) != "\\") { pos--; break }
210 - }
232 + } else if (/["'\/]/.test(ch)) {
233 + return;
211 234 } else if (sawSomething && !depth) {
212 235 ++pos;
213 236 break;
214 237 }
@@ -268,70 +291,37 @@
268 291 function cont() {
269 292 pass.apply(null, arguments);
270 293 return true;
271 294 }
272 - function inList(name, list) {
273 - for (var v = list; v; v = v.next) if (v.name == name) return true
274 - return false;
275 - }
276 295 function register(varname) {
296 + function inList(list) {
297 + for (var v = list; v; v = v.next)
298 + if (v.name == varname) return true;
299 + return false;
300 + }
277 301 var state = cx.state;
278 302 cx.marked = "def";
279 303 if (state.context) {
280 - if (state.lexical.info == "var" && state.context && state.context.block) {
281 - // FIXME function decls are also not block scoped
282 - var newContext = registerVarScoped(varname, state.context)
283 - if (newContext != null) {
284 - state.context = newContext
285 - return
286 - }
287 - } else if (!inList(varname, state.localVars)) {
288 - state.localVars = new Var(varname, state.localVars)
289 - return
290 - }
291 - }
292 - // Fall through means this is global
293 - if (parserConfig.globalVars && !inList(varname, state.globalVars))
294 - state.globalVars = new Var(varname, state.globalVars)
295 - }
296 - function registerVarScoped(varname, context) {
297 - if (!context) {
298 - return null
299 - } else if (context.block) {
300 - var inner = registerVarScoped(varname, context.prev)
301 - if (!inner) return null
302 - if (inner == context.prev) return context
303 - return new Context(inner, context.vars, true)
304 - } else if (inList(varname, context.vars)) {
305 - return context
304 + if (inList(state.localVars)) return;
305 + state.localVars = {name: varname, next: state.localVars};
306 306 } else {
307 - return new Context(context.prev, new Var(varname, context.vars), false)
307 + if (inList(state.globalVars)) return;
308 + if (parserConfig.globalVars)
309 + state.globalVars = {name: varname, next: state.globalVars};
308 310 }
309 311 }
310 312
311 - function isModifier(name) {
312 - return name == "public" || name == "private" || name == "protected" || name == "abstract" || name == "readonly"
313 - }
314 -
315 313 // Combinators
316 314
317 - function Context(prev, vars, block) { this.prev = prev; this.vars = vars; this.block = block }
318 - function Var(name, next) { this.name = name; this.next = next }
319 -
320 - var defaultVars = new Var("this", new Var("arguments", null))
315 + var defaultVars = {name: "this", next: {name: "arguments"}};
321 316 function pushcontext() {
322 - cx.state.context = new Context(cx.state.context, cx.state.localVars, false)
323 - cx.state.localVars = defaultVars
317 + cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
318 + cx.state.localVars = defaultVars;
324 319 }
325 - function pushblockcontext() {
326 - cx.state.context = new Context(cx.state.context, cx.state.localVars, true)
327 - cx.state.localVars = null
328 - }
329 320 function popcontext() {
330 - cx.state.localVars = cx.state.context.vars
331 - cx.state.context = cx.state.context.prev
321 + cx.state.localVars = cx.state.context.vars;
322 + cx.state.context = cx.state.context.prev;
332 323 }
333 - popcontext.lex = true
334 324 function pushlex(type, info) {
335 325 var result = function() {
336 326 var state = cx.state, indent = state.indented;
337 327 if (state.lexical.type == "stat") indent = state.lexical.indented;
@@ -354,9 +344,9 @@
354 344
355 345 function expect(wanted) {
356 346 function exp(type) {
357 347 if (type == wanted) return cont();
358 - else if (wanted == ";" || type == "}" || type == ")" || type == "]") return pass();
348 + else if (wanted == ";") return pass();
359 349 else return cont(exp);
360 350 };
361 351 return exp;
362 352 }
@@ -361,14 +351,14 @@
361 351 return exp;
362 352 }
363 353
364 354 function statement(type, value) {
365 - if (type == "var") return cont(pushlex("vardef", value), vardef, expect(";"), poplex);
355 + if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex);
366 356 if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
367 357 if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
368 358 if (type == "keyword d") return cx.stream.match(/^\s*$/, false) ? cont() : cont(pushlex("stat"), maybeexpression, expect(";"), poplex);
369 359 if (type == "debugger") return cont(expect(";"));
370 - if (type == "{") return cont(pushlex("}"), pushblockcontext, block, poplex, popcontext);
360 + if (type == "{") return cont(pushlex("}"), block, poplex);
371 361 if (type == ";") return cont();
372 362 if (type == "if") {
373 363 if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
374 364 cx.state.cc.pop()();
@@ -375,36 +365,29 @@
375 365 return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
376 366 }
377 367 if (type == "function") return cont(functiondef);
378 368 if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
379 - if (type == "class" || (isTS && value == "interface")) {
380 - cx.marked = "keyword"
381 - return cont(pushlex("form", type == "class" ? type : value), className, poplex)
382 - }
383 369 if (type == "variable") {
384 - if (isTS && value == "declare") {
370 + if (isTS && value == "type") {
385 371 cx.marked = "keyword"
372 + return cont(typeexpr, expect("operator"), typeexpr, expect(";"));
373 + } else if (isTS && value == "declare") {
374 + cx.marked = "keyword"
386 375 return cont(statement)
387 - } else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) {
376 + } else if (isTS && (value == "module" || value == "enum") && cx.stream.match(/^\s*\w/, false)) {
388 377 cx.marked = "keyword"
389 - if (value == "enum") return cont(enumdef);
390 - else if (value == "type") return cont(typename, expect("operator"), typeexpr, expect(";"));
391 - else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex)
392 - } else if (isTS && value == "namespace") {
393 - cx.marked = "keyword"
394 - return cont(pushlex("form"), expression, statement, poplex)
395 - } else if (isTS && value == "abstract") {
396 - cx.marked = "keyword"
397 - return cont(statement)
378 + return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex)
398 379 } else {
399 380 return cont(pushlex("stat"), maybelabel);
400 381 }
401 382 }
402 - if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"), pushblockcontext,
403 - block, poplex, poplex, popcontext);
383 + if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"),
384 + block, poplex, poplex);
404 385 if (type == "case") return cont(expression, expect(":"));
405 386 if (type == "default") return cont(expect(":"));
406 - if (type == "catch") return cont(pushlex("form"), pushcontext, maybeCatchBinding, statement, poplex, popcontext);
387 + if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
388 + statement, poplex, popcontext);
389 + if (type == "class") return cont(pushlex("form"), className, poplex);
407 390 if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
408 391 if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
409 392 if (type == "async") return cont(statement)
410 393 if (value == "@") return cont(expression, statement)
@@ -409,22 +392,19 @@
409 392 if (type == "async") return cont(statement)
410 393 if (value == "@") return cont(expression, statement)
411 394 return pass(pushlex("stat"), expression, expect(";"), poplex);
412 395 }
413 - function maybeCatchBinding(type) {
414 - if (type == "(") return cont(funarg, expect(")"))
396 + function expression(type) {
397 + return expressionInner(type, false);
415 398 }
416 - function expression(type, value) {
417 - return expressionInner(type, value, false);
399 + function expressionNoComma(type) {
400 + return expressionInner(type, true);
418 401 }
419 - function expressionNoComma(type, value) {
420 - return expressionInner(type, value, true);
421 - }
422 402 function parenExpr(type) {
423 403 if (type != "(") return pass()
424 - return cont(pushlex(")"), maybeexpression, expect(")"), poplex)
404 + return cont(pushlex(")"), expression, expect(")"), poplex)
425 405 }
426 - function expressionInner(type, value, noComma) {
406 + function expressionInner(type, noComma) {
427 407 if (cx.state.fatArrowAt == cx.stream.start) {
428 408 var body = noComma ? arrowBodyNoComma : arrowBody;
429 409 if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, expect("=>"), body, popcontext);
430 410 else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
@@ -432,9 +412,9 @@
432 412
433 413 var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
434 414 if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
435 415 if (type == "function") return cont(functiondef, maybeop);
436 - if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), classExpression, poplex); }
416 + if (type == "class") return cont(pushlex("form"), classExpression, poplex);
437 417 if (type == "keyword c" || type == "async") return cont(noComma ? expressionNoComma : expression);
438 418 if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
439 419 if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
440 420 if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
@@ -440,9 +420,8 @@
440 420 if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
441 421 if (type == "{") return contCommasep(objprop, "}", null, maybeop);
442 422 if (type == "quasi") return pass(quasi, maybeop);
443 423 if (type == "new") return cont(maybeTarget(noComma));
444 - if (type == "import") return cont(expression);
445 424 return cont();
446 425 }
447 426 function maybeexpression(type) {
448 427 if (type.match(/[;\}\)\],]/)) return pass();
@@ -449,9 +428,9 @@
449 428 return pass(expression);
450 429 }
451 430
452 431 function maybeoperatorComma(type, value) {
453 - if (type == ",") return cont(maybeexpression);
432 + if (type == ",") return cont(expression);
454 433 return maybeoperatorNoComma(type, value, false);
455 434 }
456 435 function maybeoperatorNoComma(type, value, noComma) {
457 436 var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
@@ -458,9 +437,9 @@
458 437 var expr = noComma == false ? expression : expressionNoComma;
459 438 if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
460 439 if (type == "operator") {
461 440 if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me);
462 - if (isTS && value == "<" && cx.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/, false))
441 + if (isTS && value == "<" && cx.stream.match(/^([^>]|<.*?>)*>\s*\(/, false))
463 442 return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me);
464 443 if (value == "?") return cont(expression, expect(":"), expr);
465 444 return cont(expr);
466 445 }
@@ -531,13 +510,12 @@
531 510 cx.marked = jsonldMode ? "property" : (cx.style + " property");
532 511 return cont(afterprop);
533 512 } else if (type == "jsonld-keyword") {
534 513 return cont(afterprop);
535 - } else if (isTS && isModifier(value)) {
536 - cx.marked = "keyword"
514 + } else if (type == "modifier") {
537 515 return cont(objprop)
538 516 } else if (type == "[") {
539 - return cont(expression, maybetype, expect("]"), afterprop);
517 + return cont(expression, expect("]"), afterprop);
540 518 } else if (type == "spread") {
541 519 return cont(expressionNoComma, afterprop);
542 520 } else if (value == "*") {
543 521 cx.marked = "keyword";
@@ -565,9 +543,8 @@
565 543 return pass(what)
566 544 }, proceed);
567 545 }
568 546 if (type == end || value == end) return cont();
569 - if (sep && sep.indexOf(";") > -1) return pass(what)
570 547 return cont(expect(end));
571 548 }
572 549 return function(type, value) {
573 550 if (type == end || value == end) return cont();
@@ -588,11 +565,8 @@
588 565 if (type == ":") return cont(typeexpr);
589 566 if (value == "?") return cont(maybetype);
590 567 }
591 568 }
592 - function maybetypeOrIn(type, value) {
593 - if (isTS && (type == ":" || value == "in")) return cont(typeexpr)
594 - }
595 569 function mayberettype(type) {
596 570 if (isTS && type == ":") {
597 571 if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr)
598 572 else return cont(typeexpr)
@@ -604,22 +578,21 @@
604 578 return cont()
605 579 }
606 580 }
607 581 function typeexpr(type, value) {
608 - if (value == "keyof" || value == "typeof" || value == "infer") {
609 - cx.marked = "keyword"
610 - return cont(value == "typeof" ? expressionNoComma : typeexpr)
611 - }
612 582 if (type == "variable" || value == "void") {
613 - cx.marked = "type"
614 - return cont(afterType)
583 + if (value == "keyof") {
584 + cx.marked = "keyword"
585 + return cont(typeexpr)
586 + } else {
587 + cx.marked = "type"
588 + return cont(afterType)
589 + }
615 590 }
616 - if (value == "|" || value == "&") return cont(typeexpr)
617 591 if (type == "string" || type == "number" || type == "atom") return cont(afterType);
618 592 if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)
619 593 if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType)
620 - if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType)
621 - if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr)
594 + if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
622 595 }
623 596 function maybeReturnType(type) {
624 597 if (type == "=>") return cont(typeexpr)
625 598 }
@@ -626,30 +599,25 @@
626 599 function typeprop(type, value) {
627 600 if (type == "variable" || cx.style == "keyword") {
628 601 cx.marked = "property"
629 602 return cont(typeprop)
630 - } else if (value == "?" || type == "number" || type == "string") {
603 + } else if (value == "?") {
631 604 return cont(typeprop)
632 605 } else if (type == ":") {
633 606 return cont(typeexpr)
634 607 } else if (type == "[") {
635 - return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop)
636 - } else if (type == "(") {
637 - return pass(functiondecl, typeprop)
608 + return cont(expression, maybetype, expect("]"), typeprop)
638 609 }
639 610 }
640 - function typearg(type, value) {
641 - if (type == "variable" && cx.stream.match(/^\s*[?:]/, false) || value == "?") return cont(typearg)
642 - if (type == ":") return cont(typeexpr)
643 - if (type == "spread") return cont(typearg)
644 - return pass(typeexpr)
611 + function typearg(type) {
612 + if (type == "variable") return cont(typearg)
613 + else if (type == ":") return cont(typeexpr)
645 614 }
646 615 function afterType(type, value) {
647 616 if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
648 - if (value == "|" || type == "." || value == "&") return cont(typeexpr)
649 - if (type == "[") return cont(typeexpr, expect("]"), afterType)
650 - if (value == "extends" || value == "implements") { cx.marked = "keyword"; return cont(typeexpr) }
651 - if (value == "?") return cont(typeexpr, expect(":"), typeexpr)
617 + if (value == "|" || type == ".") return cont(typeexpr)
618 + if (type == "[") return cont(expect("]"), afterType)
619 + if (value == "extends") return cont(typeexpr)
652 620 }
653 621 function maybeTypeArgs(_, value) {
654 622 if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
655 623 }
@@ -658,17 +626,16 @@
658 626 }
659 627 function maybeTypeDefault(_, value) {
660 628 if (value == "=") return cont(typeexpr)
661 629 }
662 - function vardef(_, value) {
663 - if (value == "enum") {cx.marked = "keyword"; return cont(enumdef)}
630 + function vardef() {
664 631 return pass(pattern, maybetype, maybeAssign, vardefCont);
665 632 }
666 633 function pattern(type, value) {
667 - if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(pattern) }
634 + if (type == "modifier") return cont(pattern)
668 635 if (type == "variable") { register(value); return cont(); }
669 636 if (type == "spread") return cont(pattern);
670 - if (type == "[") return contCommasep(eltpattern, "]");
637 + if (type == "[") return contCommasep(pattern, "]");
671 638 if (type == "{") return contCommasep(proppattern, "}");
672 639 }
673 640 function proppattern(type, value) {
674 641 if (type == "variable" && !cx.stream.match(/^\s*:/, false)) {
@@ -677,14 +644,10 @@
677 644 }
678 645 if (type == "variable") cx.marked = "property";
679 646 if (type == "spread") return cont(pattern);
680 647 if (type == "}") return pass();
681 - if (type == "[") return cont(expression, expect(']'), expect(':'), proppattern);
682 648 return cont(expect(":"), pattern, maybeAssign);
683 649 }
684 - function eltpattern() {
685 - return pass(pattern, maybeAssign)
686 - }
687 650 function maybeAssign(_type, value) {
688 651 if (value == "=") return cont(expressionNoComma);
689 652 }
690 653 function vardefCont(type) {
@@ -692,23 +655,29 @@
692 655 }
693 656 function maybeelse(type, value) {
694 657 if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
695 658 }
696 - function forspec(type, value) {
697 - if (value == "await") return cont(forspec);
698 - if (type == "(") return cont(pushlex(")"), forspec1, poplex);
659 + function forspec(type) {
660 + if (type == "(") return cont(pushlex(")"), forspec1, expect(")"), poplex);
699 661 }
700 662 function forspec1(type) {
701 - if (type == "var") return cont(vardef, forspec2);
702 - if (type == "variable") return cont(forspec2);
703 - return pass(forspec2)
663 + if (type == "var") return cont(vardef, expect(";"), forspec2);
664 + if (type == ";") return cont(forspec2);
665 + if (type == "variable") return cont(formaybeinof);
666 + return pass(expression, expect(";"), forspec2);
704 667 }
668 + function formaybeinof(_type, value) {
669 + if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
670 + return cont(maybeoperatorComma, forspec2);
671 + }
705 672 function forspec2(type, value) {
706 - if (type == ")") return cont()
707 - if (type == ";") return cont(forspec2)
708 - if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression, forspec2) }
709 - return pass(expression, forspec2)
673 + if (type == ";") return cont(forspec3);
674 + if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
675 + return pass(expression, expect(";"), forspec3);
710 676 }
677 + function forspec3(type) {
678 + if (type != ")") cont(expression);
679 + }
711 680 function functiondef(type, value) {
712 681 if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
713 682 if (type == "variable") {register(value); return cont(functiondef);}
714 683 if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext);
@@ -713,27 +682,11 @@
713 682 if (type == "variable") {register(value); return cont(functiondef);}
714 683 if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext);
715 684 if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef)
716 685 }
717 - function functiondecl(type, value) {
718 - if (value == "*") {cx.marked = "keyword"; return cont(functiondecl);}
719 - if (type == "variable") {register(value); return cont(functiondecl);}
720 - if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, popcontext);
721 - if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondecl)
722 - }
723 - function typename(type, value) {
724 - if (type == "keyword" || type == "variable") {
725 - cx.marked = "type"
726 - return cont(typename)
727 - } else if (value == "<") {
728 - return cont(pushlex(">"), commasep(typeparam, ">"), poplex)
729 - }
730 - }
731 686 function funarg(type, value) {
732 687 if (value == "@") cont(expression, funarg)
733 - if (type == "spread") return cont(funarg);
734 - if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(funarg); }
735 - if (isTS && type == "this") return cont(maybetype, maybeAssign)
688 + if (type == "spread" || type == "modifier") return cont(funarg);
736 689 return pass(pattern, maybetype, maybeAssign);
737 690 }
738 691 function classExpression(type, value) {
739 692 // Class expressions may have an optional name.
@@ -744,18 +697,16 @@
744 697 if (type == "variable") {register(value); return cont(classNameAfter);}
745 698 }
746 699 function classNameAfter(type, value) {
747 700 if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, classNameAfter)
748 - if (value == "extends" || value == "implements" || (isTS && type == ",")) {
749 - if (value == "implements") cx.marked = "keyword";
701 + if (value == "extends" || value == "implements" || (isTS && type == ","))
750 702 return cont(isTS ? typeexpr : expression, classNameAfter);
751 - }
752 703 if (type == "{") return cont(pushlex("}"), classBody, poplex);
753 704 }
754 705 function classBody(type, value) {
755 - if (type == "async" ||
706 + if (type == "modifier" || type == "async" ||
756 707 (type == "variable" &&
757 - (value == "static" || value == "get" || value == "set" || (isTS && isModifier(value))) &&
708 + (value == "static" || value == "get" || value == "set") &&
758 709 cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) {
759 710 cx.marked = "keyword";
760 711 return cont(classBody);
761 712 }
@@ -760,19 +711,17 @@
760 711 return cont(classBody);
761 712 }
762 713 if (type == "variable" || cx.style == "keyword") {
763 714 cx.marked = "property";
764 - return cont(classfield, classBody);
715 + return cont(isTS ? classfield : functiondef, classBody);
765 716 }
766 - if (type == "number" || type == "string") return cont(classfield, classBody);
767 717 if (type == "[")
768 - return cont(expression, maybetype, expect("]"), classfield, classBody)
718 + return cont(expression, expect("]"), isTS ? classfield : functiondef, classBody)
769 719 if (value == "*") {
770 720 cx.marked = "keyword";
771 721 return cont(classBody);
772 722 }
773 - if (isTS && type == "(") return pass(functiondecl, classBody)
774 - if (type == ";" || type == ",") return cont(classBody);
723 + if (type == ";") return cont(classBody);
775 724 if (type == "}") return cont();
776 725 if (value == "@") return cont(expression, classBody)
777 726 }
778 727 function classfield(type, value) {
@@ -778,10 +727,9 @@
778 727 function classfield(type, value) {
779 728 if (value == "?") return cont(classfield)
780 729 if (type == ":") return cont(typeexpr, maybeAssign)
781 730 if (value == "=") return cont(expressionNoComma)
782 - var context = cx.state.lexical.prev, isInterface = context && context.info == "interface"
783 - return pass(isInterface ? functiondecl : functiondef)
731 + return pass(functiondef)
784 732 }
785 733 function afterExport(type, value) {
786 734 if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
787 735 if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
@@ -793,9 +741,8 @@
793 741 if (type == "variable") return pass(expressionNoComma, exportField);
794 742 }
795 743 function afterImport(type) {
796 744 if (type == "string") return cont();
797 - if (type == "(") return pass(expression);
798 745 return pass(importSpec, maybeMoreImports, maybeFrom);
799 746 }
800 747 function importSpec(type, value) {
801 748 if (type == "{") return contCommasep(importSpec, "}");
@@ -815,14 +762,8 @@
815 762 function arrayLiteral(type) {
816 763 if (type == "]") return cont();
817 764 return pass(commasep(expressionNoComma, "]"));
818 765 }
819 - function enumdef() {
820 - return pass(pushlex("form"), pattern, expect("{"), pushlex("}"), commasep(enummember, "}"), poplex, poplex)
821 - }
822 - function enummember() {
823 - return pass(pattern, maybeAssign);
824 - }
825 766
826 767 function isContinuedStatement(state, textAfter) {
827 768 return state.lastType == "operator" || state.lastType == "," ||
828 769 isOperatorChar.test(textAfter.charAt(0)) ||
@@ -844,9 +785,9 @@
844 785 lastType: "sof",
845 786 cc: [],
846 787 lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
847 788 localVars: parserConfig.localVars,
848 - context: parserConfig.localVars && new Context(null, null, false),
789 + context: parserConfig.localVars && {vars: parserConfig.localVars},
849 790 indented: basecolumn || 0
850 791 };
851 792 if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
852 793 state.globalVars = parserConfig.globalVars;
@@ -867,9 +808,9 @@
867 808 return parseJS(state, style, type, content, stream);
868 809 },
869 810
870 811 indent: function(state, textAfter) {
871 - if (state.tokenize == tokenComment || state.tokenize == tokenQuasi) return CodeMirror.Pass;
812 + if (state.tokenize == tokenComment) return CodeMirror.Pass;
872 813 if (state.tokenize != tokenBase) return 0;
873 814 var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top
874 815 // Kludge to prevent 'maybelse' from blocking lexical scope pops
875 816 if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
@@ -885,9 +826,9 @@
885 826 if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
886 827 lexical = lexical.prev;
887 828 var type = lexical.type, closing = firstChar == type;
888 829
889 - if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info.length + 1 : 0);
830 + if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info + 1 : 0);
890 831 else if (type == "form" && firstChar == "{") return lexical.indented;
891 832 else if (type == "form") return lexical.indented + indentUnit;
892 833 else if (type == "stat")
893 834 return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0);