pegjs/examples
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.
2014-04-13 20:29:00 +02:00
..
arithmetics.pegjs Complete rewrite of the arithmetics example grammar 2014-03-12 20:55:04 +01:00
css.pegjs Complete rewrite of the CSS example grammar 2014-03-23 13:29:54 +01:00
javascript.pegjs JavaScript example: Remove reserved word detection 2014-04-13 20:29:00 +02:00
json.pegjs Complete rewrite of the JSON example grammar 2014-03-14 14:28:10 +01:00