Vergleich admin/jscripts/codemirror/mode/javascript/javascript.js - 1.8.1 - 1.8.25

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 2Zeile 2
// Distributed under an MIT license: http://codemirror.net/LICENSE

// Distributed under an MIT license: http://codemirror.net/LICENSE


// TODO actually recognize syntax of TypeScript constructs

 

(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS


(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS

Zeile 19Zeile 17
  var jsonldMode = parserConfig.jsonld;
var jsonMode = parserConfig.json || jsonldMode;
var isTS = parserConfig.typescript;

  var jsonldMode = parserConfig.jsonld;
var jsonMode = parserConfig.json || jsonldMode;
var isTS = parserConfig.typescript;

 
  var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;


// Tokenizer



// Tokenizer


Zeile 29Zeile 28

var jsKeywords = {
"if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,


var jsKeywords = {
"if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,

      "return": C, "break": C, "continue": C, "new": C, "delete": C, "throw": C, "debugger": C,

      "return": C, "break": C, "continue": C, "new": kw("new"), "delete": C, "void": C, "throw": C, "debugger": C,

      "var": kw("var"), "const": kw("var"), "let": kw("var"),
"function": kw("function"), "catch": kw("catch"),
"for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
"in": operator, "typeof": operator, "instanceof": operator,
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,

      "var": kw("var"), "const": kw("var"), "let": kw("var"),
"function": kw("function"), "catch": kw("catch"),
"for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
"in": operator, "typeof": operator, "instanceof": operator,
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,

      "this": kw("this"), "module": kw("module"), "class": kw("class"), "super": kw("atom"),
"yield": C, "export": kw("export"), "import": kw("import"), "extends": C


      "this": kw("this"), "class": kw("class"), "super": kw("atom"),
"yield": C, "export": kw("export"), "import": kw("import"), "extends": C,
"await": C

    };

// Extend the 'normal' keywords with the TypeScript language extensions
if (isTS) {

    };

// Extend the 'normal' keywords with the TypeScript language extensions
if (isTS) {

      var type = {type: "variable", style: "variable-3"};

      var type = {type: "variable", style: "type"};

      var tsKeywords = {
// object-like things

      var tsKeywords = {
// object-like things

        "interface": kw("interface"),
"extends": kw("extends"),
"constructor": kw("constructor"),



        "interface": kw("class"),
"implements": C,
"namespace": C,
"module": kw("module"),
"enum": kw("module"),


// scope modifiers


// scope modifiers

        "public": kw("public"),
"private": kw("private"),
"protected": kw("protected"),
"static": kw("static"),


        "public": kw("modifier"),
"private": kw("modifier"),
"protected": kw("modifier"),
"abstract": kw("modifier"),
"readonly": kw("modifier"),


// types


// types

        "string": type, "number": type, "bool": type, "any": type

        "string": type, "number": type, "boolean": type, "any": type

      };

for (var attr in tsKeywords) {

      };

for (var attr in tsKeywords) {

Zeile 66Zeile 69
    return jsKeywords;
}();


    return jsKeywords;
}();


  var isOperatorChar = /[+\-*&%=<>!?|~^]/;

  var isOperatorChar = /[+\-*&%=<>!?|~^@]/;

  var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;

function readRegexp(stream) {

  var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;

function readRegexp(stream) {

Zeile 103Zeile 106
      return ret("=>", "operator");
} else if (ch == "0" && stream.eat(/x/i)) {
stream.eatWhile(/[\da-f]/i);

      return ret("=>", "operator");
} else if (ch == "0" && stream.eat(/x/i)) {
stream.eatWhile(/[\da-f]/i);

 
      return ret("number", "number");
} else if (ch == "0" && stream.eat(/o/i)) {
stream.eatWhile(/[0-7]/i);
return ret("number", "number");
} else if (ch == "0" && stream.eat(/b/i)) {
stream.eatWhile(/[01]/i);

      return ret("number", "number");
} else if (/\d/.test(ch)) {
stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);

      return ret("number", "number");
} else if (/\d/.test(ch)) {
stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);

Zeile 114Zeile 123
      } else if (stream.eat("/")) {
stream.skipToEnd();
return ret("comment", "comment");

      } else if (stream.eat("/")) {
stream.skipToEnd();
return ret("comment", "comment");

      } else if (state.lastType == "operator" || state.lastType == "keyword c" ||
state.lastType == "sof" || /^[\[{}\(,;:]$/.test(state.lastType)) {

      } else if (expressionAllowed(stream, state, 1)) {


        readRegexp(stream);

        readRegexp(stream);

        stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla

        stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/);

        return ret("regexp", "string-2");
} else {
stream.eatWhile(isOperatorChar);
return ret("operator", "operator", stream.current());

        return ret("regexp", "string-2");
} else {
stream.eatWhile(isOperatorChar);
return ret("operator", "operator", stream.current());

      }

      }

    } else if (ch == "`") {
state.tokenize = tokenQuasi;
return tokenQuasi(stream, state);

    } else if (ch == "`") {
state.tokenize = tokenQuasi;
return tokenQuasi(stream, state);

Zeile 130Zeile 138
      stream.skipToEnd();
return ret("error", "error");
} else if (isOperatorChar.test(ch)) {

      stream.skipToEnd();
return ret("error", "error");
} else if (isOperatorChar.test(ch)) {

      stream.eatWhile(isOperatorChar);


      if (ch != ">" || !state.lexical || state.lexical.type != ">")
stream.eatWhile(isOperatorChar);

      return ret("operator", "operator", stream.current());

      return ret("operator", "operator", stream.current());

    } else {
stream.eatWhile(/[\w\$_]/);
var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
return (known && state.lastType != ".") ? ret(known.type, known.style, word) :
ret("variable", "variable", word);








    } else if (wordRE.test(ch)) {
stream.eatWhile(wordRE);
var word = stream.current()
if (state.lastType != ".") {
if (keywords.propertyIsEnumerable(word)) {
var kw = keywords[word]
return ret(kw.type, kw.style, word)
}
if (word == "async" && stream.match(/^\s*[\(\w]/, false))
return ret("async", "keyword", word)
}
return ret("variable", "variable", word)

    }
}


    }
}


