[antlr-interest] Re: How to set filename in parser

Ric Klaren ric.klaren at gmail.com
Fri Jul 15 10:51:10 PDT 2005


shmuel siegel wrote:
> Anyway, what I ended up doing was
> 1) introduce a local variable in the lexer for saving the filename. (the 
> one from inputState is inaccessable to the parser.)
> 2) save a reference to the lexer in the parser
> 3) overiding the parser's getFilename method to reference the saved 
> filename.

If your parser uses syntactic predicates then the lexer may be well 
ahead of your parser in the input. Unless you override the mark/rewind 
mechanism used during guessing then you can't be sure that you will get 
the right filename.

Cheers,

Ric


More information about the antlr-interest mailing list