You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
David Majda c13cc88262 JavaScript example: Remove reserved word detection
Reserved word detection as it was implemented in the JavaScript example
grammar had two big downsides:

  1. It required changes in ordering of choices in some rules in order
     not to trigger the detection prematurely. One of the changes was
     already implemented (in the |Statement| rule, see the diff), but
     apparently more were needed (the grammar didn't parse inputs like
     |true| or |function f() {}|). And I'm not 100% sure that would be
     the end of it (maybe deeper structural changes would be needed).

  2. It made error messages confusing. Consider the following example:

       var a = @;

     Instead of reporting:

       Expected ... but "@" found.

     the generated parser reported:

       Reserved word "var" can't be used as an identifier.

     This was because the parser parsed the statement first as
     |VariableStatement| and when this failed, it tried to parse it as
     |ExpressionStatement|, triggering the reserved word detection.

Because of these, I decided to remove reserved word detection from the
JavaScript example grammar.
11 years ago
..
arithmetics.pegjs Complete rewrite of the arithmetics example grammar 11 years ago
css.pegjs Complete rewrite of the CSS example grammar 11 years ago
javascript.pegjs JavaScript example: Remove reserved word detection 11 years ago
json.pegjs Complete rewrite of the JSON example grammar 11 years ago