Zeile 192Zeile 208
    if (state.fatArrowAt) state.fatArrowAt = null;
var arrow = stream.string.indexOf("=>", stream.start);
if (arrow < 0) return;

    if (state.fatArrowAt) state.fatArrowAt = null;
var arrow = stream.string.indexOf("=>", stream.start);
if (arrow < 0) return;

 

if (isTS) { // Try to skip TypeScript return type declarations after the arguments
var m = /:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(stream.string.slice(stream.start, arrow))
if (m) arrow = m.index
}


var depth = 0, sawSomething = false;
for (var pos = arrow - 1; pos >= 0; --pos) {


var depth = 0, sawSomething = false;
for (var pos = arrow - 1; pos >= 0; --pos) {

Zeile 199Zeile 220
      var bracket = brackets.indexOf(ch);
if (bracket >= 0 && bracket < 3) {
if (!depth) { ++pos; break; }

      var bracket = brackets.indexOf(ch);
if (bracket >= 0 && bracket < 3) {
if (!depth) { ++pos; break; }

        if (--depth == 0) break;

        if (--depth == 0) { if (ch == "(") sawSomething = true; break; }

      } else if (bracket >= 3 && bracket < 6) {
++depth;

      } else if (bracket >= 3 && bracket < 6) {
++depth;

      } else if (/[$\w]/.test(ch)) {

      } else if (wordRE.test(ch)) {

        sawSomething = true;

        sawSomething = true;

 
      } else if (/["'\/]/.test(ch)) {
return;

      } else if (sawSomething && !depth) {
++pos;
break;

      } else if (sawSomething && !depth) {
++pos;
break;

Zeile 272Zeile 295
      return false;
}
var state = cx.state;

      return false;
}
var state = cx.state;

 
    cx.marked = "def";

    if (state.context) {

    if (state.context) {

      cx.marked = "def";

 
      if (inList(state.localVars)) return;
state.localVars = {name: varname, next: state.localVars};
} else {

      if (inList(state.localVars)) return;
state.localVars = {name: varname, next: state.localVars};
} else {

Zeile 298Zeile 321
    var result = function() {
var state = cx.state, indent = state.indented;
if (state.lexical.type == "stat") indent = state.lexical.indented;

    var result = function() {
var state = cx.state, indent = state.indented;
if (state.lexical.type == "stat") indent = state.lexical.indented;

 
      else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev)
indent = outer.indented;

      state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
};
result.lex = true;

      state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
};
result.lex = true;

Zeile 318Zeile 343
      if (type == wanted) return cont();
else if (wanted == ";") return pass();
else return cont(exp);

      if (type == wanted) return cont();
else if (wanted == ";") return pass();
else return cont(exp);

    };

    };

    return exp;
}

function statement(type, value) {
if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex);

    return exp;
}

