-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Issue with Antlr4 Java 7 Grammar expression Parser rule #1323
Comments
Is this java or java8 grammar? it is hitting a nonlinearity. not a bug but not fun either. ;) |
@parrt Well it still seems a for me. public class AbsencesApprovalsEventsAMImpl extends ApplicationModuleImpl {
} Now if I change something in the input file like what follows. case 1: Removing the Generic Symbols from the method argument. That is changing Map<String,Integer> absenceValues to Map abscenceValues ( or like anything without "<" and ">" symbols) Keeping the rest of the code as they are. case 2: Keeping the method argument as it is and reducing the length of the String payload ( the payload string spans across multiple lines from line number 11 to line number 291) In both cases, it Works. When I tried with Java8 grammar (https://github.com/antlr/grammars-v4/blob/master/java8/Java8.g4), it worked. For some reasons, I can't change my underlying grammar. I need to get this done using Java7 grammar itself. I tried almost everything, from using to unbuffered streams to setting SSL prediction but nothing worked for me. typeParameters expression I changed the expression rule to something like this expression and logicalExpression logicalOperand For my next run, it worked. I have written some APIs targeting Java7.g4 grammar and can't move straight away to Java8.g4 as the rule name among them are entirely different. |
Yes, ANTLR's ALL(*) is O(n^4) worst case and you hit it with that. The java8 grammar doesn't use left-recursive expr and so performs better in this case. |
Dup of #994 |
I found this issue for the following input
public String publishAbsencesApprovalsEvent(Map<String,Object> absenceValues) {
// inside this method there is a pretty much long string which spans around 150 lines.
}
When I try to create a ParseTree for this input file, it's got hanged like forever. I guess there is a decision-making issue for the grammar for the below two rules.
typeArguments
: '<' typeArgument (',' typeArgument)* '>'
;
expression
: //many alternatives
| expression ('<=' | '>=' | '>' | '<') expression #logical
When I commented out the #logical alternative and re-ran it's worked.
I guess there is a token matching decision from lexer to Parser level which makes it hang forever.
Please let me know if there is a solution for this without altering much of the grammar file.
The text was updated successfully, but these errors were encountered: