[antlr-interest] trace as an grammar and rule option

richardhensley99 richard.hensley at mckesson.com
Tue Sep 17 14:08:29 PDT 2002


I have a situation where I can only reproduce a bug by testing my 
grammar on a file that is about 20k lines long. I used antlr and 
turned on -traceParser, and this looks like it will generate the 
output I need, however it is taking a very long time to run... 

I was wondering if anybody has ever thought about a trace option at 
the grammar and at the rule level?

I've been poking around in the antlr source, and I think it would be 
implemented very much like the defaultErrorHandler option. It seems 
that the touch points would be the following:

MakeGrammar.java is the only place the creates rule blocks. When it 
creates them, it copies the defaultErrorHandler option from the 
grammar. I think the same rules would apply for a trace option.

JavaCodeGenerator.java checks the grammar for the traceRules flag. 
This would be changed to test the rule block currently in context.

Grammar.java the setOption method would be modified to allow a trace 

RuleBlock.java the setOption method would be modified to allow a 
trace option.

Are there any other touch points that I missed?

I think this would be useful because I would be able to reduce the 
number of rules that are trace that I really don't care about. At 
this time, my test for debugging takes enough time that I was able to 
research this change and start on the changes.

>>From my research, I think the changes would allow the option in 
lexers, parsers, and tree parsers.

If anybody thinks this is useful, I would be more that willing to 
submit the source files, or a diff patch back to the list. I'm using 
2.7.2a2, so I think this is fairly recent.



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

More information about the antlr-interest mailing list