[antlr-interest] how do I accumulate multiple returns for parser matches in one variable?
Sven Prevrhal
sven.prevrhal at ucsf.edu
Mon Jan 26 00:04:20 PST 2009
I want to parse recipes and I have something like
ingrediententry
: q=number uid=unit iid=ingredient
qid=ingredient_qualifier*
{ .
Where ingredient_qualifier can appear more than once. How do I accumulate a
list of qualifiers that I can then process in the action to
ingrediententry?
I tried
ingrediententry
@init {
List<int> li = new List<int>();
}
// ingredient returns an id
: q=number uid=unit iid=ingredient
qid=ingredient_qualifier* {$li.Add($qid);}
{.
But that gives an missing attribute access error on rule scope for $qid.
Cheers,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090126/b043c709/attachment.html
More information about the antlr-interest
mailing list