Browse Source

PEG.js grammar: Remove reserved word detection

This is mostly done for consistency with the JavaScript example grammar,
from which the |Identifier| rule is taken from. See the previous commit
for details.
redux
David Majda 8 years ago
parent
commit
7e3b4ec4f8
  1. 884
      lib/parser.js
  2. 4
      spec/parser.spec.js
  3. 3
      src/parser.pegjs

884
lib/parser.js
File diff suppressed because it is too large
View File

4
spec/parser.spec.js

@ -388,10 +388,6 @@ describe("PEG.js grammar parser", function() {
/* Canonical Identifier is "a". */
it("parses Identifier", function() {
expect('start = a:"abcd"').toParseAs(oneRuleGrammar(labeledAbcd));
expect('start = return:"abcd"').toFailToParse({
message: "Reserved word \"return\" can't be used as an identifier."
});
});
/* Canonical IdentifierName is "a". */

3
src/parser.pegjs

@ -218,9 +218,6 @@ SingleLineComment
Identifier
= !ReservedWord name:IdentifierName { return name; }
/ name:IdentifierName {
error("Reserved word \"" + name + "\" can't be used as an identifier.");
}
IdentifierName "identifier"
= first:IdentifierStart rest:IdentifierPart* { return first + rest.join(""); }

Loading…
Cancel
Save