[antlr-interest] Grammar inheritance problem

Chet digitalasp at yahoo.com
Sun Jan 21 01:30:30 PST 2007


I'm having the same problem with 2.7.7. I know this same issue has been
reported to the list a couple of times and IIRC a preprocessor patch for this
problem was posted in 2003 for version 2.7.2. The patched code has changed
since then and seems to have reintroduced the bug.

I believe the problem is in antlr.preprocessor.Grammar.toString() in its
handling of the superclass and grammar type starting at line 250 (2.7.7).


-------------- [ SNIP: line 250] --------------
if ( superClass!=null ) {
// replace with specified superclass not actual grammar
// user must make sure that the superclass derives from super grammar class
	s.append("class " + name + " extends " + superClass + ";");
}
else {
	s.append("class " + name + " extends " + type + ";");
}
-----------------------------------------------


This should probably be something similar to this:

-------------- [ INSERT ] --------------
s.append("class " + name + " extends " + type);
if ( superClass != null ) {
	s.append(" " + superClass );
}
s.append(";");
----------------------------------------


As soon as I get a java dev environment setup (haven't done java in years) I'll
test the modified code and post the results. I'm not sure if the change even
works yet or how it may be affected by other portions of the preprocessor so if
anyone wants to give it a try feel free to have a go at it.


--- Andrey Timoshenkov <tas at ultersys.ru> wrote:

> Hi All.
> 
> I have a trouble using ANTLR 2.7.5. I need 2 lexer grammars L1 and L2, 
> where L2 inherits from L1 and I need to specify my own base class for 
> resulting lexer. Below are simple examples:



 
____________________________________________________________________________________
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives.
http://tools.search.yahoo.com/toolbar/features/mail/


More information about the antlr-interest mailing list