function statement(type, value) {
if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex);

    if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);

    if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);

    if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
if (type == "{") return cont(pushlex("}"), block, poplex);
if (type == ";") return cont();
if (type == "if") {
if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
cx.state.cc.pop()();

    if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
if (type == "{") return cont(pushlex("}"), block, poplex);
if (type == ";") return cont();
if (type == "if") {
if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
cx.state.cc.pop()();

      return cont(pushlex("form"), expression, statement, poplex, maybeelse);

      return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);

    }
if (type == "function") return cont(functiondef);
if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);

    }
if (type == "function") return cont(functiondef);
if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);

    if (type == "variable") return cont(pushlex("stat"), maybelabel);
if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),











    if (type == "variable") {
if (isTS && value == "type") {
cx.marked = "keyword"
return cont(typeexpr, expect("operator"), typeexpr, expect(";"));
} if (isTS && value == "declare") {
cx.marked = "keyword"
return cont(statement)
} else {
return cont(pushlex("stat"), maybelabel);
}
}
if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"),

                                      block, poplex, poplex);
if (type == "case") return cont(expression, expect(":"));
if (type == "default") return cont(expect(":"));
if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
statement, poplex, popcontext);

                                      block, poplex, poplex);
if (type == "case") return cont(expression, expect(":"));
if (type == "default") return cont(expect(":"));
if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
statement, poplex, popcontext);

    if (type == "module") return cont(pushlex("form"), pushcontext, afterModule, popcontext, poplex);

 
    if (type == "class") return cont(pushlex("form"), className, poplex);

    if (type == "class") return cont(pushlex("form"), className, poplex);

    if (type == "export") return cont(pushlex("form"), afterExport, poplex);
if (type == "import") return cont(pushlex("form"), afterImport, poplex);




    if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
if (type == "module") return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex)
if (type == "async") return cont(statement)
if (value == "@") return cont(expression, statement)

    return pass(pushlex("stat"), expression, expect(";"), poplex);
}
function expression(type) {

    return pass(pushlex("stat"), expression, expect(";"), poplex);
}
function expression(type) {

Zeile 353Zeile 390
  }
function expressionNoComma(type) {
return expressionInner(type, true);

  }
function expressionNoComma(type) {
return expressionInner(type, true);

 
  }
function parenExpr(type) {
if (type != "(") return pass()
return cont(pushlex(")"), expression, expect(")"), poplex)

  }
function expressionInner(type, noComma) {
if (cx.state.fatArrowAt == cx.stream.start) {
var body = noComma ? arrowBodyNoComma : arrowBody;

  }
function expressionInner(type, noComma) {
if (cx.state.fatArrowAt == cx.stream.start) {
var body = noComma ? arrowBodyNoComma : arrowBody;

      if (type == "(") return cont(pushcontext, pushlex(")"), commasep(pattern, ")"), poplex, expect("=>"), body, popcontext);

      if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, expect("=>"), body, popcontext);

      else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);

      else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);

    }


    }


    var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
if (type == "function") return cont(functiondef, maybeop);

    var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
if (type == "function") return cont(functiondef, maybeop);

    if (type == "keyword c") return cont(noComma ? maybeexpressionNoComma : maybeexpression);
if (type == "(") return cont(pushlex(")"), maybeexpression, comprehension, expect(")"), poplex, maybeop);


    if (type == "class") return cont(pushlex("form"), classExpression, poplex);
if (type == "keyword c" || type == "async") return cont(noComma ? maybeexpressionNoComma : maybeexpression);
if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);

    if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
if (type == "{") return contCommasep(objprop, "}", null, maybeop);

    if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
if (type == "{") return contCommasep(objprop, "}", null, maybeop);

    if (type == "quasi") { return pass(quasi, maybeop); }


    if (type == "quasi") return pass(quasi, maybeop);
if (type == "new") return cont(maybeTarget(noComma));

    return cont();

    return cont();

  }

  }

  function maybeexpression(type) {
if (type.match(/[;\}\)\],]/)) return pass();
return pass(expression);

  function maybeexpression(type) {
if (type.match(/[;\}\)\],]/)) return pass();
return pass(expression);

