JavaScript example: Fix parsing of statements

Fixes a problem where statements starting with a reserved word produced
errors like this:

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

The problem was in a wrong ordering of choices in the |Statement| rule
together with aggressive reserved word detection in the |Identifier|
rule.
redux
David Majda 11 years ago
parent e78ffbba9c
commit c70c8551b4

@ -993,18 +993,23 @@ Statement
= Block
/ VariableStatement
/ EmptyStatement
/ ExpressionStatement
/ IfStatement
/ IterationStatement
/ ContinueStatement
/ BreakStatement
/ ReturnStatement
/ WithStatement
/ LabelledStatement
/ SwitchStatement
/ ThrowStatement
/ TryStatement
/ DebuggerStatement
/*
* The following two statements begin with identifiers. They must be at the
* very end of the list to prevent triggering reserved word detection in the
* |Identifier| rule by keywords the statemets above begin with (e.g. |if|).
*/
/ ExpressionStatement
/ LabelledStatement
Block
= "{" __ body:(StatementList __)? "}" {

Loading…
Cancel
Save