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

Stanislas Rusinsky rusinskystanislas at yahoo.fr
Wed Aug 13 10:26:56 PDT 2008

oops, when making such attention mistakes I feel like hiding under the table :) they are LL of course

Mr. Niemeijer, could you please keep me informed if you reach a satisfactory solution with the "FOLLOW_" hint? I am interested too in that topic.


----- Message d'origine ----
De : Thomas Brandon <tbrandonau at gmail.com>
À : "Niemeijer, R.A." <r.a.niemeijer at tue.nl>
Cc : antlr-interest at antlr.org
Envoyé le : Mercredi, 13 Août 2008, 16h32mn 28s
Objet : Re: [antlr-interest] Re : How to get a list of all valid options for the next token?

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.


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.

Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr

More information about the antlr-interest mailing list