@vuetify/vue-repl 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vue-repl.js CHANGED
@@ -11208,961 +11208,970 @@ const codemirror = '';
11208
11208
 
11209
11209
  var javascript = {exports: {}};
11210
11210
 
11211
- (function (module, exports) {
11212
- // CodeMirror, copyright (c) by Marijn Haverbeke and others
11213
- // Distributed under an MIT license: https://codemirror.net/LICENSE
11211
+ var hasRequiredJavascript;
11214
11212
 
11215
- (function(mod) {
11216
- mod(requireCodemirror());
11217
- })(function(CodeMirror) {
11213
+ function requireJavascript () {
11214
+ if (hasRequiredJavascript) return javascript.exports;
11215
+ hasRequiredJavascript = 1;
11216
+ (function (module, exports) {
11217
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
11218
+ // Distributed under an MIT license: https://codemirror.net/LICENSE
11218
11219
 
11219
- CodeMirror.defineMode("javascript", function(config, parserConfig) {
11220
- var indentUnit = config.indentUnit;
11221
- var statementIndent = parserConfig.statementIndent;
11222
- var jsonldMode = parserConfig.jsonld;
11223
- var jsonMode = parserConfig.json || jsonldMode;
11224
- var trackScope = parserConfig.trackScope !== false;
11225
- var isTS = parserConfig.typescript;
11226
- var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
11220
+ (function(mod) {
11221
+ mod(requireCodemirror());
11222
+ })(function(CodeMirror) {
11227
11223
 
11228
- // Tokenizer
11224
+ CodeMirror.defineMode("javascript", function(config, parserConfig) {
11225
+ var indentUnit = config.indentUnit;
11226
+ var statementIndent = parserConfig.statementIndent;
11227
+ var jsonldMode = parserConfig.jsonld;
11228
+ var jsonMode = parserConfig.json || jsonldMode;
11229
+ var trackScope = parserConfig.trackScope !== false;
11230
+ var isTS = parserConfig.typescript;
11231
+ var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
11229
11232
 
11230
- var keywords = function(){
11231
- function kw(type) {return {type: type, style: "keyword"};}
11232
- var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"), D = kw("keyword d");
11233
- var operator = kw("operator"), atom = {type: "atom", style: "atom"};
11233
+ // Tokenizer
11234
11234
 
11235
- return {
11236
- "if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
11237
- "return": D, "break": D, "continue": D, "new": kw("new"), "delete": C, "void": C, "throw": C,
11238
- "debugger": kw("debugger"), "var": kw("var"), "const": kw("var"), "let": kw("var"),
11239
- "function": kw("function"), "catch": kw("catch"),
11240
- "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
11241
- "in": operator, "typeof": operator, "instanceof": operator,
11242
- "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
11243
- "this": kw("this"), "class": kw("class"), "super": kw("atom"),
11244
- "yield": C, "export": kw("export"), "import": kw("import"), "extends": C,
11245
- "await": C
11246
- };
11247
- }();
11248
-
11249
- var isOperatorChar = /[+\-*&%=<>!?|~^@]/;
11250
- var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
11251
-
11252
- function readRegexp(stream) {
11253
- var escaped = false, next, inSet = false;
11254
- while ((next = stream.next()) != null) {
11255
- if (!escaped) {
11256
- if (next == "/" && !inSet) return;
11257
- if (next == "[") inSet = true;
11258
- else if (inSet && next == "]") inSet = false;
11259
- }
11260
- escaped = !escaped && next == "\\";
11261
- }
11262
- }
11235
+ var keywords = function(){
11236
+ function kw(type) {return {type: type, style: "keyword"};}
11237
+ var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"), D = kw("keyword d");
11238
+ var operator = kw("operator"), atom = {type: "atom", style: "atom"};
11263
11239
 
11264
- // Used as scratch variables to communicate multiple values without
11265
- // consing up tons of objects.
11266
- var type, content;
11267
- function ret(tp, style, cont) {
11268
- type = tp; content = cont;
11269
- return style;
11270
- }
11271
- function tokenBase(stream, state) {
11272
- var ch = stream.next();
11273
- if (ch == '"' || ch == "'") {
11274
- state.tokenize = tokenString(ch);
11275
- return state.tokenize(stream, state);
11276
- } else if (ch == "." && stream.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/)) {
11277
- return ret("number", "number");
11278
- } else if (ch == "." && stream.match("..")) {
11279
- return ret("spread", "meta");
11280
- } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
11281
- return ret(ch);
11282
- } else if (ch == "=" && stream.eat(">")) {
11283
- return ret("=>", "operator");
11284
- } else if (ch == "0" && stream.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/)) {
11285
- return ret("number", "number");
11286
- } else if (/\d/.test(ch)) {
11287
- stream.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/);
11288
- return ret("number", "number");
11289
- } else if (ch == "/") {
11290
- if (stream.eat("*")) {
11291
- state.tokenize = tokenComment;
11292
- return tokenComment(stream, state);
11293
- } else if (stream.eat("/")) {
11294
- stream.skipToEnd();
11295
- return ret("comment", "comment");
11296
- } else if (expressionAllowed(stream, state, 1)) {
11297
- readRegexp(stream);
11298
- stream.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/);
11299
- return ret("regexp", "string-2");
11300
- } else {
11301
- stream.eat("=");
11302
- return ret("operator", "operator", stream.current());
11303
- }
11304
- } else if (ch == "`") {
11305
- state.tokenize = tokenQuasi;
11306
- return tokenQuasi(stream, state);
11307
- } else if (ch == "#" && stream.peek() == "!") {
11308
- stream.skipToEnd();
11309
- return ret("meta", "meta");
11310
- } else if (ch == "#" && stream.eatWhile(wordRE)) {
11311
- return ret("variable", "property")
11312
- } else if (ch == "<" && stream.match("!--") ||
11313
- (ch == "-" && stream.match("->") && !/\S/.test(stream.string.slice(0, stream.start)))) {
11314
- stream.skipToEnd();
11315
- return ret("comment", "comment")
11316
- } else if (isOperatorChar.test(ch)) {
11317
- if (ch != ">" || !state.lexical || state.lexical.type != ">") {
11318
- if (stream.eat("=")) {
11319
- if (ch == "!" || ch == "=") stream.eat("=");
11320
- } else if (/[<>*+\-|&?]/.test(ch)) {
11321
- stream.eat(ch);
11322
- if (ch == ">") stream.eat(ch);
11323
- }
11324
- }
11325
- if (ch == "?" && stream.eat(".")) return ret(".")
11326
- return ret("operator", "operator", stream.current());
11327
- } else if (wordRE.test(ch)) {
11328
- stream.eatWhile(wordRE);
11329
- var word = stream.current();
11330
- if (state.lastType != ".") {
11331
- if (keywords.propertyIsEnumerable(word)) {
11332
- var kw = keywords[word];
11333
- return ret(kw.type, kw.style, word)
11334
- }
11335
- if (word == "async" && stream.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/, false))
11336
- return ret("async", "keyword", word)
11337
- }
11338
- return ret("variable", "variable", word)
11339
- }
11340
- }
11341
-
11342
- function tokenString(quote) {
11343
- return function(stream, state) {
11344
- var escaped = false, next;
11345
- if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){
11346
- state.tokenize = tokenBase;
11347
- return ret("jsonld-keyword", "meta");
11348
- }
11349
- while ((next = stream.next()) != null) {
11350
- if (next == quote && !escaped) break;
11351
- escaped = !escaped && next == "\\";
11352
- }
11353
- if (!escaped) state.tokenize = tokenBase;
11354
- return ret("string", "string");
11355
- };
11356
- }
11240
+ return {
11241
+ "if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
11242
+ "return": D, "break": D, "continue": D, "new": kw("new"), "delete": C, "void": C, "throw": C,
11243
+ "debugger": kw("debugger"), "var": kw("var"), "const": kw("var"), "let": kw("var"),
11244
+ "function": kw("function"), "catch": kw("catch"),
11245
+ "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
11246
+ "in": operator, "typeof": operator, "instanceof": operator,
11247
+ "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
11248
+ "this": kw("this"), "class": kw("class"), "super": kw("atom"),
11249
+ "yield": C, "export": kw("export"), "import": kw("import"), "extends": C,
11250
+ "await": C
11251
+ };
11252
+ }();
11357
11253
 
11358
- function tokenComment(stream, state) {
11359
- var maybeEnd = false, ch;
11360
- while (ch = stream.next()) {
11361
- if (ch == "/" && maybeEnd) {
11362
- state.tokenize = tokenBase;
11363
- break;
11364
- }
11365
- maybeEnd = (ch == "*");
11366
- }
11367
- return ret("comment", "comment");
11368
- }
11254
+ var isOperatorChar = /[+\-*&%=<>!?|~^@]/;
11255
+ var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
11369
11256
 
11370
- function tokenQuasi(stream, state) {
11371
- var escaped = false, next;
11372
- while ((next = stream.next()) != null) {
11373
- if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) {
11374
- state.tokenize = tokenBase;
11375
- break;
11376
- }
11377
- escaped = !escaped && next == "\\";
11378
- }
11379
- return ret("quasi", "string-2", stream.current());
11380
- }
11257
+ function readRegexp(stream) {
11258
+ var escaped = false, next, inSet = false;
11259
+ while ((next = stream.next()) != null) {
11260
+ if (!escaped) {
11261
+ if (next == "/" && !inSet) return;
11262
+ if (next == "[") inSet = true;
11263
+ else if (inSet && next == "]") inSet = false;
11264
+ }
11265
+ escaped = !escaped && next == "\\";
11266
+ }
11267
+ }
11381
11268
 
11382
- var brackets = "([{}])";
11383
- // This is a crude lookahead trick to try and notice that we're
11384
- // parsing the argument patterns for a fat-arrow function before we
11385
- // actually hit the arrow token. It only works if the arrow is on
11386
- // the same line as the arguments and there's no strange noise
11387
- // (comments) in between. Fallback is to only notice when we hit the
11388
- // arrow, and not declare the arguments as locals for the arrow
11389
- // body.
11390
- function findFatArrow(stream, state) {
11391
- if (state.fatArrowAt) state.fatArrowAt = null;
11392
- var arrow = stream.string.indexOf("=>", stream.start);
11393
- if (arrow < 0) return;
11394
-
11395
- if (isTS) { // Try to skip TypeScript return type declarations after the arguments
11396
- var m = /:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(stream.string.slice(stream.start, arrow));
11397
- if (m) arrow = m.index;
11398
- }
11269
+ // Used as scratch variables to communicate multiple values without
11270
+ // consing up tons of objects.
11271
+ var type, content;
11272
+ function ret(tp, style, cont) {
11273
+ type = tp; content = cont;
11274
+ return style;
11275
+ }
11276
+ function tokenBase(stream, state) {
11277
+ var ch = stream.next();
11278
+ if (ch == '"' || ch == "'") {
11279
+ state.tokenize = tokenString(ch);
11280
+ return state.tokenize(stream, state);
11281
+ } else if (ch == "." && stream.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/)) {
11282
+ return ret("number", "number");
11283
+ } else if (ch == "." && stream.match("..")) {
11284
+ return ret("spread", "meta");
11285
+ } else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
11286
+ return ret(ch);
11287
+ } else if (ch == "=" && stream.eat(">")) {
11288
+ return ret("=>", "operator");
11289
+ } else if (ch == "0" && stream.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/)) {
11290
+ return ret("number", "number");
11291
+ } else if (/\d/.test(ch)) {
11292
+ stream.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/);
11293
+ return ret("number", "number");
11294
+ } else if (ch == "/") {
11295
+ if (stream.eat("*")) {
11296
+ state.tokenize = tokenComment;
11297
+ return tokenComment(stream, state);
11298
+ } else if (stream.eat("/")) {
11299
+ stream.skipToEnd();
11300
+ return ret("comment", "comment");
11301
+ } else if (expressionAllowed(stream, state, 1)) {
11302
+ readRegexp(stream);
11303
+ stream.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/);
11304
+ return ret("regexp", "string-2");
11305
+ } else {
11306
+ stream.eat("=");
11307
+ return ret("operator", "operator", stream.current());
11308
+ }
11309
+ } else if (ch == "`") {
11310
+ state.tokenize = tokenQuasi;
11311
+ return tokenQuasi(stream, state);
11312
+ } else if (ch == "#" && stream.peek() == "!") {
11313
+ stream.skipToEnd();
11314
+ return ret("meta", "meta");
11315
+ } else if (ch == "#" && stream.eatWhile(wordRE)) {
11316
+ return ret("variable", "property")
11317
+ } else if (ch == "<" && stream.match("!--") ||
11318
+ (ch == "-" && stream.match("->") && !/\S/.test(stream.string.slice(0, stream.start)))) {
11319
+ stream.skipToEnd();
11320
+ return ret("comment", "comment")
11321
+ } else if (isOperatorChar.test(ch)) {
11322
+ if (ch != ">" || !state.lexical || state.lexical.type != ">") {
11323
+ if (stream.eat("=")) {
11324
+ if (ch == "!" || ch == "=") stream.eat("=");
11325
+ } else if (/[<>*+\-|&?]/.test(ch)) {
11326
+ stream.eat(ch);
11327
+ if (ch == ">") stream.eat(ch);
11328
+ }
11329
+ }
11330
+ if (ch == "?" && stream.eat(".")) return ret(".")
11331
+ return ret("operator", "operator", stream.current());
11332
+ } else if (wordRE.test(ch)) {
11333
+ stream.eatWhile(wordRE);
11334
+ var word = stream.current();
11335
+ if (state.lastType != ".") {
11336
+ if (keywords.propertyIsEnumerable(word)) {
11337
+ var kw = keywords[word];
11338
+ return ret(kw.type, kw.style, word)
11339
+ }
11340
+ if (word == "async" && stream.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/, false))
11341
+ return ret("async", "keyword", word)
11342
+ }
11343
+ return ret("variable", "variable", word)
11344
+ }
11345
+ }
11399
11346
 
