[antlr-interest] Grammar dependencies (was Re: Expected token apparently not expected?!)

David Bullock db at dawnbreaks.net
Fri Sep 10 05:41:13 PDT 2004


--- In antlr-interest at yahoogroups.com, Ric Klaren <klaren at c...> wrote:
> On Fri, Sep 10, 2004 at 06:12:27AM -0000, David Bullock wrote:
> > I guess the problem is that if you use literals in the parser, 
then 
> > the lexer needs to get these somehow.  This means that the 
grammar 
> > needs to be 'pushed back' to the lexer.
> > 
> 
> Oh yeah that's a good point. I usually define all tokens in the 
lexer using
> the tokens section. So the parser can be a clean 'consumer' of the 
vocab of
> the lexer.
>
> e.g. in the lexer:
> 
> class L extends Lexer;
> options { .. }
> tokens {
>   IF="if";
>   ELSE="else";
>   ..
> }

Excellent!  That is the neat way of doing it that I was looking for.

thanks,
David.



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list