[antlr-interest] Language Design Patterns and incremental parsing

Andreas Stefik stefika at gmail.com
Wed Jul 22 09:59:54 PDT 2009


Andrew,

So far as I understand it, where incremental parsing comes in really handy
is when you have something continually reparsing a file. In my case, I use
ANTLR to parse a custom programming language, which is then integrated into
the NetBeans platform. The NetBeans parser, by default, continually reparses
the source as the user types to try and determine whether there are errors
in what the user is typing. It then generates visual feedback on the fly
(e.g., little red squiggly lines), depending upon if there are errors.

In practice, even with a non-incremental parser, this generally works fine
for 1 file (the user can only type in one at a time), but since everything
is done in real time, you want to the minimum amount of computation done
while the user is typing so that the visual (and in my case, aural, since my
language is for blind children), feedback to be as fluid and consistent as
possible. Since ANTLR is not incremental, I currently have NetBeans wipe the
build information for the file every time it requests a re-parse (which
happens often!!), and then ask ANTLR to do it from scratch. It would be nice
though, if ANTLR could only update the pieces of code the user was typing
in, as it would, in theory at least, be much faster.

In my case though, there are a few things I'm not sure how I would handle
yet if ANTLR were incremental.

1. How would the different phases of my VM interact (e.g., would the tree
walker also incrementally change?)

2. Would I be able to figure out how to modify my post-ANTLR compiler phases
if ANTLR were incremental?

I'm sure there are solutions to questions like these, and I highly support
incremental parsing for ANTLR, if it's feasible, but so far as I understand
it, it's a pretty tricky technology.

Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090722/ecd7c3a6/attachment.html 


More information about the antlr-interest mailing list