11400
- var depth = 0, sawSomething = false;
11401
- for (var pos = arrow - 1; pos >= 0; --pos) {
11402
- var ch = stream.string.charAt(pos);
11403
- var bracket = brackets.indexOf(ch);
11404
- if (bracket >= 0 && bracket < 3) {
11405
- if (!depth) { ++pos; break; }
11406
- if (--depth == 0) { if (ch == "(") sawSomething = true; break; }
11407
- } else if (bracket >= 3 && bracket < 6) {
11408
- ++depth;
11409
- } else if (wordRE.test(ch)) {
11410
- sawSomething = true;
11411
- } else if (/["'\/`]/.test(ch)) {
11412
- for (;; --pos) {
11413
- if (pos == 0) return
11414
- var next = stream.string.charAt(pos - 1);
11415
- if (next == ch && stream.string.charAt(pos - 2) != "\\") { pos--; break }
11416
- }
11417
- } else if (sawSomething && !depth) {
11418
- ++pos;
11419
- break;
11420
- }
11421
- }
11422
- if (sawSomething && !depth) state.fatArrowAt = pos;
11423
- }
11347
+ function tokenString(quote) {
11348
+ return function(stream, state) {
11349
+ var escaped = false, next;
11350
+ if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){
11351
+ state.tokenize = tokenBase;
11352
+ return ret("jsonld-keyword", "meta");
11353
+ }
11354
+ while ((next = stream.next()) != null) {
11355
+ if (next == quote && !escaped) break;
11356
+ escaped = !escaped && next == "\\";
11357
+ }
11358
+ if (!escaped) state.tokenize = tokenBase;
11359
+ return ret("string", "string");
11360
+ };
11361
+ }
11424
11362
 
11425
- // Parser
11363
+ function tokenComment(stream, state) {
11364
+ var maybeEnd = false, ch;
11365
+ while (ch = stream.next()) {
11366
+ if (ch == "/" && maybeEnd) {
11367
+ state.tokenize = tokenBase;
11368
+ break;
11369
+ }
11370
+ maybeEnd = (ch == "*");
11371
+ }
11372
+ return ret("comment", "comment");
11373
+ }
11426
11374
 
11427
- var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true,
11428
- "regexp": true, "this": true, "import": true, "jsonld-keyword": true};
11375
+ function tokenQuasi(stream, state) {
11376
+ var escaped = false, next;
11377
+ while ((next = stream.next()) != null) {
11378
+ if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) {
11379
+ state.tokenize = tokenBase;
11380
+ break;
11381
+ }
11382
+ escaped = !escaped && next == "\\";
11383
+ }
11384
+ return ret("quasi", "string-2", stream.current());
11385
+ }
11386
+
11387
+ var brackets = "([{}])";
11388
+ // This is a crude lookahead trick to try and notice that we're
11389
+ // parsing the argument patterns for a fat-arrow function before we
11390
+ // actually hit the arrow token. It only works if the arrow is on
11391
+ // the same line as the arguments and there's no strange noise
11392
+ // (comments) in between. Fallback is to only notice when we hit the
11393
+ // arrow, and not declare the arguments as locals for the arrow
11394
+ // body.
11395
+ function findFatArrow(stream, state) {
11396
+ if (state.fatArrowAt) state.fatArrowAt = null;
11397
+ var arrow = stream.string.indexOf("=>", stream.start);
11398
+ if (arrow < 0) return;
11399
+
11400
+ if (isTS) { // Try to skip TypeScript return type declarations after the arguments
11401
+ var m = /:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(stream.string.slice(stream.start, arrow));
11402
+ if (m) arrow = m.index;
11403
+ }
11404
+
11405
+ var depth = 0, sawSomething = false;
11406
+ for (var pos = arrow - 1; pos >= 0; --pos) {
11407
+ var ch = stream.string.charAt(pos);
11408
+ var bracket = brackets.indexOf(ch);
11409
+ if (bracket >= 0 && bracket < 3) {
11410
+ if (!depth) { ++pos; break; }
11411
+ if (--depth == 0) { if (ch == "(") sawSomething = true; break; }
11412
+ } else if (bracket >= 3 && bracket < 6) {
11413
+ ++depth;
11414
+ } else if (wordRE.test(ch)) {
11415
+ sawSomething = true;
11416
+ } else if (/["'\/`]/.test(ch)) {
11417
+ for (;; --pos) {
11418
+ if (pos == 0) return
11419
+ var next = stream.string.charAt(pos - 1);
11420
+ if (next == ch && stream.string.charAt(pos - 2) != "\\") { pos--; break }
11421
+ }
11422
+ } else if (sawSomething && !depth) {
11423
+ ++pos;
11424
+ break;
11425
+ }
11426
+ }
11427
+ if (sawSomething && !depth) state.fatArrowAt = pos;
11428
+ }
11429
11429
 
11430
- function JSLexical(indented, column, type, align, prev, info) {
11431
- this.indented = indented;
11432
- this.column = column;
11433
- this.type = type;
11434
- this.prev = prev;
11435
- this.info = info;
11436
- if (align != null) this.align = align;
11437
- }
11430
+ // Parser
11438
11431
 
11439
- function inScope(state, varname) {
11440
- if (!trackScope) return false
11441
- for (var v = state.localVars; v; v = v.next)
11442
- if (v.name == varname) return true;
11443
- for (var cx = state.context; cx; cx = cx.prev) {
11444
- for (var v = cx.vars; v; v = v.next)
11445
- if (v.name == varname) return true;
11446
- }
11447
- }
11432
+ var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true,
11433
+ "regexp": true, "this": true, "import": true, "jsonld-keyword": true};
11448
11434
 
11449
- function parseJS(state, style, type, content, stream) {
11450
- var cc = state.cc;
11451
- // Communicate our context to the combinators.
11452
- // (Less wasteful than consing up a hundred closures on every call.)
11453
- cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; cx.style = style;
11454
-
11455
- if (!state.lexical.hasOwnProperty("align"))
11456
- state.lexical.align = true;
11457
-
11458
- while(true) {
11459
- var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
11460
- if (combinator(type, content)) {
11461
- while(cc.length && cc[cc.length - 1].lex)
11462
- cc.pop()();
11463
- if (cx.marked) return cx.marked;
11464
- if (type == "variable" && inScope(state, content)) return "variable-2";
11465
- return style;
11466
- }
11467
- }
11468
- }
11435
+ function JSLexical(indented, column, type, align, prev, info) {
11436
+ this.indented = indented;
11437
+ this.column = column;
11438
+ this.type = type;
11439
+ this.prev = prev;
11440
+ this.info = info;
11441
+ if (align != null) this.align = align;
11442
+ }
11469
11443
 