Zeile 388Zeile 431
  function maybeoperatorNoComma(type, value, noComma) {
var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
var expr = noComma == false ? expression : expressionNoComma;

  function maybeoperatorNoComma(type, value, noComma) {
var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
var expr = noComma == false ? expression : expressionNoComma;

    if (value == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);

    if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);

    if (type == "operator") {

    if (type == "operator") {

      if (/\+\+|--/.test(value)) return cont(me);

      if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me);

      if (value == "?") return cont(expression, expect(":"), expr);
return cont(expr);
}

      if (value == "?") return cont(expression, expect(":"), expr);
return cont(expr);
}

Zeile 399Zeile 442
    if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
if (type == ".") return cont(property, me);
if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);

    if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
if (type == ".") return cont(property, me);
if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);

 
    if (isTS && value == "as") { cx.marked = "keyword"; return cont(typeexpr, me) }
if (type == "regexp") {
cx.state.lastType = cx.marked = "operator"
cx.stream.backUp(cx.stream.pos - cx.stream.start - 1)
return cont(expr)
}

  }
function quasi(type, value) {
if (type != "quasi") return pass();

  }
function quasi(type, value) {
if (type != "quasi") return pass();

Zeile 414Zeile 463
  }
function arrowBody(type) {
findFatArrow(cx.stream, cx.state);

  }
function arrowBody(type) {
findFatArrow(cx.stream, cx.state);

    if (type == "{") return pass(statement);
return pass(expression);
}

    return pass(type == "{" ? statement : expression);
}


  function arrowBodyNoComma(type) {
findFatArrow(cx.stream, cx.state);

  function arrowBodyNoComma(type) {
findFatArrow(cx.stream, cx.state);

    if (type == "{") return pass(statement);
return pass(expressionNoComma);













    return pass(type == "{" ? statement : expressionNoComma);
}
function maybeTarget(noComma) {
return function(type) {
if (type == ".") return cont(noComma ? targetNoComma : target);
else if (type == "variable" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma)
else return pass(noComma ? expressionNoComma : expression);
};
}
function target(_, value) {
if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorComma); }
}
function targetNoComma(_, value) {
if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorNoComma); }

  }
function maybelabel(type) {
if (type == ":") return cont(poplex, statement);

  }
function maybelabel(type) {
if (type == ":") return cont(poplex, statement);

Zeile 430Zeile 490
    if (type == "variable") {cx.marked = "property"; return cont();}
}
function objprop(type, value) {

    if (type == "variable") {cx.marked = "property"; return cont();}
}
function objprop(type, value) {

    if (type == "variable" || cx.style == "keyword") {




    if (type == "async") {
cx.marked = "property";
return cont(objprop);
} else if (type == "variable" || cx.style == "keyword") {

      cx.marked = "property";
if (value == "get" || value == "set") return cont(getterSetter);

      cx.marked = "property";
if (value == "get" || value == "set") return cont(getterSetter);

 
      var m // Work around fat-arrow-detection complication for detecting typescript typed arrow params
if (isTS && cx.state.fatArrowAt == cx.stream.start && (m = cx.stream.match(/^\s*:\s*/, false)))
cx.state.fatArrowAt = cx.stream.pos + m[0].length

      return cont(afterprop);
} else if (type == "number" || type == "string") {
cx.marked = jsonldMode ? "property" : (cx.style + " property");
return cont(afterprop);
} else if (type == "jsonld-keyword") {
return cont(afterprop);

      return cont(afterprop);
} else if (type == "number" || type == "string") {
cx.marked = jsonldMode ? "property" : (cx.style + " property");
return cont(afterprop);
} else if (type == "jsonld-keyword") {
return cont(afterprop);

 
    } else if (type == "modifier") {
return cont(objprop)

    } else if (type == "[") {
return cont(expression, expect("]"), afterprop);

    } else if (type == "[") {
return cont(expression, expect("]"), afterprop);

    }
}





    } else if (type == "spread") {
return cont(expression, afterprop);
} else if (type == ":") {
return pass(afterprop)
}
}

  function getterSetter(type) {
if (type != "variable") return pass(afterprop);
cx.marked = "property";

  function getterSetter(type) {
if (type != "variable") return pass(afterprop);
cx.marked = "property";

Zeile 452Zeile 524
    if (type == ":") return cont(expressionNoComma);
if (type == "(") return pass(functiondef);
}

    if (type == ":") return cont(expressionNoComma);
if (type == "(") return pass(functiondef);
}

  function commasep(what, end) {
function proceed(type) {
if (type == ",") {

  function commasep(what, end, sep) {
function proceed(type, value) {
if (sep ? sep.indexOf(type) > -1 : type == ",") {

        var lex = cx.state.lexical;
if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;

        var lex = cx.state.lexical;
if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;

        return cont(what, proceed);




        return cont(function(type, value) {
if (type == end || value == end) return pass()
return pass(what)
}, proceed);

      }

      }

      if (type == end) return cont();

      if (type == end || value == end) return cont();

      return cont(expect(end));
}

      return cont(expect(end));
}

    return function(type) {
if (type == end) return cont();

    return function(type, value) {
if (type == end || value == end) return cont();

      return pass(what, proceed);
};
}

      return pass(what, proceed);
};
}

