I have a large c-code file (>9000 LoC) and attempt to parse it using this grammar:
https://github.com/antlr/grammars-v4/blob/master/c/C.g4
I waited for over an hour before aborting. The machine is a Core 2 Duo L9400 with 4GB of ram. Maximum java vm-heap-size is set to 2GB. It does not produce any parse errors, but it simply doesn't finish.
After doing some research, I set the prediction mode to SLL, which produces a "no viable alternative at input" within seconds.
Next, I set the prediction mode to LL_EXACT_AMBIG_DETECTION and attached a DiagnosticErrorListener to the parser. This produces a lot of "Ambiguity reports", mainly concerning declarations/declaration-specifiers. I assume this forces the parser to backtrack extremely often, which I is probably the explaination for the long parsing time?
Is there anything I can do to improve performance other than attempting to rewrite the grammar?
Any help is appreciated ;)