[antlr-interest] Collecting Values in Lists
Behdad Forghani
behdad.forghani at samsarasol.com
Wed Apr 8 16:36:53 PDT 2009
Hello,
In the grammar I am working on I have a lot of list items like:
x :
y (',' y)*;
The rule y appears under other nodes. Now, when I am building my data
structure I am doing the following:
x
scope {
ArrayList<XType> list;
}
:
xCollecty (',' xCollecty)*;
xCollectY :
y
{
$x::list.add($y.value);
}
;
y
returns [value YType]
token :
{
$value = ...;
}
;
Is there a better way of doing this?
Thanks,
Behdad
More information about the antlr-interest
mailing list