Permalink
Browse files

Merge future reseverd words and keywords.

Since the parser does not distinguish betwen future reserved words and
keywords, just merge these two.

No detectable performance impact is observed.

http://code.google.com/p/esprima/issues/detail?id=65
  • Loading branch information...
1 parent 6e462e3 commit 82b7d727d9b28ed7a36a4510363b9e93842a46c2 @ariya ariya committed Dec 4, 2011
Showing with 11 additions and 22 deletions.
  1. +11 −22 esprima.js
View
33 esprima.js
@@ -40,13 +40,12 @@ parseStatement: true */
Token = {
BooleanLiteral: 1,
EOF: 2,
- FutureReservedWord: 3,
- Identifier: 4,
- Keyword: 5,
- NullLiteral: 6,
- NumericLiteral: 7,
- Punctuator: 8,
- StringLiteral: 9
+ Identifier: 3,
+ Keyword: 4,
+ NullLiteral: 5,
+ NumericLiteral: 6,
+ Punctuator: 7,
+ StringLiteral: 8
};
Syntax = {
@@ -139,9 +138,12 @@ parseStatement: true */
}
// 7.6.1.1 Keywords
+ // 7.6.1.2 Future Reserved Words
function isKeyword(id) {
switch (id) {
+
+ // Keywords.
case 'break':
case 'case':
case 'catch':
@@ -168,15 +170,8 @@ parseStatement: true */
case 'void':
case 'while':
case 'with':
- return true;
- }
- return false;
- }
-
- // 7.6.1.2 Future Reserved Words
- function isFutureReservedWord(id) {
- switch (id) {
+ // Future reserved words.
case 'class':
case 'const':
case 'enum':
@@ -197,6 +192,7 @@ parseStatement: true */
case 'yield':
return true;
}
+
return false;
}
@@ -293,13 +289,6 @@ parseStatement: true */
};
}
- if (isFutureReservedWord(id)) {
- return {
- type: Token.FutureReservedKeyword,
- value: id
- };
- }
-
// 7.8.1 Null Literals
if (id === 'null') {

0 comments on commit 82b7d72

Please sign in to comment.