[antlr-interest] zero-or-more or one-or-more in tree grammars
Mike J. Bell
ckimyt at gmail.com
Thu May 28 08:21:06 PDT 2009
I'm having trouble finding examples to show how to handle accumulation of
rule components in a tree parser.
For instance, given a grammar snippet:
big_definition: ^(DEFINITION_TOKEN str=collection) {
System.out.println("definition " + $str.value); };
collection returns [String value]:
t=thing* { /* insert magic to accumulate all the t's into $value */ };
thing: ...
See what I mean? When I look at the code generated here, t is assigned
inside the (*) loop, while the /*...*/ comment is placed after the
accumulation. I need to insert code at the (*). I don't seem to be able to
get the (ANTLR) grammar right to make this happen.
Any ideas? Does this happen a lot to you tree parser gurus? Any wealth of
knowledge besides the ANTLR wiki on tree parsing lore?
Thanks in advance,
Mike
--
Mike J. Bell on gmail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090528/b9adc7bd/attachment.html
More information about the antlr-interest
mailing list