[antlr-interest] What exactly does 'follow set' mean?
Monty Zukowski
monty at codetransform.com
Sun Apr 17 09:00:33 PDT 2005
Prashant Deva wrote:
> What exactly do you mean by a 'follow set'?
Follow set is what tokens may follow this in the stream, i.e. the
lookahead at that point of the production.
> In the doc it says that, when antlr parsers encounter an error they
> look up tokens until they find one in the 'follow set' of the rule.
So the idea is 'hey that doesn't belong here, so I'll just skip ahead in
the token stream until I see a token that the calling rule might match.'
So that when the errorneous rule returns the calling rule might be
able to continue where it left off.
Note that in ANTLR 2, the follow set for a rule is the union of the
lookahead following every call to the rule. ANTLR 2 doesn't distinguish
follow sets based on the caller.
Hey Ter, this may be able to improve in ANTLR 3 since you actually know
the follow set specific to the calling rule. Or maybe you figured that
out already? Wouldn't suprise me ;)
> So what exaclty does the parser look for when it encounters an error?
>
Hopefully I've answered that by now.
Monty
More information about the antlr-interest
mailing list