Zeile 476Zeile 551
    if (type == "}") return cont();
return pass(statement, block);
}

    if (type == "}") return cont();
return pass(statement, block);
}

  function maybetype(type) {
if (isTS && type == ":") return cont(typedef);












































  function maybetype(type, value) {
if (isTS) {
if (type == ":") return cont(typeexpr);
if (value == "?") return cont(maybetype);
}
}
function typeexpr(type, value) {
if (type == "variable") {
if (value == "keyof") {
cx.marked = "keyword"
return cont(typeexpr)
} else {
cx.marked = "type"
return cont(afterType)
}
}
if (type == "string" || type == "number" || type == "atom") return cont(afterType);
if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)
if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType)
if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
}
function maybeReturnType(type) {
if (type == "=>") return cont(typeexpr)
}
function typeprop(type, value) {
if (type == "variable" || cx.style == "keyword") {
cx.marked = "property"
return cont(typeprop)
} else if (value == "?") {
return cont(typeprop)
} else if (type == ":") {
return cont(typeexpr)
} else if (type == "[") {
return cont(expression, maybetype, expect("]"), typeprop)
}
}
function typearg(type) {
if (type == "variable") return cont(typearg)
else if (type == ":") return cont(typeexpr)
}
function afterType(type, value) {
if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
if (value == "|" || type == ".") return cont(typeexpr)
if (type == "[") return cont(expect("]"), afterType)
if (value == "extends") return cont(typeexpr)

  }

  }

  function typedef(type) {
if (type == "variable"){cx.marked = "variable-3"; return cont();}

  function maybeTypeArgs(_, value) {
if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)

  }
function vardef() {
return pass(pattern, maybetype, maybeAssign, vardefCont);
}
function pattern(type, value) {

  }
function vardef() {
return pass(pattern, maybetype, maybeAssign, vardefCont);
}
function pattern(type, value) {

 
    if (type == "modifier") return cont(pattern)

    if (type == "variable") { register(value); return cont(); }

    if (type == "variable") { register(value); return cont(); }

 
    if (type == "spread") return cont(pattern);

    if (type == "[") return contCommasep(pattern, "]");
if (type == "{") return contCommasep(proppattern, "}");
}

    if (type == "[") return contCommasep(pattern, "]");
if (type == "{") return contCommasep(proppattern, "}");
}

Zeile 496Zeile 616
      return cont(maybeAssign);
}
if (type == "variable") cx.marked = "property";

      return cont(maybeAssign);
}
if (type == "variable") cx.marked = "property";

 
    if (type == "spread") return cont(pattern);
