I rely on two main elements to analyze and improve grammar performance.
The latest version of ANTLRWorks 2 includes advanced profiling capabilities. Current restrictions include the following:
- The profiler does not support languages that require a custom
CharStream or TokenStream (for example, for preprocessing input). - The profiler does not perform custom embedded actions in the lexer or parser, so your grammar should be able to create a parse tree without relying on these operations. Standard lexer commands, such as
-> skip or -> channel(HIDDEN) , are not a problem. - The profiler’s output is a table of numbers that is not always understood by most ANTLR users, especially in terms of understanding what you should do in response to numbers.
I use fork of the main version , which includes a number of optimizations that are not available in the reference version of ANTLR 4. Note. that these features are “restrained” documented, as their only goal today is to support the internal development of ANTLRWorks and GoWorks. For most grammars, this fork performs an approximately equivalent reference version. However, for some well-known grammars, an “optimized” release performs more than 200 times faster than a reference release.
If you could provide grammar and input, in particular, I could do an analysis and try to interpret key pieces of the results.
The latest version of ANTLRWorks is distributed through the official NetBeans Update Center. Just run Tools → Plugins , go to Available Plugins and find ANTLRWorks Editor .
To start the profiler, use Run -> Interpret Parser .... The result window is available after the parsing operation by choosing Window → Parser Debugger Controller .
source share