[antlr-interest] No literals with two parsers using same TokenTypes

Olivier Dragon dragonoe at mcmaster.ca
Fri Mar 3 05:40:12 PST 2006


Hi,

Using ANTLR 2.5, I have the following problem:

I'm trying to write two parsers that have the same output tree language,
but different input languages. In order to make things easier on myself
I thought of sharing token types by importing the vocabulary from
GrammarA into GrammarB.

My problem is with literals inside the parser. All the tokens defined as
rules in the lexer of GrammarB, as well as tokens defined inside the
tokens{} section of GrammarB are merged with the tokens from GrammarA
properly, except for literal strings inside the parser.

I have the following headers in GrammarB:

class GrammarBParser extends Parser;
options {
    importVocab=LanguageA;
    exportVocab=LanguageB;
}

class GrammarBLexer extends Lexer;
options {
    importVocab=LanguageA;
    exportVocab=LanguageB;
}

And a file called "LanguageATokenTypes.txt" in the same directory as
GrammarB.

Any idea what I'm doing wrong? I could put all the literals in the
tokens{} section as a workaround, but I would rather avoid that if
possible.

Thanks!
-Olivier

-- 
          __-/|    ? ?     |\-__
     __--/  /  \   (^^)   /  \  \--__
  _-/   /   /  /\ / ( )  /\  \   \   \-_
 /  /   /  /  /  (   ^^ ~  \  \  \   \  \
 / Oli Dragon    ( dragonoe at mcmaster.ca \
/  B.Eng. Sfwr   ( dragon.homelinux.org  \
/  /  /    /__--_ (   ) __--__\    \  \  \
|  /  /  _/        \_ \_       \_  \  \  |
 \/  / _/            \_ \_       \_ \  \/
  \_/ /                -\_\        \ \_/
    \/                    )         \/
                        *~
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20060303/7115c390/attachment.bin


More information about the antlr-interest mailing list