From 31e77b975ed0bf14f68f9b0f6608bbe78d694bf0 Mon Sep 17 00:00:00 2001
From: impinball
Punctuation token types. Again, the type property is purely for debugging.
var _bracketL = {type: "[", beforeExpr: true}, _bracketR = {type: "]"}, _braceL = {type: "{", beforeExpr: true};
var _braceR = {type: "}"}, _parenL = {type: "(", beforeExpr: true}, _parenR = {type: ")"};
var _comma = {type: ",", beforeExpr: true}, _semi = {type: ";", beforeExpr: true};
- var _colon = {type: ":", beforeExpr: true}, _dot = {type: "."}, _question = {type: "?", beforeExpr: true};Operators. These carry several kinds of properties to help the + var _colon = {type: ":", beforeExpr: true}, _dot = {type: "."}, _ellipsis = {type: "..."}, _question = {type: "?", beforeExpr: true};
Operators. These carry several kinds of properties to help the parser use them properly (the presence of these properties is what categorizes them as operators).
@@ -217,8 +217,8 @@ in AssignmentExpression nodes.Provide access to the token types for external users of the tokenizer.
exports.tokTypes = {bracketL: _bracketL, bracketR: _bracketR, braceL: _braceL, braceR: _braceR,
parenL: _parenL, parenR: _parenR, comma: _comma, semi: _semi, colon: _colon,
- dot: _dot, question: _question, slash: _slash, eq: _eq, name: _name, eof: _eof,
- num: _num, regexp: _regexp, string: _string};
+ dot: _dot, ellipsis: _ellipsis, question: _question, slash: _slash, eq: _eq,
+ name: _name, eof: _eof, num: _num, regexp: _regexp, string: _string};
for (var kw in keywordTypes) exports.tokTypes["_" + kw] = keywordTypes[kw];This is a trick taken from Esprima. It turns out that, on
non-Chrome browsers, to check whether a string is in a set, a
predicate containing a big ugly switch statement is faster than
@@ -376,8 +376,14 @@ into it.
tokRegexpAllowed trick does not work. See parseStatement. function readToken_dot() {
var next = input.charCodeAt(tokPos + 1);
if (next >= 48 && next <= 57) return readNumber(true);
- ++tokPos;
- return finishToken(_dot);
+ var next2 = input.charCodeAt(tokPos + 2);
+ if (options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.'
+ tokPos += 3;
+ return finishToken(_ellipsis);
+ } else {
+ ++tokPos;
+ return finishToken(_dot);
+ }
}
function readToken_slash() { // '/'
@@ -448,7 +454,7 @@ into it.
function getTokenFromCode(code) {
switch(code) {The interpretation of a dot depends on whether it is followed -by a digit.
case 46: // '.'
+by a digit or another two dots. case 46: // '.'
return readToken_dot();Punctuation tokens.
case 40: ++tokPos; return finishToken(_parenL);
case 41: ++tokPos; return finishToken(_parenR);
case 59: ++tokPos; return finishToken(_semi);
@@ -1280,11 +1286,22 @@ init properties are also not allowed to be repeated. Start a new scope with regard to labels and the inFunction
flag (restore them to their old value afterwards).
var oldInFunc = inFunction, oldLabels = labels;
inFunction = true; labels = [];