[antlr-interest] labels for rule results?

Torsten Curdt tcurdt at vafer.org
Sat Aug 23 20:24:37 PDT 2008


attributeDeclaration
     : type_specifier name=Identifier  ';'
	  {
		System.out.println("name:" + name.getText());
	  }
     ;

The above works just fine. But what's the easiest way to access the  
result of the rules?
While this generates just fine

attributeDeclaration
     : thetype=type_specifier name=Identifier  ';'
	  {
		System.out.println("name:" + name.getText());
		System.out.println("type:" + thetype);
	  }
     ;

it does not compile as the there is no such variable.

The only way I could think of is to fill a context in (or a global  
variable) in the type_specifier rule.

cheers
--
Torsten


More information about the antlr-interest mailing list