[antlr-interest] Re: Redifinition of token in tokens {...}: CTAGBEGIN

Ric Klaren klaren at cs.utwente.nl
Fri Mar 19 02:56:48 PST 2004


On Thu, Mar 18, 2004 at 05:19:08PM -0000, Jerry Dy wrote:
> > Because the CTAGBEGIN is implicitly defined in the parser. :)
> >
>
> Am I not simply referencing the token CTAGBEGIN in the parser, not
> defining it? The cpp files where generated without errors when I
> removed CTAGBEGIN from the tokens section... in this case, where is
> the CTAGBEGIN token defined??

ANTLR defines tokens implicitly as it encounters them (think vanilla
BASIC), this can be a real PITA, but Ter nearly had me shot when I tried to
change that ;)

Also it does different things if you have lexer/parser in one file or
separate files. The behaviour with separate files is a more consistent. But
you'll usually have to make a exportVocab -> importVocab 'chain'.

E.g. make your lexer define tokens there do an exportVocab from the lexer.
Then in the parser use a importVocab .. add imaginary tokens if you need
them do an exportVocab to another vocabulary which can be used by
treeparsers and so on. See the FAQ's on this topic on jguru.com.
Disadvantage of this approach though is that you need to build your
grammars in the right order (although it's not much different from normal
build processes, unless you're not aware of those due to nice
shiny gui's ;) )

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
  Before they invented drawing boards, what did they go back to?


 
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