From 330084f9939f9492d57df69a9c4719946e6fe199 Mon Sep 17 00:00:00 2001
From: Marijn Haverbeke
The keywords that denote values.
var _null = {keyword: "null", atomValue: null}, _true = {keyword: "true", atomValue: true};
+ var _while = {keyword: "while", isLoop: true}, _with = {keyword: "with"}, _new = {keyword: "new", beforeExpr: true};
+ var _this = {keyword: "this"};The keywords that denote values.
var _null = {keyword: "null", atomValue: null}, _true = {keyword: "true", atomValue: true};
var _false = {keyword: "false", atomValue: false};Some keywords are treated as regular operators. in sometimes
(when parsing for) needs to be tested against specifically, so
we assign a variable name to it for quick comparing.
var _in = {keyword: "in", binop: 7, beforeExpr: true};Map keyword names to token types.
var keywordTypes = {"break": _break, "case": _case, "catch": _catch,
@@ -127,7 +128,7 @@ we assign a variable name to it for quick comparing. Punctuation token types. Again, the type property is purely for debugging.
var _bracketL = {type: "[", beforeExpr: true}, _bracketR = {type: "]"}, _braceL = {type: "{", beforeExpr: true};
@@ -190,7 +191,7 @@ switch first dispatches on the lengths, to save on comparisons.
compareTo(words);
}
return new Function("str", f);
- }The ECMAScript 3 reserved word list.
var isReservedWord3 = makePredicate("abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile");ECMAScript 5 reserved words.
var isReservedWord5 = makePredicate("class enum extends super const export import");The additional reserved words in strict mode.
var isStrictReservedWord = makePredicate("implements interface let package private protected public static yield");The forbidden variable names in strict mode.
var isStrictBadIdWord = makePredicate("eval arguments");And the keywords.
var isKeyword = makePredicate("break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in");Big ugly regular expressions that match characters in the + }
The ECMAScript 3 reserved word list.
var isReservedWord3 = makePredicate("abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile");ECMAScript 5 reserved words.
var isReservedWord5 = makePredicate("class enum extends super const export import");The additional reserved words in strict mode.
var isStrictReservedWord = makePredicate("implements interface let package private protected public static yield");The forbidden variable names in strict mode.
var isStrictBadIdWord = makePredicate("eval arguments");And the keywords.
var isKeyword = makePredicate("break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this");Big ugly regular expressions that match characters in the whitespace, identifier, and identifier-start categories. These are only applied when a character is found to actually have a code point above 128.
var nonASCIIwhitespace = /[\u1680\u180E\u2000-\u200A\u202F\u205F\u3000\uFEFF]/;
@@ -353,7 +354,6 @@ of the type given by its first argument. If we are here, we either found a non-ASCII identifier character, or something that's entirely disallowed.
var ch = String.fromCharCode(code);
@@ -1012,13 +1012,12 @@ expression, an expression started by a keyword like function or
new, or an expression wrapped in punctuation like (), [],
or {}. function parseExprAtom() {
switch (tokType) {
+ case _this:
+ var node = startNode();
+ next();
+ return finishNode(node, "ThisExpression");
case _name:
- if (tokVal === "this") {
- var node = startNode();
- next();
- return finishNode(node, "ThisExpression");
- } else return parseIdent();
-
+ return parseIdent();
case _num: case _string: case _regexp:
var node = startNode();
node.value = tokVal;