[antlr-interest] semantic predicate does not work

weberjn <weberjn at yahoo.com> weberjn at yahoo.com
Tue Jan 21 08:00:22 PST 2003


Hi,

on Terence Parr's Getting Started With ANTLR there is a rule with
a semantic predicate

startRule
    :   n:NAME
        {System.out.println("Hi there, "+n.getText());};



I tried to insert something like that into the IDL grammar:

module
	:    "module" 	
	     d1:identifier 
         {System.out.println("found identifier "+d1.getText());}
 	     LCURLY definition_list RCURLY
	;


but the java compile complains of 

   [javac] C:\myjava\antlridl\gensrc\IDLParser.java:268: cannot
resolve symbol
   [javac] symbol  : variable d1
   [javac] location: class IDLParser
   [javac]                     System.out.println("found identifier
"+d1.getText());


What is the trick?

Thanks for any hints,
Juergen



 

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



More information about the antlr-interest mailing list