[antlr-interest] Re : How to get a list of all valid options for the next token?

Thomas Brandon tbrandonau at gmail.com
Wed Aug 13 07:32:28 PDT 2008


ANTLR grammars are LL not LR, but they are recursive descent and thus
don't use an explicit internal representation of the grammar to
control parse decisions. They do however have follow sets available at
parse time, used for error recovery and reporting. See the various
FOLLOW_ bitsets in generated parsers and the computeErrorRecoverySet
and computeContextSensitiveRuleFOLLOW methods in BaseRecognizer. You
may be able to get what you need from them. Though as they only
support a limited purpose they may collapse alternatives you need to
keep distinct.
Another option would be to create a custom generator that would then
have the richer information ANTLR uses at generation time.

Tom.

On Wed, Aug 13, 2008 at 10:48 PM, Niemeijer, R.A. <r.a.niemeijer at tue.nl> wrote:
> Well, so much for that idea then :(
>
> Guess the only way to do this then is to indeed duplicate the knowledge
> inherent in the parser to a different checker. Oh well.
>
>
>
> From: Stanislas Rusinsky [mailto:rusinskystanislas at yahoo.fr]
> Sent: woensdag 13 augustus 2008 14:42
> To: Niemeijer, R.A.; Foust
> Cc: antlr-interest at antlr.org
> Subject: Re : [antlr-interest] How to get a list of all valid options for
> the next token?
>
>
>
> I have found one series of 3 articles that might be interesting for such
> situation:
>
> http://www.ibm.com/developerworks/views/opensource/libraryview.jsp?search_by=Create+commercial-quality+eclipse+ide
>
> But I don't know if you could achieve that easily (if someone knows a way or
> tool I would be interested too in knowing it). ANTLR parsers generated from
> grammars are not 'self-aware' if I understood correctly: they are LR parsers
> but don't hold as such a graph based on the grammar that could determine the
> next allowed token.
>
> Yours sincerely,
>
> Stanislas Herman.
>


More information about the antlr-interest mailing list