[antlr-interest] how to report errors in include files

Rob Finneran robfinneran at gmail.com
Sun Oct 7 12:05:59 PDT 2007


Hi Pete,

One idea would be to not reset() the line counter. You would then need
to map the virtual line number (like line 127585) to the actual file
and actual line number (like line 123).

Just an idea!

On 10/7/07, Pete Siemsen <siemsen at ucar.edu> wrote:
>
> Can I make ANTLR show source file names in error messages?
>
> I'm developing a grammar to translate a set of about 1300 source files.  The
> files have to be processed in a certain order, so there's a single file that
> has about 1300 "include" statements.  By pointing my ANTLR 3.0.1 translator
> at the single source file, the entire set is processed as if it were one
> giant file.  My translator now handles the include files fine, thanks to
> help from this list.  As I expected, I'm seeing various parser error
> messages because my grammar isn't quite correct yet. The trouble is that the
> error messages don't tell me which include file the error occurred in.
>
> I tried putting debugging lines in the code that handles the include
> statements.  Now I see about 1300 messages that say "opening include file
> xyz".  The handling of include files happens in the lexer phase, so I see
> all 1300 of those messages first, followed by all the messages about parser
> errors.  The latter messages have line numbers, but not file names, so
> there's no way to relate the messages to the files.
>
> I could approach this problem outside ANTLR by running the translator on
> each individual file, but I'm hoping for a better method.
>
>
> -- Pete
>
>
>
>


More information about the antlr-interest mailing list