[antlr-interest] ANTLR3 AST construction with options andalternatives

David Holroyd dave at badgers-in-foil.co.uk
Mon Nov 13 10:21:13 PST 2006


On Mon, Nov 13, 2006 at 05:26:12PM +0000, Foolish Ewe wrote:
> a: b=b (c+=C)?->^(A $b $c+); // Doesn't seem to work if C is not scanned

I dunno if this is the problem or not, but if 'C' only appears once on
the left of the rewrite above, wouldn't you write 'c=C', rather than
'c+=C'?  I've not used the += systax, so I'm not entirely sure.

Also, my simplistic unserstanding is that cardinality should 'match'
(sort of) on the left and the right of the rewrite, so I would be doing
something like,

  a: b=b (c=C)?->^(A $b $c?);

(i.e. giving the $c ref a '?' rather than a '+')

finally, I think that in such a simple rule, you don't need to
explicitly label each of the values, so you could rewrite it thus,

  a: b C? -> ^(A b C?)


I've not tested any of that though.  ;)


ta,
dave

-- 
http://david.holroyd.me.uk/


More information about the antlr-interest mailing list