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

Pete Siemsen siemsen at UCAR.EDU
Sun Oct 7 11:37:20 PDT 2007


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



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20071007/dbbef065/attachment.html 


More information about the antlr-interest mailing list