[antlr-interest] Dealing with lists in a tree grammar action
Terence Parr
parrt at cs.usfca.edu
Thu Jul 12 17:52:56 PDT 2007
On Jul 12, 2007, at 5:38 PM, Cameron Esfahani wrote:
>> elements returns[ pANTLR3_VECTOR List ]
>> : v += value+
>> {
>> $List = $v;
>> }
>> ;
>>
>> But I get the following error from ANTLR:
>>
>> error(134): TWalker.g:58:4: rule '+=' list labels are not allowed
>> w/o output option: v
Yeah, rules can have multiple return values and so I just decided to
only keep track of result trees, which are currently not available in
tree grammars. I will fix that soon.
>> I've read the documentation about "+=" only being applicable in
>> AST or template outputs. And so I'm stuck.
>>
>> Does anyone have any suggestions on how to handle this?
I'm in a rush but you can try a single v=value {list.add($v.start);}
which will make a list of all the root/start nodes for stuff going
into value rule.
Ter
More information about the antlr-interest
mailing list