[antlr-interest] How to use StringTemplate in Antler 3

Kay Roepke kroepke at classdump.org
Thu Nov 9 07:09:59 PST 2006


Hi Hugo!

On 9. Nov 2006, at 15:58 , Hugo Garcia wrote:

> importDeclaration
> 	:	'import' 'static'? Identifier ('.' Identifier)* ('.' '*')? ';'
> 	-> import(name={$Identifier.st},
>                begin={$Identifier.start},
>                end={$Identifier.stop})
> 	;

ANTLR can't figure out which Identifier you mean here. If you mean  
the first one, give it a label:

importDeclaration
	:	'import' 'static'? id=Identifier ('.' Identifier)* ('.' '*')? ';'
	-> import(name={$id.st},
                begin={$id.start},
                end={$id.stop})
	;

If you need all identifiers, you can't access it like $id.st etc., of  
course, the action code would be more
involved in that case.

HTH,
-k
-- 
Kay Röpke <kroepke at classdump.org>
classdump Software
Key fingerprint = A849 0F2C C322 4022 379E  8661 7E1B FE0D 4CD2 A6D0





More information about the antlr-interest mailing list