[antlr-interest] Why does this conflict?

Martin Probst mail at martin-probst.com
Sun May 29 08:07:27 PDT 2005


It's probably easier and cleaner to put
STRING {
   testLiterals=false;
}:
  ....

into the parser...

shmuel siegel wrote:
> 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;
>        else
>            return super.testLiteralsTable(ttype);
>    }
> 
> 
> 




More information about the antlr-interest mailing list