Skip to content

Commit

Permalink
Reserved: Update list of reserved words to ECMAScript 2015
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingun committed May 22, 2021
1 parent c3d2aef commit e0a482b
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions lib/peg.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const parser = require("./parser");
const VERSION = require("./version");

const RESERVED_WORDS = [
// Reserved keywords as of ECMAScript 2015
"break",
"case",
"catch",
Expand All @@ -17,38 +18,61 @@ const RESERVED_WORDS = [
"delete",
"do",
"else",
"enum",
"export",
"extends",
"false",
"finally",
"for",
"function",
"if",
"import",
"instanceof",
"in",
"instanceof",
"new",
"null",
"return",
"super",
"switch",
"this",
"throw",
"true",
"try",
"typeof",
"var",
"void",
"while",
"with"
"with",
// "yield", // encountered twice on the web page

// Special constants
"null",
"true",
"false",

// These are always reserved:
"enum",

// The following are only reserved when they are found in strict mode code
// Peggy generates code in strictly mode, so it applicable to it
"implements",
"interface",
"let",
"package",
"private",
"protected",
"public",
"static",
"yield",

// The following are only reserved when they are found in module code:
"await"
];

const peg = {
// Peggy version (filled in by /tools/release).
VERSION,
/**
* Default list of reserved words.
* Default list of reserved words. Contains list of currently and future
* JavaScript (ECMAScript 2015) reserved words.
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#reserved_keywords_as_of_ecmascript_2015
*/
RESERVED_WORDS,
GrammarError,
Expand Down

0 comments on commit e0a482b

Please sign in to comment.