antlr/antlr4 — Issue #29: Unable to parse new array expression with LR rule
Author: sharwell
Created: 2012-02-29 17:38:09+00:00
State: open

With the current algorithm, it is not possible to parse certain expressions with an LR rule. One basic example is the new array expression in Java:

Grammar:

```
grammar T;
s @after {System.out.println($ctx.toStringTree(this));} : e EOF ;
expressionList
: e (',' e)*
;
e : INT
| 'new' type ('[' e ']')+
| e '[' e ']'
;
type: ID
| ID '[' ']'
;
ID : ('a'..'z'|'A'..'Z'|'_'|'$')+;
INT : '0'..'9'+ ;
WS : (' '|'\\n') -> skip ;
```

Failed expression:

```
new T[1]
```

Expected:

```
(s (e new (type T) [ (e 1) ]) )
```