11470
- // Combinator utils
11444
+ function inScope(state, varname) {
11445
+ if (!trackScope) return false
11446
+ for (var v = state.localVars; v; v = v.next)
11447
+ if (v.name == varname) return true;
11448
+ for (var cx = state.context; cx; cx = cx.prev) {
11449
+ for (var v = cx.vars; v; v = v.next)
11450
+ if (v.name == varname) return true;
11451
+ }
11452
+ }
11471
11453
 
11472
- var cx = {state: null, column: null, marked: null, cc: null};
11473
- function pass() {
11474
- for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
11475
- }
11476
- function cont() {
11477
- pass.apply(null, arguments);
11478
- return true;
11479
- }
11480
- function inList(name, list) {
11481
- for (var v = list; v; v = v.next) if (v.name == name) return true
11482
- return false;
11483
- }
11484
- function register(varname) {
11485
- var state = cx.state;
11486
- cx.marked = "def";
11487
- if (!trackScope) return
11488
- if (state.context) {
11489
- if (state.lexical.info == "var" && state.context && state.context.block) {
11490
- // FIXME function decls are also not block scoped
11491
- var newContext = registerVarScoped(varname, state.context);
11492
- if (newContext != null) {
11493
- state.context = newContext;
11494
- return
11495
- }
11496
- } else if (!inList(varname, state.localVars)) {
11497
- state.localVars = new Var(varname, state.localVars);
11498
- return
11499
- }
11500
- }
11501
- // Fall through means this is global
11502
- if (parserConfig.globalVars && !inList(varname, state.globalVars))
11503
- state.globalVars = new Var(varname, state.globalVars);
11504
- }
11505
- function registerVarScoped(varname, context) {
11506
- if (!context) {
11507
- return null
11508
- } else if (context.block) {
11509
- var inner = registerVarScoped(varname, context.prev);
11510
- if (!inner) return null
11511
- if (inner == context.prev) return context
11512
- return new Context(inner, context.vars, true)
11513
- } else if (inList(varname, context.vars)) {
11514
- return context
11515
- } else {
11516
- return new Context(context.prev, new Var(varname, context.vars), false)
11517
- }
11518
- }
11454
+ function parseJS(state, style, type, content, stream) {
11455
+ var cc = state.cc;
11456
+ // Communicate our context to the combinators.
11457
+ // (Less wasteful than consing up a hundred closures on every call.)
11458
+ cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; cx.style = style;
11519
11459
 
11520
- function isModifier(name) {
11521
- return name == "public" || name == "private" || name == "protected" || name == "abstract" || name == "readonly"
11522
- }
11460
+ if (!state.lexical.hasOwnProperty("align"))
11461
+ state.lexical.align = true;
11523
11462
 
11524
- // Combinators
11463
+ while(true) {
11464
+ var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
11465
+ if (combinator(type, content)) {
11466
+ while(cc.length && cc[cc.length - 1].lex)
11467
+ cc.pop()();
11468
+ if (cx.marked) return cx.marked;
11469
+ if (type == "variable" && inScope(state, content)) return "variable-2";
11470
+ return style;
11471
+ }
11472
+ }
11473
+ }
11525
11474
 
11526
- function Context(prev, vars, block) { this.prev = prev; this.vars = vars; this.block = block; }
11527
- function Var(name, next) { this.name = name; this.next = next; }
11475
+ // Combinator utils
11528
11476
 
11529
- var defaultVars = new Var("this", new Var("arguments", null));
11530
- function pushcontext() {
11531
- cx.state.context = new Context(cx.state.context, cx.state.localVars, false);
11532
- cx.state.localVars = defaultVars;
11533
- }
11534
- function pushblockcontext() {
11535
- cx.state.context = new Context(cx.state.context, cx.state.localVars, true);
11536
- cx.state.localVars = null;
11537
- }
11538
- pushcontext.lex = pushblockcontext.lex = true;
11539
- function popcontext() {
11540
- cx.state.localVars = cx.state.context.vars;
11541
- cx.state.context = cx.state.context.prev;
11542
- }
11543
- popcontext.lex = true;
11544
- function pushlex(type, info) {
11545
- var result = function() {
11546
- var state = cx.state, indent = state.indented;
11547
- if (state.lexical.type == "stat") indent = state.lexical.indented;
11548
- else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev)
11549
- indent = outer.indented;
11550
- state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
11551
- };
11552
- result.lex = true;
11553
- return result;
11554
- }
11555
- function poplex() {
11556
- var state = cx.state;
11557
- if (state.lexical.prev) {
11558
- if (state.lexical.type == ")")
11559
- state.indented = state.lexical.indented;
11560
- state.lexical = state.lexical.prev;
11561
- }
11562
- }
11563
- poplex.lex = true;
11564
-
11565
- function expect(wanted) {
11566
- function exp(type) {
11567
- if (type == wanted) return cont();
11568
- else if (wanted == ";" || type == "}" || type == ")" || type == "]") return pass();
11569
- else return cont(exp);
11570
- } return exp;
11571
- }
11477
+ var cx = {state: null, column: null, marked: null, cc: null};
11478
+ function pass() {
11479
+ for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
11480
+ }
11481
+ function cont() {
11482
+ pass.apply(null, arguments);
11483
+ return true;
11484
+ }
11485
+ function inList(name, list) {
11486
+ for (var v = list; v; v = v.next) if (v.name == name) return true
11487
+ return false;
11488
+ }
11489
+ function register(varname) {
11490
+ var state = cx.state;
11491
+ cx.marked = "def";
11492
+ if (!trackScope) return
11493
+ if (state.context) {
11494
+ if (state.lexical.info == "var" && state.context && state.context.block) {
11495
+ // FIXME function decls are also not block scoped
11496
+ var newContext = registerVarScoped(varname, state.context);
11497
+ if (newContext != null) {
11498
+ state.context = newContext;
11499
+ return
11500
+ }
11501
+ } else if (!inList(varname, state.localVars)) {
11502
+ state.localVars = new Var(varname, state.localVars);
11503
+ return
11504
+ }
11505
+ }
11506
+ // Fall through means this is global
11507
+ if (parserConfig.globalVars && !inList(varname, state.globalVars))
11508
+ state.globalVars = new Var(varname, state.globalVars);
11509
+ }
11510
+ function registerVarScoped(varname, context) {
11511
+ if (!context) {
11512
+ return null
11513
+ } else if (context.block) {
11514
+ var inner = registerVarScoped(varname, context.prev);
11515
+ if (!inner) return null
11516
+ if (inner == context.prev) return context
11517
+ return new Context(inner, context.vars, true)
11518
+ } else if (inList(varname, context.vars)) {
11519
+ return context
11520
+ } else {
11521
+ return new Context(context.prev, new Var(varname, context.vars), false)
11522
+ }
11523
+ }
11572
11524
 
11573
- function statement(type, value) {
11574
- if (type == "var") return cont(pushlex("vardef", value), vardef, expect(";"), poplex);
11575
- if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
11576
- if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
11577
- if (type == "keyword d") return cx.stream.match(/^\s*$/, false) ? cont() : cont(pushlex("stat"), maybeexpression, expect(";"), poplex);
11578
- if (type == "debugger") return cont(expect(";"));
11579
- if (type == "{") return cont(pushlex("}"), pushblockcontext, block, poplex, popcontext);
11580
- if (type == ";") return cont();
11581
- if (type == "if") {
11582
- if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
11583
- cx.state.cc.pop()();
11584
- return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
11585
- }
11586
- if (type == "function") return cont(functiondef);
11587
- if (type == "for") return cont(pushlex("form"), pushblockcontext, forspec, statement, popcontext, poplex);
11588
- if (type == "class" || (isTS && value == "interface")) {
11589
- cx.marked = "keyword";
11590
- return cont(pushlex("form", type == "class" ? type : value), className, poplex)
11591
- }
11592
- if (type == "variable") {
11593
- if (isTS && value == "declare") {
11594
- cx.marked = "keyword";
11595
- return cont(statement)
11596
- } else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) {
11597
- cx.marked = "keyword";
11598
- if (value == "enum") return cont(enumdef);
11599
- else if (value == "type") return cont(typename, expect("operator"), typeexpr, expect(";"));
11600
- else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex)
11601
- } else if (isTS && value == "namespace") {
11602
- cx.marked = "keyword";
11603
- return cont(pushlex("form"), expression, statement, poplex)
11604
- } else if (isTS && value == "abstract") {
11605
- cx.marked = "keyword";
11606
- return cont(statement)
11607
- } else {
11608
- return cont(pushlex("stat"), maybelabel);
11609
- }
11610
- }
11611
- if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"), pushblockcontext,
11612
- block, poplex, poplex, popcontext);
11613
- if (type == "case") return cont(expression, expect(":"));
11614
- if (type == "default") return cont(expect(":"));
11615
- if (type == "catch") return cont(pushlex("form"), pushcontext, maybeCatchBinding, statement, poplex, popcontext);
11616
- if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
11617
- if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
11618
- if (type == "async") return cont(statement)
11619
- if (value == "@") return cont(expression, statement)
11620
- return pass(pushlex("stat"), expression, expect(";"), poplex);
11621
- }
11622
- function maybeCatchBinding(type) {
11623
- if (type == "(") return cont(funarg, expect(")"))
11624
- }
11625
- function expression(type, value) {
11626
- return expressionInner(type, value, false);
11627
- }
11628
- function expressionNoComma(type, value) {
11629
- return expressionInner(type, value, true);
11630
- }
11631
- function parenExpr(type) {
11632
- if (type != "(") return pass()
11633
- return cont(pushlex(")"), maybeexpression, expect(")"), poplex)
11634
- }
11635
- function expressionInner(type, value, noComma) {
11636
- if (cx.state.fatArrowAt == cx.stream.start) {
11637
- var body = noComma ? arrowBodyNoComma : arrowBody;
11638
- if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, expect("=>"), body, popcontext);
11639
- else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
11640
- }
11525
+ function isModifier(name) {
11526
+ return name == "public" || name == "private" || name == "protected" || name == "abstract" || name == "readonly"
11527
+ }
11641
11528
 
11642
- var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
11643
- if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
11644
- if (type == "function") return cont(functiondef, maybeop);
11645
- if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), classExpression, poplex); }
11646
- if (type == "keyword c" || type == "async") return cont(noComma ? expressionNoComma : expression);
11647
- if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
11648
- if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
11649
- if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
11650
- if (type == "{") return contCommasep(objprop, "}", null, maybeop);
11651
- if (type == "quasi") return pass(quasi, maybeop);
11652
- if (type == "new") return cont(maybeTarget(noComma));
11653
- return cont();
11654
- }
11655
- function maybeexpression(type) {
11656
- if (type.match(/[;\}\)\],]/)) return pass();
11657
- return pass(expression);
11658
- }
11529
+ // Combinators
11659
11530
 
