[antlr-interest] warning: redefinition of token in tokens (was Re: ambiguous grammar)
Ric Klaren
klaren at cs.utwente.nl
Sat Jan 25 08:53:24 PST 2003
Hi,
Didn't quite follow the thread but anyway ;)
On Sat, Jan 25, 2003 at 02:51:41PM -0000, beeh1973 <bendt at inf.fu-berlin.de> wrote:
> as both lexers need to share a common vocabulary i created a file
> CommonTokenTypes.txt, put in the common tokens and imported it in
> both lexers and the parser. compare with example below.
>
> in the parser i am adding the AST Option to the imported Tokens.
> this causes a warning for Example: 'warning:Redefinition of token in
> tokens {...}: AND'
This depends a little on your setup. If you have parser and lexer in one
file then you don't need to import/exportvocab (since they will share the
same vocabulary). (only nice if you have small lexer/parser/treewalkers)
If you have them in separate files, then the best setup is to create a
chain of export/importVocabs.
E.g. in your lexer you do exportVocab = Lexer_ in your parser you do a
importVocab = Lexer_, and a exportVocab = Parser_ in the first tree walker
you'd do a importVocab = Parser_ and if you add new nodest to the tree
you'd do a new exportVocab.
You don't need to do exportVocab's if you don't define any additional
tokens/astnodes in a parser/treewalker. If you use this setup you have to
make sure you build things in the right order e.g. from the bottom up. If
you don't you might end up with parsers/treewalkers/lexers that have a
different understanding of a token/astnode.
Another option is to define all tokens/astnodes in one of your files and
exportvocab from there and importvocab from all the others. This is a
matter of taste kinda.
> The generated Parser works as expected. So maybe theres just a switch
> to turn the warning off?
Think we didn't add a switch for that... talked about it but it got
probably got lost somewhere.
HTH,
Ric
--
-----+++++*****************************************************+++++++++-------
---- Ric Klaren ----- klaren at cs.utwente.nl ----- +31 53 4893722 ----
-----+++++*****************************************************+++++++++-------
Before they invented drawing boards, what did they go back to?
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list