if (type == "}") return pass();

    return cont(expect(":"), pattern, maybeAssign);
}
function maybeAssign(_type, value) {

    return cont(expect(":"), pattern, maybeAssign);
}
function maybeAssign(_type, value) {

Zeile 531Zeile 653
  function functiondef(type, value) {
if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
if (type == "variable") {register(value); return cont(functiondef);}

  function functiondef(type, value) {
if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
if (type == "variable") {register(value); return cont(functiondef);}

    if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, statement, popcontext);


    if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, maybetype, statement, popcontext);
if (isTS && value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, functiondef)

  }

  }

  function funarg(type) {
if (type == "spread") return cont(funarg);
return pass(pattern, maybetype);







  function funarg(type, value) {
if (value == "@") cont(expression, funarg)
if (type == "spread" || type == "modifier") return cont(funarg);
return pass(pattern, maybetype, maybeAssign);
}
function classExpression(type, value) {
// Class expressions may have an optional name.
if (type == "variable") return className(type, value);
return classNameAfter(type, value);

  }
function className(type, value) {
if (type == "variable") {register(value); return cont(classNameAfter);}

  }
function className(type, value) {
if (type == "variable") {register(value); return cont(classNameAfter);}

  }

  }

  function classNameAfter(type, value) {

  function classNameAfter(type, value) {

    if (value == "extends") return cont(expression, classNameAfter);



    if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, classNameAfter)
if (value == "extends" || value == "implements" || (isTS && type == ","))
return cont(isTS ? typeexpr : expression, classNameAfter);

    if (type == "{") return cont(pushlex("}"), classBody, poplex);

    if (type == "{") return cont(pushlex("}"), classBody, poplex);

  }

  }

  function classBody(type, value) {

  function classBody(type, value) {

 
    if (type == "modifier" || type == "async" ||
(type == "variable" &&
(value == "static" || value == "get" || value == "set") &&
cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) {
cx.marked = "keyword";
return cont(classBody);
}

    if (type == "variable" || cx.style == "keyword") {
cx.marked = "property";

    if (type == "variable" || cx.style == "keyword") {
cx.marked = "property";

      if (value == "get" || value == "set") return cont(classGetterSetter, functiondef, classBody);
return cont(functiondef, classBody);

      return cont(isTS ? classfield : functiondef, classBody);


    }

    }

 
    if (type == "[")
return cont(expression, expect("]"), isTS ? classfield : functiondef, classBody)

    if (value == "*") {
cx.marked = "keyword";
return cont(classBody);
}
if (type == ";") return cont(classBody);
if (type == "}") return cont();

    if (value == "*") {
cx.marked = "keyword";
return cont(classBody);
}
if (type == ";") return cont(classBody);
if (type == "}") return cont();

 
    if (value == "@") return cont(expression, classBody)

  }

  }

  function classGetterSetter(type) {
if (type != "variable") return pass();
cx.marked = "property";
return cont();
}
function afterModule(type, value) {
if (type == "string") return cont(statement);
if (type == "variable") { register(value); return cont(maybeFrom); }

  function classfield(type, value) {
if (value == "?") return cont(classfield)
if (type == ":") return cont(typeexpr, maybeAssign)
if (value == "=") return cont(expressionNoComma)
return pass(functiondef)




  }

  }

  function afterExport(_type, value) {

  function afterExport(type, value) {

    if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }

    if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }

 
    if (type == "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";"));

    return pass(statement);

    return pass(statement);

 
  }
function exportField(type, value) {
if (value == "as") { cx.marked = "keyword"; return cont(expect("variable")); }
if (type == "variable") return pass(expressionNoComma, exportField);

  }
function afterImport(type) {
if (type == "string") return cont();

  }
function afterImport(type) {
if (type == "string") return cont();

    return pass(importSpec, maybeFrom);

    return pass(importSpec, maybeMoreImports, maybeFrom);

  }
function importSpec(type, value) {
if (type == "{") return contCommasep(importSpec, "}");
if (type == "variable") register(value);

  }
function importSpec(type, value) {
if (type == "{") return contCommasep(importSpec, "}");
if (type == "variable") register(value);

    return cont();
}








    if (value == "*") cx.marked = "keyword";
return cont(maybeAs);
}
function maybeMoreImports(type) {
if (type == ",") return cont(importSpec, maybeMoreImports)
}
function maybeAs(_type, value) {
if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
}

  function maybeFrom(_type, value) {
if (value == "from") { cx.marked = "keyword"; return cont(expression); }

  function maybeFrom(_type, value) {
if (value == "from") { cx.marked = "keyword"; return cont(expression); }

  }

  }

  function arrayLiteral(type) {
if (type == "]") return cont();

  function arrayLiteral(type) {
if (type == "]") return cont();

    return pass(expressionNoComma, maybeArrayComprehension);
}
function maybeArrayComprehension(type) {
if (type == "for") return pass(comprehension, expect("]"));
if (type == ",") return cont(commasep(expressionNoComma, "]"));

 
    return pass(commasep(expressionNoComma, "]"));

    return pass(commasep(expressionNoComma, "]"));

  }
function comprehension(type) {
if (type == "for") return cont(forspec, comprehension);
if (type == "if") return cont(expression, comprehension);









  }

function isContinuedStatement(state, textAfter) {
return state.lastType == "operator" || state.lastType == "," ||
isOperatorChar.test(textAfter.charAt(0)) ||
/[,.]/.test(textAfter.charAt(0));
}

function expressionAllowed(stream, state, backUp) {
return state.tokenize == tokenBase &&
/^(?:operator|sof|keyword [bc]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
(state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))

  }

// Interface

  }