11660
- function maybeoperatorComma(type, value) {
11661
- if (type == ",") return cont(maybeexpression);
11662
- return maybeoperatorNoComma(type, value, false);
11663
- }
11664
- function maybeoperatorNoComma(type, value, noComma) {
11665
- var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
11666
- var expr = noComma == false ? expression : expressionNoComma;
11667
- if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
11668
- if (type == "operator") {
11669
- if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me);
11670
- if (isTS && value == "<" && cx.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/, false))
11671
- return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me);
11672
- if (value == "?") return cont(expression, expect(":"), expr);
11673
- return cont(expr);
11674
- }
11675
- if (type == "quasi") { return pass(quasi, me); }
11676
- if (type == ";") return;
11677
- if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
11678
- if (type == ".") return cont(property, me);
11679
- if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
11680
- if (isTS && value == "as") { cx.marked = "keyword"; return cont(typeexpr, me) }
11681
- if (type == "regexp") {
11682
- cx.state.lastType = cx.marked = "operator";
11683
- cx.stream.backUp(cx.stream.pos - cx.stream.start - 1);
11684
- return cont(expr)
11685
- }
11686
- }
11687
- function quasi(type, value) {
11688
- if (type != "quasi") return pass();
11689
- if (value.slice(value.length - 2) != "${") return cont(quasi);
11690
- return cont(maybeexpression, continueQuasi);
11691
- }
11692
- function continueQuasi(type) {
11693
- if (type == "}") {
11694
- cx.marked = "string-2";
11695
- cx.state.tokenize = tokenQuasi;
11696
- return cont(quasi);
11697
- }
11698
- }
11699
- function arrowBody(type) {
11700
- findFatArrow(cx.stream, cx.state);
11701
- return pass(type == "{" ? statement : expression);
11702
- }
11703
- function arrowBodyNoComma(type) {
11704
- findFatArrow(cx.stream, cx.state);
11705
- return pass(type == "{" ? statement : expressionNoComma);
11706
- }
11707
- function maybeTarget(noComma) {
11708
- return function(type) {
11709
- if (type == ".") return cont(noComma ? targetNoComma : target);
11710
- else if (type == "variable" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma)
11711
- else return pass(noComma ? expressionNoComma : expression);
11712
- };
11713
- }
11714
- function target(_, value) {
11715
- if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorComma); }
11716
- }
11717
- function targetNoComma(_, value) {
11718
- if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorNoComma); }
11719
- }
11720
- function maybelabel(type) {
11721
- if (type == ":") return cont(poplex, statement);
11722
- return pass(maybeoperatorComma, expect(";"), poplex);
11723
- }
11724
- function property(type) {
11725
- if (type == "variable") {cx.marked = "property"; return cont();}
11726
- }
11727
- function objprop(type, value) {
11728
- if (type == "async") {
11729
- cx.marked = "property";
11730
- return cont(objprop);
11731
- } else if (type == "variable" || cx.style == "keyword") {
11732
- cx.marked = "property";
11733
- if (value == "get" || value == "set") return cont(getterSetter);
11734
- var m; // Work around fat-arrow-detection complication for detecting typescript typed arrow params
11735
- if (isTS && cx.state.fatArrowAt == cx.stream.start && (m = cx.stream.match(/^\s*:\s*/, false)))
11736
- cx.state.fatArrowAt = cx.stream.pos + m[0].length;
11737
- return cont(afterprop);
11738
- } else if (type == "number" || type == "string") {
11739
- cx.marked = jsonldMode ? "property" : (cx.style + " property");
11740
- return cont(afterprop);
11741
- } else if (type == "jsonld-keyword") {
11742
- return cont(afterprop);
11743
- } else if (isTS && isModifier(value)) {
11744
- cx.marked = "keyword";
11745
- return cont(objprop)
11746
- } else if (type == "[") {
11747
- return cont(expression, maybetype, expect("]"), afterprop);
11748
- } else if (type == "spread") {
11749
- return cont(expressionNoComma, afterprop);
11750
- } else if (value == "*") {
11751
- cx.marked = "keyword";
11752
- return cont(objprop);
11753
- } else if (type == ":") {
11754
- return pass(afterprop)
11755
- }
11756
- }
11757
- function getterSetter(type) {
11758
- if (type != "variable") return pass(afterprop);
11759
- cx.marked = "property";
11760
- return cont(functiondef);
11761
- }
11762
- function afterprop(type) {
11763
- if (type == ":") return cont(expressionNoComma);
11764
- if (type == "(") return pass(functiondef);
11765
- }
11766
- function commasep(what, end, sep) {
11767
- function proceed(type, value) {
11768
- if (sep ? sep.indexOf(type) > -1 : type == ",") {
11769
- var lex = cx.state.lexical;
11770
- if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
11771
- return cont(function(type, value) {
11772
- if (type == end || value == end) return pass()
11773
- return pass(what)
11774
- }, proceed);
11775
- }
11776
- if (type == end || value == end) return cont();
11777
- if (sep && sep.indexOf(";") > -1) return pass(what)
11778
- return cont(expect(end));
11779
- }
11780
- return function(type, value) {
11781
- if (type == end || value == end) return cont();
11782
- return pass(what, proceed);
11783
- };
11784
- }
11785
- function contCommasep(what, end, info) {
11786
- for (var i = 3; i < arguments.length; i++)
11787
- cx.cc.push(arguments[i]);
11788
- return cont(pushlex(end, info), commasep(what, end), poplex);
11789
- }
11790
- function block(type) {
11791
- if (type == "}") return cont();
11792
- return pass(statement, block);
11793
- }
11794
- function maybetype(type, value) {
11795
- if (isTS) {
11796
- if (type == ":") return cont(typeexpr);
11797
- if (value == "?") return cont(maybetype);
11798
- }
11799
- }
11800
- function maybetypeOrIn(type, value) {
11801
- if (isTS && (type == ":" || value == "in")) return cont(typeexpr)
11802
- }
11803
- function mayberettype(type) {
11804
- if (isTS && type == ":") {
11805
- if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr)
11806
- else return cont(typeexpr)
11807
- }
11808
- }
11809
- function isKW(_, value) {
11810
- if (value == "is") {
11811
- cx.marked = "keyword";
11812
- return cont()
11813
- }
11814
- }
11815
- function typeexpr(type, value) {
11816
- if (value == "keyof" || value == "typeof" || value == "infer" || value == "readonly") {
11817
- cx.marked = "keyword";
11818
- return cont(value == "typeof" ? expressionNoComma : typeexpr)
11819
- }
11820
- if (type == "variable" || value == "void") {
11821
- cx.marked = "type";
11822
- return cont(afterType)
11823
- }
11824
- if (value == "|" || value == "&") return cont(typeexpr)
11825
- if (type == "string" || type == "number" || type == "atom") return cont(afterType);
11826
- if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)
11827
- if (type == "{") return cont(pushlex("}"), typeprops, poplex, afterType)
11828
- if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType)
11829
- if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr)
11830
- if (type == "quasi") { return pass(quasiType, afterType); }
11831
- }
11832
- function maybeReturnType(type) {
11833
- if (type == "=>") return cont(typeexpr)
11834
- }
11835
- function typeprops(type) {
11836
- if (type.match(/[\}\)\]]/)) return cont()
11837
- if (type == "," || type == ";") return cont(typeprops)
11838
- return pass(typeprop, typeprops)
11839
- }
11840
- function typeprop(type, value) {
11841
- if (type == "variable" || cx.style == "keyword") {
11842
- cx.marked = "property";
11843
- return cont(typeprop)
11844
- } else if (value == "?" || type == "number" || type == "string") {
11845
- return cont(typeprop)
11846
- } else if (type == ":") {
11847
- return cont(typeexpr)
11848
- } else if (type == "[") {
11849
- return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop)
11850
- } else if (type == "(") {
11851
- return pass(functiondecl, typeprop)
11852
- } else if (!type.match(/[;\}\)\],]/)) {
11853
- return cont()
11854
- }
11855
- }
11856
- function quasiType(type, value) {
11857
- if (type != "quasi") return pass();
11858
- if (value.slice(value.length - 2) != "${") return cont(quasiType);
11859
- return cont(typeexpr, continueQuasiType);
11860
- }
11861
- function continueQuasiType(type) {
11862
- if (type == "}") {
11863
- cx.marked = "string-2";
11864
- cx.state.tokenize = tokenQuasi;
11865
- return cont(quasiType);
11866
- }
11867
- }
11868
- function typearg(type, value) {
11869
- if (type == "variable" && cx.stream.match(/^\s*[?:]/, false) || value == "?") return cont(typearg)
11870
- if (type == ":") return cont(typeexpr)
11871
- if (type == "spread") return cont(typearg)
11872
- return pass(typeexpr)
11873
- }
11874
- function afterType(type, value) {
11875
- if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
11876
- if (value == "|" || type == "." || value == "&") return cont(typeexpr)
11877
- if (type == "[") return cont(typeexpr, expect("]"), afterType)
11878
- if (value == "extends" || value == "implements") { cx.marked = "keyword"; return cont(typeexpr) }
11879
- if (value == "?") return cont(typeexpr, expect(":"), typeexpr)
11880
- }
11881
- function maybeTypeArgs(_, value) {
11882
- if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
11883
- }
11884
- function typeparam() {
11885
- return pass(typeexpr, maybeTypeDefault)
11886
- }
11887
- function maybeTypeDefault(_, value) {
11888
- if (value == "=") return cont(typeexpr)
11889
- }
11890
- function vardef(_, value) {
11891
- if (value == "enum") {cx.marked = "keyword"; return cont(enumdef)}
11892
- return pass(pattern, maybetype, maybeAssign, vardefCont);
11893
- }
11894
- function pattern(type, value) {
11895
- if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(pattern) }
11896
- if (type == "variable") { register(value); return cont(); }
11897
- if (type == "spread") return cont(pattern);
11898
- if (type == "[") return contCommasep(eltpattern, "]");
11899
- if (type == "{") return contCommasep(proppattern, "}");
11900
- }
11901
- function proppattern(type, value) {
11902
- if (type == "variable" && !cx.stream.match(/^\s*:/, false)) {
11903
- register(value);
11904
- return cont(maybeAssign);
11905
- }
11906
- if (type == "variable") cx.marked = "property";
11907
- if (type == "spread") return cont(pattern);
11908
- if (type == "}") return pass();
11909
- if (type == "[") return cont(expression, expect(']'), expect(':'), proppattern);
11910
- return cont(expect(":"), pattern, maybeAssign);
11911
- }
11912
- function eltpattern() {
11913
- return pass(pattern, maybeAssign)
11914
- }
11915
- function maybeAssign(_type, value) {
11916
- if (value == "=") return cont(expressionNoComma);
11917
- }
11918
- function vardefCont(type) {
11919
- if (type == ",") return cont(vardef);
11920
- }
11921
- function maybeelse(type, value) {
11922
- if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
11923
- }
11924
- function forspec(type, value) {
11925
- if (value == "await") return cont(forspec);
11926
- if (type == "(") return cont(pushlex(")"), forspec1, poplex);
11927
- }
11928
- function forspec1(type) {
11929
- if (type == "var") return cont(vardef, forspec2);
11930
- if (type == "variable") return cont(forspec2);
11931
- return pass(forspec2)
11932
- }
11933
- function forspec2(type, value) {
11934
- if (type == ")") return cont()
11935
- if (type == ";") return cont(forspec2)
11936
- if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression, forspec2) }
11937
- return pass(expression, forspec2)
11938
- }
11939
- function functiondef(type, value) {
11940
- if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
11941
- if (type == "variable") {register(value); return cont(functiondef);}
11942
- if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext);
11943
- if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef)
11944
- }
11945
- function functiondecl(type, value) {
11946
- if (value == "*") {cx.marked = "keyword"; return cont(functiondecl);}
11947
- if (type == "variable") {register(value); return cont(functiondecl);}
11948
- if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, popcontext);
11949
- if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondecl)
11950
- }
11951
- function typename(type, value) {
11952
- if (type == "keyword" || type == "variable") {
11953
- cx.marked = "type";
11954
- return cont(typename)
11955
- } else if (value == "<") {
11956
- return cont(pushlex(">"), commasep(typeparam, ">"), poplex)
11957
- }
11958
- }
11959
- function funarg(type, value) {
11960
- if (value == "@") cont(expression, funarg);
11961
- if (type == "spread") return cont(funarg);
11962
- if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(funarg); }
11963
- if (isTS && type == "this") return cont(maybetype, maybeAssign)
11964
- return pass(pattern, maybetype, maybeAssign);
11965
- }
11966
- function classExpression(type, value) {
11967
- // Class expressions may have an optional name.
11968
- if (type == "variable") return className(type, value);
11969
- return classNameAfter(type, value);
11970
- }
11971
- function className(type, value) {
11972
- if (type == "variable") {register(value); return cont(classNameAfter);}
11973
- }
11974
- function classNameAfter(type, value) {
11975
- if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, classNameAfter)
11976
- if (value == "extends" || value == "implements" || (isTS && type == ",")) {
11977
- if (value == "implements") cx.marked = "keyword";
11978
- return cont(isTS ? typeexpr : expression, classNameAfter);
11979
- }
11980
- if (type == "{") return cont(pushlex("}"), classBody, poplex);
11981
- }
11982
- function classBody(type, value) {
11983
- if (type == "async" ||
11984
- (type == "variable" &&
11985
- (value == "static" || value == "get" || value == "set" || (isTS && isModifier(value))) &&
11986
- cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) {
11987
- cx.marked = "keyword";
11988
- return cont(classBody);
11989
- }
11990
- if (type == "variable" || cx.style == "keyword") {
11991
- cx.marked = "property";
11992
- return cont(classfield, classBody);
11993
- }
11994
- if (type == "number" || type == "string") return cont(classfield, classBody);
11995
- if (type == "[")
11996
- return cont(expression, maybetype, expect("]"), classfield, classBody)
11997
- if (value == "*") {
11998
- cx.marked = "keyword";
11999
- return cont(classBody);
12000
- }
12001
- if (isTS && type == "(") return pass(functiondecl, classBody)
12002
- if (type == ";" || type == ",") return cont(classBody);
12003
- if (type == "}") return cont();
12004
- if (value == "@") return cont(expression, classBody)
12005
- }
12006
- function classfield(type, value) {
12007
- if (value == "!") return cont(classfield)
12008
- if (value == "?") return cont(classfield)
12009
- if (type == ":") return cont(typeexpr, maybeAssign)
12010
- if (value == "=") return cont(expressionNoComma)
12011
- var context = cx.state.lexical.prev, isInterface = context && context.info == "interface";
12012
- return pass(isInterface ? functiondecl : functiondef)
12013
- }
12014
- function afterExport(type, value) {
12015
- if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
12016
- if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
12017
- if (type == "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";"));
12018
- return pass(statement);
12019
- }
12020
- function exportField(type, value) {
12021
- if (value == "as") { cx.marked = "keyword"; return cont(expect("variable")); }
12022
- if (type == "variable") return pass(expressionNoComma, exportField);
12023
- }
12024
- function afterImport(type) {
12025
- if (type == "string") return cont();
12026
- if (type == "(") return pass(expression);
12027
- if (type == ".") return pass(maybeoperatorComma);
12028
- return pass(importSpec, maybeMoreImports, maybeFrom);
12029
- }
12030
- function importSpec(type, value) {
12031
- if (type == "{") return contCommasep(importSpec, "}");
12032
- if (type == "variable") register(value);
12033
- if (value == "*") cx.marked = "keyword";
12034
- return cont(maybeAs);
12035
- }
12036
- function maybeMoreImports(type) {
12037
- if (type == ",") return cont(importSpec, maybeMoreImports)
12038
- }
12039
- function maybeAs(_type, value) {
12040
- if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
12041
- }
12042
- function maybeFrom(_type, value) {
12043
- if (value == "from") { cx.marked = "keyword"; return cont(expression); }
12044
- }
12045
- function arrayLiteral(type) {
12046
- if (type == "]") return cont();
12047
- return pass(commasep(expressionNoComma, "]"));
12048
- }
12049
- function enumdef() {
12050
- return pass(pushlex("form"), pattern, expect("{"), pushlex("}"), commasep(enummember, "}"), poplex, poplex)
12051
- }
12052
- function enummember() {
12053
- return pass(pattern, maybeAssign);
12054
- }
11531
+ function Context(prev, vars, block) { this.prev = prev; this.vars = vars; this.block = block; }
11532
+ function Var(name, next) { this.name = name; this.next = next; }
12055
11533
 
12056
- function isContinuedStatement(state, textAfter) {
12057
- return state.lastType == "operator" || state.lastType == "," ||
12058
- isOperatorChar.test(textAfter.charAt(0)) ||
12059
- /[,.]/.test(textAfter.charAt(0));
12060
- }
11534
+ var defaultVars = new Var("this", new Var("arguments", null));
11535
+ function pushcontext() {
11536
+ cx.state.context = new Context(cx.state.context, cx.state.localVars, false);
11537
+ cx.state.localVars = defaultVars;
11538
+ }
11539
+ function pushblockcontext() {
11540
+ cx.state.context = new Context(cx.state.context, cx.state.localVars, true);
11541
+ cx.state.localVars = null;
11542
+ }
11543
+ pushcontext.lex = pushblockcontext.lex = true;
11544
+ function popcontext() {
11545
+ cx.state.localVars = cx.state.context.vars;
11546
+ cx.state.context = cx.state.context.prev;
11547
+ }
11548
+ popcontext.lex = true;
11549
+ function pushlex(type, info) {
11550
+ var result = function() {
11551
+ var state = cx.state, indent = state.indented;
11552
+ if (state.lexical.type == "stat") indent = state.lexical.indented;
11553
+ else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev)
11554
+ indent = outer.indented;
11555
+ state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
11556
+ };
11557
+ result.lex = true;
11558
+ return result;
11559
+ }
11560
+ function poplex() {
11561
+ var state = cx.state;
11562
+ if (state.lexical.prev) {
11563
+ if (state.lexical.type == ")")
11564
+ state.indented = state.lexical.indented;
11565
+ state.lexical = state.lexical.prev;
11566
+ }
11567
+ }
11568
+ poplex.lex = true;
11569
+
11570
+ function expect(wanted) {
11571
+ function exp(type) {
11572
+ if (type == wanted) return cont();
11573
+ else if (wanted == ";" || type == "}" || type == ")" || type == "]") return pass();
11574
+ else return cont(exp);
11575
+ } return exp;
11576
+ }
11577
+
11578
+ function statement(type, value) {
11579
+ if (type == "var") return cont(pushlex("vardef", value), vardef, expect(";"), poplex);
11580
+ if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
11581
+ if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
11582
+ if (type == "keyword d") return cx.stream.match(/^\s*$/, false) ? cont() : cont(pushlex("stat"), maybeexpression, expect(";"), poplex);
11583
+ if (type == "debugger") return cont(expect(";"));
11584
+ if (type == "{") return cont(pushlex("}"), pushblockcontext, block, poplex, popcontext);
11585
+ if (type == ";") return cont();
11586
+ if (type == "if") {
11587
+ if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
11588
+ cx.state.cc.pop()();
11589
+ return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
11590
+ }
11591
+ if (type == "function") return cont(functiondef);
11592
+ if (type == "for") return cont(pushlex("form"), pushblockcontext, forspec, statement, popcontext, poplex);
11593
+ if (type == "class" || (isTS && value == "interface")) {
11594
+ cx.marked = "keyword";
11595
+ return cont(pushlex("form", type == "class" ? type : value), className, poplex)
11596
+ }
11597
+ if (type == "variable") {
11598
+ if (isTS && value == "declare") {
11599
+ cx.marked = "keyword";
11600
+ return cont(statement)
11601
+ } else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) {
11602
+ cx.marked = "keyword";
11603
+ if (value == "enum") return cont(enumdef);
11604
+ else if (value == "type") return cont(typename, expect("operator"), typeexpr, expect(";"));
11605
+ else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex)
11606
+ } else if (isTS && value == "namespace") {
11607
+ cx.marked = "keyword";
11608
+ return cont(pushlex("form"), expression, statement, poplex)
11609
+ } else if (isTS && value == "abstract") {
11610
+ cx.marked = "keyword";
11611
+ return cont(statement)
11612
+ } else {
11613
+ return cont(pushlex("stat"), maybelabel);
11614
+ }
11615
+ }
11616
+ if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"), pushblockcontext,
11617
+ block, poplex, poplex, popcontext);
11618
+ if (type == "case") return cont(expression, expect(":"));
11619
+ if (type == "default") return cont(expect(":"));
11620
+ if (type == "catch") return cont(pushlex("form"), pushcontext, maybeCatchBinding, statement, poplex, popcontext);
11621
+ if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
11622
+ if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
11623
+ if (type == "async") return cont(statement)
11624
+ if (value == "@") return cont(expression, statement)
11625
+ return pass(pushlex("stat"), expression, expect(";"), poplex);
11626
+ }
11627
+ function maybeCatchBinding(type) {
11628
+ if (type == "(") return cont(funarg, expect(")"))
11629
+ }
11630
+ function expression(type, value) {
11631
+ return expressionInner(type, value, false);
11632
+ }
11633
+ function expressionNoComma(type, value) {
11634
+ return expressionInner(type, value, true);
11635
+ }
11636
+ function parenExpr(type) {
11637
+ if (type != "(") return pass()
11638
+ return cont(pushlex(")"), maybeexpression, expect(")"), poplex)
11639
+ }
11640
+ function expressionInner(type, value, noComma) {
11641
+ if (cx.state.fatArrowAt == cx.stream.start) {
11642
+ var body = noComma ? arrowBodyNoComma : arrowBody;
11643
+ if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, expect("=>"), body, popcontext);
11644
+ else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
11645
+ }
11646
+
11647
+ var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
11648
+ if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
11649
+ if (type == "function") return cont(functiondef, maybeop);
11650
+ if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), classExpression, poplex); }
11651
+ if (type == "keyword c" || type == "async") return cont(noComma ? expressionNoComma : expression);
11652
+ if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
11653
+ if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
11654
+ if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
11655
+ if (type == "{") return contCommasep(objprop, "}", null, maybeop);
11656
+ if (type == "quasi") return pass(quasi, maybeop);
11657
+ if (type == "new") return cont(maybeTarget(noComma));
11658
+ return cont();
11659
+ }
11660
+ function maybeexpression(type) {
11661
+ if (type.match(/[;\}\)\],]/)) return pass();
11662
+ return pass(expression);
11663
+ }
11664
+
11665
+ function maybeoperatorComma(type, value) {
11666
+ if (type == ",") return cont(maybeexpression);
11667
+ return maybeoperatorNoComma(type, value, false);
11668
+ }
11669
+ function maybeoperatorNoComma(type, value, noComma) {
11670
+ var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
11671
+ var expr = noComma == false ? expression : expressionNoComma;
11672
+ if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
11673
+ if (type == "operator") {
11674
+ if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me);
11675
+ if (isTS && value == "<" && cx.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/, false))
11676
+ return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me);
11677
+ if (value == "?") return cont(expression, expect(":"), expr);
11678
+ return cont(expr);
11679
+ }
11680
+ if (type == "quasi") { return pass(quasi, me); }
11681
+ if (type == ";") return;
11682
+ if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
11683
+ if (type == ".") return cont(property, me);
11684
+ if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
11685
+ if (isTS && value == "as") { cx.marked = "keyword"; return cont(typeexpr, me) }
11686
+ if (type == "regexp") {
11687
+ cx.state.lastType = cx.marked = "operator";
11688
+ cx.stream.backUp(cx.stream.pos - cx.stream.start - 1);
11689
+ return cont(expr)
11690
+ }
11691
+ }
11692
+ function quasi(type, value) {
11693
+ if (type != "quasi") return pass();
11694
+ if (value.slice(value.length - 2) != "${") return cont(quasi);
11695
+ return cont(maybeexpression, continueQuasi);
11696
+ }
11697
+ function continueQuasi(type) {
11698
+ if (type == "}") {
11699
+ cx.marked = "string-2";
11700
+ cx.state.tokenize = tokenQuasi;
11701
+ return cont(quasi);
11702
+ }
11703
+ }
11704
+ function arrowBody(type) {
11705
+ findFatArrow(cx.stream, cx.state);
11706
+ return pass(type == "{" ? statement : expression);
11707
+ }
11708
+ function arrowBodyNoComma(type) {
11709
+ findFatArrow(cx.stream, cx.state);
11710
+ return pass(type == "{" ? statement : expressionNoComma);
11711
+ }
11712
+ function maybeTarget(noComma) {
11713
+ return function(type) {
11714
+ if (type == ".") return cont(noComma ? targetNoComma : target);
11715
+ else if (type == "variable" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma)
11716
+ else return pass(noComma ? expressionNoComma : expression);
11717
+ };
11718
+ }
11719
+ function target(_, value) {
11720
+ if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorComma); }
11721
+ }
11722
+ function targetNoComma(_, value) {
11723
+ if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorNoComma); }
11724
+ }
11725
+ function maybelabel(type) {
11726
+ if (type == ":") return cont(poplex, statement);
11727
+ return pass(maybeoperatorComma, expect(";"), poplex);
11728
+ }
11729
+ function property(type) {
11730
+ if (type == "variable") {cx.marked = "property"; return cont();}
11731
+ }
11732
+ function objprop(type, value) {
11733
+ if (type == "async") {
11734
+ cx.marked = "property";
11735
+ return cont(objprop);
11736
+ } else if (type == "variable" || cx.style == "keyword") {
11737
+ cx.marked = "property";
11738
+ if (value == "get" || value == "set") return cont(getterSetter);
11739
+ var m; // Work around fat-arrow-detection complication for detecting typescript typed arrow params
11740
+ if (isTS && cx.state.fatArrowAt == cx.stream.start && (m = cx.stream.match(/^\s*:\s*/, false)))
11741
+ cx.state.fatArrowAt = cx.stream.pos + m[0].length;
11742
+ return cont(afterprop);
11743
+ } else if (type == "number" || type == "string") {
11744
+ cx.marked = jsonldMode ? "property" : (cx.style + " property");
11745
+ return cont(afterprop);
11746
+ } else if (type == "jsonld-keyword") {
11747
+ return cont(afterprop);
11748
+ } else if (isTS && isModifier(value)) {
11749
+ cx.marked = "keyword";
11750
+ return cont(objprop)
11751
+ } else if (type == "[") {
11752
+ return cont(expression, maybetype, expect("]"), afterprop);
11753
+ } else if (type == "spread") {
11754
+ return cont(expressionNoComma, afterprop);
11755
+ } else if (value == "*") {
11756
+ cx.marked = "keyword";
11757
+ return cont(objprop);
11758
+ } else if (type == ":") {
11759
+ return pass(afterprop)
11760
+ }
11761
+ }
11762
+ function getterSetter(type) {
11763
+ if (type != "variable") return pass(afterprop);
11764
+ cx.marked = "property";
11765
+ return cont(functiondef);
11766
+ }
11767
+ function afterprop(type) {
11768
+ if (type == ":") return cont(expressionNoComma);
11769
+ if (type == "(") return pass(functiondef);
11770
+ }
11771
+ function commasep(what, end, sep) {
11772
+ function proceed(type, value) {
11773
+ if (sep ? sep.indexOf(type) > -1 : type == ",") {
11774
+ var lex = cx.state.lexical;
11775
+ if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
11776
+ return cont(function(type, value) {
11777
+ if (type == end || value == end) return pass()
11778
+ return pass(what)
11779
+ }, proceed);
11780
+ }
11781
+ if (type == end || value == end) return cont();
11782
+ if (sep && sep.indexOf(";") > -1) return pass(what)
11783
+ return cont(expect(end));
11784
+ }
11785
+ return function(type, value) {
11786
+ if (type == end || value == end) return cont();
11787
+ return pass(what, proceed);
11788
+ };
11789
+ }
11790
+ function contCommasep(what, end, info) {
11791
+ for (var i = 3; i < arguments.length; i++)
11792
+ cx.cc.push(arguments[i]);
11793
+ return cont(pushlex(end, info), commasep(what, end), poplex);
11794
+ }
11795
+ function block(type) {
11796
+ if (type == "}") return cont();
11797
+ return pass(statement, block);
11798
+ }
11799
+ function maybetype(type, value) {
11800
+ if (isTS) {
11801
+ if (type == ":") return cont(typeexpr);
11802
+ if (value == "?") return cont(maybetype);
11803
+ }
11804
+ }
11805
+ function maybetypeOrIn(type, value) {
11806
+ if (isTS && (type == ":" || value == "in")) return cont(typeexpr)
11807
+ }
11808
+ function mayberettype(type) {
11809
+ if (isTS && type == ":") {
11810
+ if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr)
11811
+ else return cont(typeexpr)
11812
+ }
11813
+ }
11814
+ function isKW(_, value) {
11815
+ if (value == "is") {
11816
+ cx.marked = "keyword";
11817
+ return cont()
11818
+ }
11819
+ }
11820
+ function typeexpr(type, value) {
11821
+ if (value == "keyof" || value == "typeof" || value == "infer" || value == "readonly") {
11822
+ cx.marked = "keyword";
11823
+ return cont(value == "typeof" ? expressionNoComma : typeexpr)
11824
+ }
11825
+ if (type == "variable" || value == "void") {
11826
+ cx.marked = "type";
11827
+ return cont(afterType)
11828
+ }
11829
+ if (value == "|" || value == "&") return cont(typeexpr)
11830
+ if (type == "string" || type == "number" || type == "atom") return cont(afterType);
11831
+ if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)
11832
+ if (type == "{") return cont(pushlex("}"), typeprops, poplex, afterType)
11833
+ if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType)
11834
+ if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr)
11835
+ if (type == "quasi") { return pass(quasiType, afterType); }
11836
+ }
11837
+ function maybeReturnType(type) {
11838
+ if (type == "=>") return cont(typeexpr)
11839
+ }
11840
+ function typeprops(type) {
11841
+ if (type.match(/[\}\)\]]/)) return cont()
11842
+ if (type == "," || type == ";") return cont(typeprops)
11843
+ return pass(typeprop, typeprops)
11844
+ }
11845
+ function typeprop(type, value) {
11846
+ if (type == "variable" || cx.style == "keyword") {
11847
+ cx.marked = "property";
11848
+ return cont(typeprop)
11849
+ } else if (value == "?" || type == "number" || type == "string") {
11850
+ return cont(typeprop)
11851
+ } else if (type == ":") {
11852
+ return cont(typeexpr)
11853
+ } else if (type == "[") {
11854
+ return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop)
11855
+ } else if (type == "(") {
11856
+ return pass(functiondecl, typeprop)
11857
+ } else if (!type.match(/[;\}\)\],]/)) {
11858
+ return cont()
11859
+ }
11860
+ }
11861
+ function quasiType(type, value) {
11862
+ if (type != "quasi") return pass();
11863
+ if (value.slice(value.length - 2) != "${") return cont(quasiType);
11864
+ return cont(typeexpr, continueQuasiType);
11865
+ }
11866
+ function continueQuasiType(type) {
11867
+ if (type == "}") {
11868
+ cx.marked = "string-2";
11869
+ cx.state.tokenize = tokenQuasi;
11870
+ return cont(quasiType);
11871
+ }
11872
+ }
11873
+ function typearg(type, value) {
11874
+ if (type == "variable" && cx.stream.match(/^\s*[?:]/, false) || value == "?") return cont(typearg)
11875
+ if (type == ":") return cont(typeexpr)
11876
+ if (type == "spread") return cont(typearg)
11877
+ return pass(typeexpr)
11878
+ }
11879
+ function afterType(type, value) {
11880
+ if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
11881
+ if (value == "|" || type == "." || value == "&") return cont(typeexpr)
11882
+ if (type == "[") return cont(typeexpr, expect("]"), afterType)
11883
+ if (value == "extends" || value == "implements") { cx.marked = "keyword"; return cont(typeexpr) }
11884
+ if (value == "?") return cont(typeexpr, expect(":"), typeexpr)
11885
+ }
11886
+ function maybeTypeArgs(_, value) {
11887
+ if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
11888
+ }
11889
+ function typeparam() {
11890
+ return pass(typeexpr, maybeTypeDefault)
11891
+ }
11892
+ function maybeTypeDefault(_, value) {
11893
+ if (value == "=") return cont(typeexpr)
11894
+ }
11895
+ function vardef(_, value) {
11896
+ if (value == "enum") {cx.marked = "keyword"; return cont(enumdef)}
11897
+ return pass(pattern, maybetype, maybeAssign, vardefCont);
11898
+ }
11899
+ function pattern(type, value) {
11900
+ if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(pattern) }
11901
+ if (type == "variable") { register(value); return cont(); }
11902
+ if (type == "spread") return cont(pattern);
11903
+ if (type == "[") return contCommasep(eltpattern, "]");
11904
+ if (type == "{") return contCommasep(proppattern, "}");
11905
+ }
11906
+ function proppattern(type, value) {
11907
+ if (type == "variable" && !cx.stream.match(/^\s*:/, false)) {
11908
+ register(value);
11909
+ return cont(maybeAssign);
11910
+ }
11911
+ if (type == "variable") cx.marked = "property";
11912
+ if (type == "spread") return cont(pattern);
11913
+ if (type == "}") return pass();
11914
+ if (type == "[") return cont(expression, expect(']'), expect(':'), proppattern);
11915
+ return cont(expect(":"), pattern, maybeAssign);
11916
+ }
11917
+ function eltpattern() {
11918
+ return pass(pattern, maybeAssign)
11919
+ }
11920
+ function maybeAssign(_type, value) {
11921
+ if (value == "=") return cont(expressionNoComma);
11922
+ }
11923
+ function vardefCont(type) {
11924
+ if (type == ",") return cont(vardef);
11925
+ }
11926
+ function maybeelse(type, value) {
11927
+ if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
11928
+ }
11929
+ function forspec(type, value) {
11930
+ if (value == "await") return cont(forspec);
11931
+ if (type == "(") return cont(pushlex(")"), forspec1, poplex);
11932
+ }
11933
+ function forspec1(type) {
11934
+ if (type == "var") return cont(vardef, forspec2);
11935
+ if (type == "variable") return cont(forspec2);
11936
+ return pass(forspec2)
11937
+ }
11938
+ function forspec2(type, value) {
11939
+ if (type == ")") return cont()
11940
+ if (type == ";") return cont(forspec2)
11941
+ if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression, forspec2) }
11942
+ return pass(expression, forspec2)
11943
+ }
11944
+ function functiondef(type, value) {
11945
+ if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
11946
+ if (type == "variable") {register(value); return cont(functiondef);}
11947
+ if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext);
11948
+ if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef)
11949
+ }
11950
+ function functiondecl(type, value) {
11951
+ if (value == "*") {cx.marked = "keyword"; return cont(functiondecl);}
11952
+ if (type == "variable") {register(value); return cont(functiondecl);}
11953
+ if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, popcontext);
11954
+ if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondecl)
11955
+ }
11956
+ function typename(type, value) {
11957
+ if (type == "keyword" || type == "variable") {
11958
+ cx.marked = "type";
11959
+ return cont(typename)
11960
+ } else if (value == "<") {
11961
+ return cont(pushlex(">"), commasep(typeparam, ">"), poplex)
11962
+ }
11963
+ }
11964
+ function funarg(type, value) {
11965
+ if (value == "@") cont(expression, funarg);
11966
+ if (type == "spread") return cont(funarg);
11967
+ if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(funarg); }
11968
+ if (isTS && type == "this") return cont(maybetype, maybeAssign)
11969
+ return pass(pattern, maybetype, maybeAssign);
11970
+ }
11971
+ function classExpression(type, value) {
11972
+ // Class expressions may have an optional name.
11973
+ if (type == "variable") return className(type, value);
11974
+ return classNameAfter(type, value);
11975
+ }
11976
+ function className(type, value) {
11977
+ if (type == "variable") {register(value); return cont(classNameAfter);}
11978
+ }
11979
+ function classNameAfter(type, value) {
11980
+ if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, classNameAfter)
11981
+ if (value == "extends" || value == "implements" || (isTS && type == ",")) {
11982
+ if (value == "implements") cx.marked = "keyword";
11983
+ return cont(isTS ? typeexpr : expression, classNameAfter);
11984
+ }
11985
+ if (type == "{") return cont(pushlex("}"), classBody, poplex);
11986
+ }
11987
+ function classBody(type, value) {
11988
+ if (type == "async" ||
11989
+ (type == "variable" &&
11990
+ (value == "static" || value == "get" || value == "set" || (isTS && isModifier(value))) &&
11991
+ cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) {
11992
+ cx.marked = "keyword";
11993
+ return cont(classBody);
11994
+ }
11995
+ if (type == "variable" || cx.style == "keyword") {
11996
+ cx.marked = "property";
11997
+ return cont(classfield, classBody);
11998
+ }
11999
+ if (type == "number" || type == "string") return cont(classfield, classBody);
12000
+ if (type == "[")
12001
+ return cont(expression, maybetype, expect("]"), classfield, classBody)
12002
+ if (value == "*") {
12003
+ cx.marked = "keyword";
12004
+ return cont(classBody);
12005
+ }
12006
+ if (isTS && type == "(") return pass(functiondecl, classBody)
12007
+ if (type == ";" || type == ",") return cont(classBody);
12008
+ if (type == "}") return cont();
12009
+ if (value == "@") return cont(expression, classBody)
12010
+ }
12011
+ function classfield(type, value) {
12012
+ if (value == "!") return cont(classfield)
12013
+ if (value == "?") return cont(classfield)
12014
+ if (type == ":") return cont(typeexpr, maybeAssign)
12015
+ if (value == "=") return cont(expressionNoComma)
12016
+ var context = cx.state.lexical.prev, isInterface = context && context.info == "interface";
12017
+ return pass(isInterface ? functiondecl : functiondef)
12018
+ }
12019
+ function afterExport(type, value) {
12020
+ if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
12021
+ if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
12022
+ if (type == "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";"));
12023
+ return pass(statement);
12024
+ }
12025
+ function exportField(type, value) {
12026
+ if (value == "as") { cx.marked = "keyword"; return cont(expect("variable")); }
12027
+ if (type == "variable") return pass(expressionNoComma, exportField);
12028
+ }
12029
+ function afterImport(type) {
12030
+ if (type == "string") return cont();
12031
+ if (type == "(") return pass(expression);
12032
+ if (type == ".") return pass(maybeoperatorComma);
12033
+ return pass(importSpec, maybeMoreImports, maybeFrom);
12034
+ }
12035
+ function importSpec(type, value) {
12036
+ if (type == "{") return contCommasep(importSpec, "}");
12037
+ if (type == "variable") register(value);
12038
+ if (value == "*") cx.marked = "keyword";
12039
+ return cont(maybeAs);
12040
+ }
12041
+ function maybeMoreImports(type) {
12042
+ if (type == ",") return cont(importSpec, maybeMoreImports)
12043
+ }
12044
+ function maybeAs(_type, value) {
12045
+ if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
12046
+ }
12047
+ function maybeFrom(_type, value) {
12048
+ if (value == "from") { cx.marked = "keyword"; return cont(expression); }
12049
+ }
12050
+ function arrayLiteral(type) {
12051
+ if (type == "]") return cont();
12052
+ return pass(commasep(expressionNoComma, "]"));
12053
+ }
12054
+ function enumdef() {
12055
+ return pass(pushlex("form"), pattern, expect("{"), pushlex("}"), commasep(enummember, "}"), poplex, poplex)
12056
+ }
12057
+ function enummember() {
12058
+ return pass(pattern, maybeAssign);
12059
+ }
12061
12060
 
12062
- function expressionAllowed(stream, state, backUp) {
12063
- return state.tokenize == tokenBase &&
12064
- /^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
12065
- (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
12066
- }
12061
+ function isContinuedStatement(state, textAfter) {
12062
+ return state.lastType == "operator" || state.lastType == "," ||
12063
+ isOperatorChar.test(textAfter.charAt(0)) ||
12064
+ /[,.]/.test(textAfter.charAt(0));
12065
+ }
12066
+
12067
+ function expressionAllowed(stream, state, backUp) {
12068
+ return state.tokenize == tokenBase &&
12069
+ /^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
12070
+ (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
12071
+ }
12067
12072
 
12068
- // Interface
12073
+ // Interface
12069
12074
 
12070
- return {
12071
- startState: function(basecolumn) {
12072
- var state = {
12073
- tokenize: tokenBase,
12074
- lastType: "sof",
12075
- cc: [],
12076
- lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
12077
- localVars: parserConfig.localVars,
12078
- context: parserConfig.localVars && new Context(null, null, false),
12079
- indented: basecolumn || 0
12080
- };
12081
- if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
12082
- state.globalVars = parserConfig.globalVars;
12083
- return state;
12084
- },
12075
+ return {
12076
+ startState: function(basecolumn) {
12077
+ var state = {
12078
+ tokenize: tokenBase,
12079
+ lastType: "sof",
12080
+ cc: [],
12081
+ lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
12082
+ localVars: parserConfig.localVars,
12083
+ context: parserConfig.localVars && new Context(null, null, false),
12084
+ indented: basecolumn || 0
12085
+ };
12086
+ if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
12087
+ state.globalVars = parserConfig.globalVars;
12088
+ return state;
12089
+ },
12085
12090
 
12086
- token: function(stream, state) {
12087
- if (stream.sol()) {
12088
- if (!state.lexical.hasOwnProperty("align"))
12089
- state.lexical.align = false;
12090
- state.indented = stream.indentation();
12091
- findFatArrow(stream, state);
12092
- }
12093
- if (state.tokenize != tokenComment && stream.eatSpace()) return null;
12094
- var style = state.tokenize(stream, state);
12095
- if (type == "comment") return style;
12096
- state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
12097
- return parseJS(state, style, type, content, stream);
12098
- },
12091
+ token: function(stream, state) {
12092
+ if (stream.sol()) {
12093
+ if (!state.lexical.hasOwnProperty("align"))
12094
+ state.lexical.align = false;
12095
+ state.indented = stream.indentation();
12096
+ findFatArrow(stream, state);
12097
+ }
12098
+ if (state.tokenize != tokenComment && stream.eatSpace()) return null;
12099
+ var style = state.tokenize(stream, state);
12100
+ if (type == "comment") return style;
12101
+ state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
12102
+ return parseJS(state, style, type, content, stream);
12103
+ },
12099
12104
 
12100
- indent: function(state, textAfter) {
12101
- if (state.tokenize == tokenComment || state.tokenize == tokenQuasi) return CodeMirror.Pass;
12102
- if (state.tokenize != tokenBase) return 0;
12103
- var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top;
12104
- // Kludge to prevent 'maybelse' from blocking lexical scope pops
12105
- if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
12106
- var c = state.cc[i];
12107
- if (c == poplex) lexical = lexical.prev;
12108
- else if (c != maybeelse && c != popcontext) break;
12109
- }
12110
- while ((lexical.type == "stat" || lexical.type == "form") &&
12111
- (firstChar == "}" || ((top = state.cc[state.cc.length - 1]) &&
12112
- (top == maybeoperatorComma || top == maybeoperatorNoComma) &&
12113
- !/^[,\.=+\-*:?[\(]/.test(textAfter))))
12114
- lexical = lexical.prev;
12115
- if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
12116
- lexical = lexical.prev;
12117
- var type = lexical.type, closing = firstChar == type;
12118
-
12119
- if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info.length + 1 : 0);
12120
- else if (type == "form" && firstChar == "{") return lexical.indented;
12121
- else if (type == "form") return lexical.indented + indentUnit;
12122
- else if (type == "stat")
12123
- return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0);
12124
- else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
12125
- return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
12126
- else if (lexical.align) return lexical.column + (closing ? 0 : 1);
12127
- else return lexical.indented + (closing ? 0 : indentUnit);
12128
- },
12105
+ indent: function(state, textAfter) {
12106
+ if (state.tokenize == tokenComment || state.tokenize == tokenQuasi) return CodeMirror.Pass;
12107
+ if (state.tokenize != tokenBase) return 0;
12108
+ var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top;
12109
+ // Kludge to prevent 'maybelse' from blocking lexical scope pops
12110
+ if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
12111
+ var c = state.cc[i];
12112
+ if (c == poplex) lexical = lexical.prev;
12113
+ else if (c != maybeelse && c != popcontext) break;
12114
+ }
12115
+ while ((lexical.type == "stat" || lexical.type == "form") &&
12116
+ (firstChar == "}" || ((top = state.cc[state.cc.length - 1]) &&
12117
+ (top == maybeoperatorComma || top == maybeoperatorNoComma) &&
12118
+ !/^[,\.=+\-*:?[\(]/.test(textAfter))))
12119
+ lexical = lexical.prev;
12120
+ if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
12121
+ lexical = lexical.prev;
12122
+ var type = lexical.type, closing = firstChar == type;
12123
+
12124
+ if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info.length + 1 : 0);
12125
+ else if (type == "form" && firstChar == "{") return lexical.indented;
12126
+ else if (type == "form") return lexical.indented + indentUnit;
12127
+ else if (type == "stat")
12128
+ return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0);
12129
+ else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
12130
+ return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
12131
+ else if (lexical.align) return lexical.column + (closing ? 0 : 1);
12132
+ else return lexical.indented + (closing ? 0 : indentUnit);
12133
+ },
12129
12134
 
12130
- electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
12131
- blockCommentStart: jsonMode ? null : "/*",
12132
- blockCommentEnd: jsonMode ? null : "*/",
12133
- blockCommentContinue: jsonMode ? null : " * ",
12134
- lineComment: jsonMode ? null : "//",
12135
- fold: "brace",
12136
- closeBrackets: "()[]{}''\"\"``",
12135
+ electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
12136
+ blockCommentStart: jsonMode ? null : "/*",
12137
+ blockCommentEnd: jsonMode ? null : "*/",
12138
+ blockCommentContinue: jsonMode ? null : " * ",
12139
+ lineComment: jsonMode ? null : "//",
12140
+ fold: "brace",
12141
+ closeBrackets: "()[]{}''\"\"``",
12137
12142
 
12138
- helperType: jsonMode ? "json" : "javascript",
12139
- jsonldMode: jsonldMode,
12140
- jsonMode: jsonMode,
12143
+ helperType: jsonMode ? "json" : "javascript",
12144
+ jsonldMode: jsonldMode,
12145
+ jsonMode: jsonMode,
12141
12146
 
12142
- expressionAllowed: expressionAllowed,
12147
+ expressionAllowed: expressionAllowed,
12143
12148
 
12144
- skipExpression: function(state) {
12145
- parseJS(state, "atom", "atom", "true", new CodeMirror.StringStream("", 2, null));
12146
- }
12147
- };
12148
- });
12149
+ skipExpression: function(state) {
12150
+ parseJS(state, "atom", "atom", "true", new CodeMirror.StringStream("", 2, null));
12151
+ }
12152
+ };
12153
+ });
12149
12154
 
