Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to parse new array expression with LR rule #29

Closed
sharwell opened this issue Feb 29, 2012 · 1 comment
Closed

Unable to parse new array expression with LR rule #29

sharwell opened this issue Feb 29, 2012 · 1 comment

Comments

@sharwell
Copy link
Member

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) ]) <EOF>)
@sharwell
Copy link
Member Author

Fixed in 7525bb6

parrt pushed a commit that referenced this issue Jun 30, 2015
parrt pushed a commit that referenced this issue Jun 30, 2015
parrt added a commit that referenced this issue Jun 30, 2015
sharwell added a commit to sharwell/antlr4 that referenced this issue Dec 23, 2018
Fix travis build support for Java 6 and 7
KvanTTT pushed a commit to KvanTTT/antlr4 that referenced this issue Jan 22, 2024
KvanTTT pushed a commit to KvanTTT/antlr4 that referenced this issue Jan 22, 2024
KvanTTT pushed a commit to KvanTTT/antlr4 that referenced this issue Jan 22, 2024
KvanTTT pushed a commit to KvanTTT/antlr4 that referenced this issue Jan 22, 2024
KvanTTT pushed a commit to KvanTTT/antlr4 that referenced this issue Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant