[antlr-interest] String template return val propagation

Bill Andersen andersen at ontologyworks.com
Thu Oct 15 12:52:23 PDT 2009


Hi all

I have the following grammar fragment (with template output) that  
parses an AST and translates it to a text representation.  The parsing  
works fine and I'm reading in the template group just fine.

The problem that seems to be happening below is that 'prefixed_name'  
is being correctly recognized and the template returned, but the  
'name' production is not passing that template back up to the 'name'  
non-terminal in the top rule for inclusion in the template rewrite.   
Is there some switch I'm forgetting to set or do I need to do  
something explicit with the second rule to make sure the template gets  
propagated.

Thanks in advance

text_block
	: ^(AS_TEXT name phrase+)
	  -> text(name={$name.st})
	;

name
	: prefixed_name
	;
	
prefixed_name
	: ^(AS_NAME AS_NAME_NS AS_NAME_LOCAL)
	  -> name(ns={$AS_NAME_NS.text},local={$AS_NAME_LOCAL.text})
	;


	.bill




More information about the antlr-interest mailing list