[antlr-interest] Why does this conflict?

shmuel siegel antlr at shmuelhome.mine.nu
Sun May 29 02:58:13 PDT 2005

I thank you for calling attention to the difference between parser 
literals and lexer tokens. It is a nice way to eliminate many annoying 
non-determinism warnings when looking for both keywords and identifiers.

But there is a gotya which I was lucky enough to catch in one of my test 
cases. In my lexer, I strip the quotes from strings since I don't need 
them in my tree (and also don't want them in my output). Unfortunately 
that makes them candidates for reinterpretation.

Solution, override testLiteralsTable in the lexer
    public int testLiteralsTable(int ttype)
        if (ttype == PreprocessorParserTokenTypes.STRING)
            return ttype;
            return super.testLiteralsTable(ttype);

No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.322 / Virus Database: 267.2.0 - Release Date: 5/27/2005

More information about the antlr-interest mailing list