antlr / grammars-v4

Grammars written for ANTLR v4; expectation that the grammars are free of actions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[javascript] parser is too greedy for some new expressions

meraedit opened this issue · comments

Expressions like new a.B().call() are parsed incorrectly as new (singleExpression a.B().call) arguments

I tried to reorder the productions (similarly to #2178), but without success. Adding a semantic predicate fails when generating the parser with "The following sets of rules are mutually left-recursive [singleExpression]".

It seems to me that the only way is to break down the single expression such as the Arguments/call expression cannot follow the new operator: https://262.ecma-international.org/5.1/#sec-11.2
But this is a big change in the grammar...