[antlr-interest] Imported parser grammar importing another grammar produces unsuspected errors
Berger, Michael
michael.berger at fokus.fraunhofer.de
Thu Apr 22 06:49:56 PDT 2010
Title:
Imported parser grammar importing another grammar produces unsuspected
errors
Description:
The original example from the article about the import introduction:
A combined grammar imports a parser grammar importing an other parser
grammar. (without overriding)
Software:
antlrworks-1.3.1.jar
-------
lexer grammar lex;
LETTER : 'a'..'z' ;
SPACE : ' ' ;
--------
parser grammar par1;
letter : LETTER ;
spaces : SPACE+ ;
---------
parser grammar par2;
import par1;
letters : letter+ ;
---------
grammar gram;
import lex, par2;
stuff : ( letters spaces )+ ;
--------
Generated java code produces follow errors :
D:\local\mib\Compiler\de.fraunhofer.fokus.ttcn3.compiler\grammar\gram_pa
r2_par1.java:22: cannot find symbol
symbol : variable ggramgpar2
location: class gram_par2_par1
public int getRuleLevel() { return ggramgpar2.getRuleLevel(); }
^
D:\local\mib\Compiler\de.fraunhofer.fokus.ttcn3.compiler\grammar\gram_pa
r2_par1.java:23: cannot find symbol
symbol : variable ggramgpar2
location: class gram_par2_par1
public void incRuleLevel() { ggramgpar2.incRuleLevel(); }
^
D:\local\mib\Compiler\de.fraunhofer.fokus.ttcn3.compiler\grammar\gram_pa
r2_par1.java:24: cannot find symbol
symbol : variable ggramgpar2
location: class gram_par2_par1
public void decRuleLevel() { ggramgpar2.decRuleLevel(); }
^
D:\local\mib\Compiler\de.fraunhofer.fokus.ttcn3.compiler\grammar\gram_pa
r2.java:28: cannot find symbol
symbol : constructor
gram_par2_par1(org.antlr.runtime.TokenStream,gram_par2,org.antlr.runtime
.RecognizerSharedState,gramParser)
location: class gram_par2_par1
gpar1 = new gram_par2_par1(input, this, this.state, ggram);
--------
the generated constructor in class gram_par2_par1:
public gram_par2_par1(TokenStream input, DebugEventListener dbg,
RecognizerSharedState state, gramParser ggram, gram_par2 gpar2) {
super(input, dbg, state);
this.ggram = ggram;
this.gpar2 = gpar2;
}
best regards,
Michael Berger
Fraunhofer FOKUS
Kaiserin-Augusta-Allee 31
10589 Berlin
Tel: +49-30-3463-7176
More information about the antlr-interest
mailing list