[antlr-interest] Incremental parsing using ANTLR
monty at codetransform.com
Wed Mar 2 11:00:09 PST 2005
Nigel Sheridan-Smith wrote:
>>From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
>>bounces at antlr.org] On Behalf Of Prashant Deva
>>Sent: Thursday, 3 March 2005 7:16 AM
>>To: antlr-interest at antlr.org
>>Subject: [antlr-interest] Incremental parsing using ANTLR
>>Anybody has any ideas on doing incremental parsing in ides using antlr.
>>All the papers I have found talk only about LR parsers. Havent found one
>>Eclipse also uses a hand coded LR parser for its incremental parsing.
>>What I can think of right now is to determine the 'context' the user
>>is in, say in a method, then tell the parser to parse only the rule
> Can't you call the parsing method for any non-protected parser rules?
That's an intuitive conclusion to draw, but it is wrong.
"protected" is really only useful in lexers, where it is used as a flag
to keep that rule out of the ANTLR-synthesized nextToken() rule.
With a parser, you need to have your rule accessible as a "top level"
rule, which means that no other rules call it, and hence no tokens are
expected to come after it. Easily done like so:
If you don't do that, then ANTLR doesn't have the information to
correctly compute the follow sets, and you will get messages about
expecting a token that isn't there when you use that rule. That's
because to ANTLR, expr is always followed by something else, which gets
sucked into the follow sets, which turn into the lookahead and then
become part of the lookahead computation, even if, intuitively, it is
More information about the antlr-interest