[antlr-interest] constructing AST nodes from variables

Mark Volkmann r.mark.volkmann at gmail.com
Wed Dec 12 15:20:03 PST 2007


Is it possible to set a variable that is used in an AST rewrite rule?
In the example below that doesn't currently work I'm trying to set the
variable "msg" and then output it into my AST. Maybe the underlying
question is whether you can use both { } and -> in the same rule.

myRule
@init { String msg; }
  : 'assert' left=value r=RELATION right=value
    { msg = "some string value"; }
    -> ^(ASSERT $r $left $right msg);

-- 
R. Mark Volkmann
Object Computing, Inc.


More information about the antlr-interest mailing list