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 10 years ago
parent e78ffbba9c
commit c70c8551b4

@ -993,18 +993,23 @@ Statement
= Block = Block
/ VariableStatement / VariableStatement
/ EmptyStatement / EmptyStatement
/ ExpressionStatement
/ IfStatement / IfStatement
/ IterationStatement / IterationStatement
/ ContinueStatement / ContinueStatement
/ BreakStatement / BreakStatement
/ ReturnStatement / ReturnStatement
/ WithStatement / WithStatement
/ LabelledStatement
/ SwitchStatement / SwitchStatement
/ ThrowStatement / ThrowStatement
/ TryStatement / TryStatement
/ DebuggerStatement / 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 Block
= "{" __ body:(StatementList __)? "}" { = "{" __ body:(StatementList __)? "}" {

Loading…
Cancel
Save