[antlr-interest] Problem with rewrite rule referencing the previous value of the AST

Jim Idle jimi at temporal-wave.com
Tue Oct 23 16:31:04 PDT 2007


Mats,

You are getting this because you are using the ! operator and the ->
rewrites at the same time, and you must chose one or the other. It is a bit
of an obscure message of course, but when ANTLR3 grammars are parsed using
ANTLR3, then these kinds of things will be reported a lot better.

You probably want a rewrite like this:

 	optionCmd: p=OptionKeyword (Dot!)? 
                 (
 			  t=StrictKeyword                    ->
^(GenericStatement $t)
 			| a=MaxDurationKeyword b=intData     ->
^(GenericStatement $a $b)
 		     )


Though perhaps you would want a different Node type for the two alts?

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Mats Behre
> Sent: Tuesday, October 23, 2007 3:13 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Problem with rewrite rule referencing the
> previous value of the AST
> 
> Hi,
> 
> I am in the process of converting a v2 grammar to v3, and have some
> rules that (I would like to) look basically like this:
> 
> 	optionCmd: p=OptionKeyword (Dot!)? (
> 			t=StrictKeyword
> 			| t=MaxDurationKeyword intData
> 		) -> ^(GenericStatement $optionCmd);
> 
> The problem is that when I have the exclamation mark after the optional
> Dot token, I get a "Can't find template tokenRefBangTrack.st"
> exception.




More information about the antlr-interest mailing list