[antlr-interest] Syntax Highlighting and Autocompletion
roxton at gmail.com
Sun Jan 9 08:12:54 PST 2011
I'm interested in making a simple editor for my ANTLR grammar. The key
things I want are autocomplete and syntax highlighting. So after digging
through the book, I did a little digging on the list.
Back in June 2008, Terrence Parr talked about making the NFA's available at
runtime for such use.
In November 2008, Sam Harwell suggested that ANTLR was not appropriate for
autocompletion (although it was deemed appropriate for scanning the larger
project and populating the cache used by autocompletion).
In May 2009, Sam Harwell discussed the use of simplified lexers to
facilitate syntax highlighting in Visual Studio. He makes a number of
insightful comments on VS's implementation/contract and best practices.
Did Terrence make any headway with runtime access of NFA's? It seems that
Harwell's concerns about performance and robustness could be addressed by
having parsers work incrementally, pausing at the current, incomplete token
and giving the developer access to current runtime NFA state, perhaps
resolving ambiguity by following multiple still-valid paths on the NFA and
only using look-ahead to rank possibilities. (The above may be badly
formulated, infeasible, or just plain incorrect.)
Harwell wrote a special grammar for common cases of incomplete expressions.
Is that still a pretty good way to go?
I'm prepared to move ahead given what I know, but any updated thinking on
this subject would be much appreciated.
More information about the antlr-interest