// Interface

Zeile 608Zeile 760
        lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
localVars: parserConfig.localVars,
context: parserConfig.localVars && {vars: parserConfig.localVars},

        lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
localVars: parserConfig.localVars,
context: parserConfig.localVars && {vars: parserConfig.localVars},

        indented: 0

        indented: basecolumn || 0

      };
if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
state.globalVars = parserConfig.globalVars;
return state;

      };
if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
state.globalVars = parserConfig.globalVars;
return state;

    },

    },


token: function(stream, state) {
if (stream.sol()) {


token: function(stream, state) {
if (stream.sol()) {

Zeile 632Zeile 784
    indent: function(state, textAfter) {
if (state.tokenize == tokenComment) return CodeMirror.Pass;
if (state.tokenize != tokenBase) return 0;

    indent: function(state, textAfter) {
if (state.tokenize == tokenComment) return CodeMirror.Pass;
if (state.tokenize != tokenBase) return 0;

      var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;

      var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top

      // Kludge to prevent 'maybelse' from blocking lexical scope pops
if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
var c = state.cc[i];
if (c == poplex) lexical = lexical.prev;
else if (c != maybeelse) break;
}

      // Kludge to prevent 'maybelse' from blocking lexical scope pops
if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
var c = state.cc[i];
if (c == poplex) lexical = lexical.prev;
else if (c != maybeelse) break;
}

      if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;





      while ((lexical.type == "stat" || lexical.type == "form") &&
(firstChar == "}" || ((top = state.cc[state.cc.length - 1]) &&
(top == maybeoperatorComma || top == maybeoperatorNoComma) &&
!/^[,\.=+\-*:?[\(]/.test(textAfter))))
lexical = lexical.prev;

      if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
lexical = lexical.prev;
var type = lexical.type, closing = firstChar == type;

      if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
lexical = lexical.prev;
var type = lexical.type, closing = firstChar == type;

Zeile 648Zeile 804
      else if (type == "form" && firstChar == "{") return lexical.indented;
else if (type == "form") return lexical.indented + indentUnit;
else if (type == "stat")

      else if (type == "form" && firstChar == "{") return lexical.indented;
else if (type == "form") return lexical.indented + indentUnit;
else if (type == "stat")

        return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? statementIndent || indentUnit : 0);

        return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0);

      else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
else if (lexical.align) return lexical.column + (closing ? 0 : 1);
else return lexical.indented + (closing ? 0 : indentUnit);
},


      else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
else if (lexical.align) return lexical.column + (closing ? 0 : 1);
else return lexical.indented + (closing ? 0 : indentUnit);
},


    electricChars: ":{}",

    electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,

    blockCommentStart: jsonMode ? null : "/*",
blockCommentEnd: jsonMode ? null : "*/",
lineComment: jsonMode ? null : "//",
fold: "brace",

    blockCommentStart: jsonMode ? null : "/*",
blockCommentEnd: jsonMode ? null : "*/",
lineComment: jsonMode ? null : "//",
fold: "brace",

 
    closeBrackets: "()[]{}''\"\"``",


helperType: jsonMode ? "json" : "javascript",
jsonldMode: jsonldMode,


helperType: jsonMode ? "json" : "javascript",
jsonldMode: jsonldMode,

    jsonMode: jsonMode








    jsonMode: jsonMode,

expressionAllowed: expressionAllowed,

skipExpression: function(state) {
var top = state.cc[state.cc.length - 1]
if (top == expression || top == expressionNoComma) state.cc.pop()
}

  };
});


  };
});


CodeMirror.registerHelper("wordChars", "javascript", /[\\w$]/);

CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);


CodeMirror.defineMIME("text/javascript", "javascript");
CodeMirror.defineMIME("text/ecmascript", "javascript");


CodeMirror.defineMIME("text/javascript", "javascript");
CodeMirror.defineMIME("text/ecmascript", "javascript");