[antlr-interest] lexer doesn't see super constructor & inherited variable

johan.grande at crans.org johan.grande at crans.org
Tue Jul 22 10:23:29 PDT 2008


Raphael Reitzig <r_reitzi at cs.uni-kl.de> a écrit :

> "Johan Grande" <johan.grande at crans.org> wrote (Mon Jul 21 23:35:35 2008):
>
>> I first tried antlr-3.0.1 . But I found a bug in it [...] and in my  
>>   case the generated parser didn't compile.
> Uh, so why did 3.0.1 work for me? That bugs _me_ o.o
In the original grammar there is no rule parameter. But I need some,  
and they lead to a bug. I typically writes things like :

foo : modifiers bar[$modifiers.tree] -> bar
bar[Tree modifiers] : 'bar' sth -> ^(Bar modifiers sth)

Where foo and bar already exist, I add the parameters and the tree  
construction.

>
>> How can javac see a class but not a constructor in it ?
> Usually, if there is no such construcor or it is hidden.
>
> Wait. What package is the superclass in and which modifier got the
> constructor in question? Your parser will for sure be in another
> package. Thus, if constructors are package local, you may get those
> errors.
>
The superclass of the generated lexer is org.antlr.runtime.Lexer :

public abstract class Lexer extends BaseRecognizer implements TokenSource

and it contains the _public_ Lexer constructor.



>> I think I can assume the .class included in antlr correspond to the  
>>   .java provided ...
> You should. However, if the distributor if the package did something
> wrong, weird stuff can happen. But since we both downloaded from
> antlr.org, I suppose, that cannot be the case.
>
>> I don't know all the subtleties of Java, but it would be great if    
>> you could explain me how the bug can just exist.
> I can only think of Classpath and compatibility issues.

The .jar is in the classpath; I see it by echo.

The class Lexer is in the classpath, because "java  
org.antlr.runtime.Lexer" raises "NoSuchMethodError: main" and not  
"NoClassDefFound"

>
> Do you run a MAC? Do you use some JDK _not_ from SUN? (I suppose both
> questions will be answered with 'no', for javac -version should have
> looked somehow different (?), but just to be sure)
>
I use the Sun JDK on GNU/Linux.

> Please send me both the gramar file and the jar you use. I want to try
> exactly this combination here...
>
The .jar is he ne of the one of antlr v3.1b2 .

I will send my grammar as soon as possible, I can't yet, sorry.

Regards,
Johan


More information about the antlr-interest mailing list