Skip to content

Commit cc04fa0

Browse files
committed
Reserved: Update list of reserved words to ECMAScript 2015
1 parent 09a092c commit cc04fa0

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

lib/peg.js

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const parser = require("./parser");
66
const VERSION = require("./version");
77

88
const RESERVED_WORDS = [
9+
// Reserved keywords as of ECMAScript 2015
910
"break",
1011
"case",
1112
"catch",
@@ -17,38 +18,61 @@ const RESERVED_WORDS = [
1718
"delete",
1819
"do",
1920
"else",
20-
"enum",
2121
"export",
2222
"extends",
23-
"false",
2423
"finally",
2524
"for",
2625
"function",
2726
"if",
2827
"import",
29-
"instanceof",
3028
"in",
29+
"instanceof",
3130
"new",
32-
"null",
3331
"return",
3432
"super",
3533
"switch",
3634
"this",
3735
"throw",
38-
"true",
3936
"try",
4037
"typeof",
4138
"var",
4239
"void",
4340
"while",
44-
"with"
41+
"with",
42+
// "yield", // encountered twice on the web page
43+
44+
// Special constants
45+
"null",
46+
"true",
47+
"false",
48+
49+
// These are always reserved:
50+
"enum",
51+
52+
// The following are only reserved when they are found in strict mode code
53+
// Peggy generates code in strictly mode, so it applicable to it
54+
"implements",
55+
"interface",
56+
"let",
57+
"package",
58+
"private",
59+
"protected",
60+
"public",
61+
"static",
62+
"yield",
63+
64+
// The following are only reserved when they are found in module code:
65+
"await"
4566
];
4667

4768
const peg = {
4869
// Peggy version (filled in by /tools/release).
4970
VERSION,
5071
/**
51-
* Default list of reserved words.
72+
* Default list of reserved words. Contains list of currently and future
73+
* JavaScript (ECMAScript 2015) reserved words.
74+
*
75+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#reserved_keywords_as_of_ecmascript_2015
5276
*/
5377
RESERVED_WORDS,
5478
GrammarError,

0 commit comments

Comments
 (0)