12150
- CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);
12155
+ CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);
12151
12156
 
12152
- CodeMirror.defineMIME("text/javascript", "javascript");
12153
- CodeMirror.defineMIME("text/ecmascript", "javascript");
12154
- CodeMirror.defineMIME("application/javascript", "javascript");
12155
- CodeMirror.defineMIME("application/x-javascript", "javascript");
12156
- CodeMirror.defineMIME("application/ecmascript", "javascript");
12157
- CodeMirror.defineMIME("application/json", { name: "javascript", json: true });
12158
- CodeMirror.defineMIME("application/x-json", { name: "javascript", json: true });
12159
- CodeMirror.defineMIME("application/manifest+json", { name: "javascript", json: true });
12160
- CodeMirror.defineMIME("application/ld+json", { name: "javascript", jsonld: true });
12161
- CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
12162
- CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
12157
+ CodeMirror.defineMIME("text/javascript", "javascript");
12158
+ CodeMirror.defineMIME("text/ecmascript", "javascript");
12159
+ CodeMirror.defineMIME("application/javascript", "javascript");
12160
+ CodeMirror.defineMIME("application/x-javascript", "javascript");
12161
+ CodeMirror.defineMIME("application/ecmascript", "javascript");
12162
+ CodeMirror.defineMIME("application/json", { name: "javascript", json: true });
12163
+ CodeMirror.defineMIME("application/x-json", { name: "javascript", json: true });
12164
+ CodeMirror.defineMIME("application/manifest+json", { name: "javascript", json: true });
12165
+ CodeMirror.defineMIME("application/ld+json", { name: "javascript", jsonld: true });
12166
+ CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
12167
+ CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
12163
12168
 
12164
- });
12169
+ });
12165
12170
  } ());
12171
+ return javascript.exports;
12172
+ }
12173
+
12174
+ requireJavascript();
12166
12175
 
12167
12176
  var css$2 = {exports: {}};
12168
12177
 
@@ -13459,7 +13468,7 @@ function requireXml () {
13459
13468
  // Distributed under an MIT license: https://codemirror.net/LICENSE
13460
13469
 
13461
13470
  (function(mod) {
13462
- mod(requireCodemirror(), requireXml(), javascript.exports, css$2.exports);
13471
+ mod(requireCodemirror(), requireXml(), requireJavascript(), css$2.exports);
13463
13472
  })(function(CodeMirror) {
13464
13473
 
13465
13474
  var defaultTags = {
@@ -15322,7 +15331,7 @@ function requirePug () {
15322
15331
  // Distributed under an MIT license: https://codemirror.net/LICENSE
15323
15332
 
15324
15333
  (function(mod) {
15325
- mod(requireCodemirror(), javascript.exports, css$2.exports, htmlmixed.exports);
15334
+ mod(requireCodemirror(), requireJavascript(), css$2.exports, htmlmixed.exports);
15326
15335
  })(function(CodeMirror) {
15327
15336
 
15328
15337
  CodeMirror.defineMode("pug", function (config) {
@@ -16356,7 +16365,7 @@ function requireHandlebars () {
16356
16365
  mod(requireCodemirror(),
16357
16366
  requireOverlay(),
16358
16367
  requireXml(),
16359
- javascript.exports,
16368
+ requireJavascript(),
16360
16369
  requireCoffeescript(),
16361
16370
  css$2.exports,
16362
16371
  requireSass(),
@@ -33026,7 +33035,13 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
33026
33035
  editor.on("blur", () => {
33027
33036
  emit("change", prettier.format(
33028
33037
  editor.getValue(),
33029
- { parser: "html", plugins: [parserBabel, parserHtml] }
33038
+ {
33039
+ parser: "html",
33040
+ plugins: [parserBabel, parserHtml],
33041
+ semi: false,
33042
+ singleQuote: true,
33043
+ arrowParens: "avoid"
33044
+ }
33030
33045
  ));
33031
33046
  });
33032
33047
  watchEffect(() => {