[antlr-interest] Token Attributes in Arraylist
Richard Clark
rdclark at gmail.com
Wed Mar 12 09:41:00 PDT 2008
On Wed, Mar 12, 2008 at 9:08 AM, Alexander Gängel <alexander at gaengel.de> wrote:
> Is use id+=Identifier+ in a rule in my treegrammar and was wondering if
> there is some "easy" way to get an arrayList of just the text of the
> token like $if.text
Usually you just embed an action to append to a list as you go.
myRule
@init { List values = new ArrayList(); }
: (id+=Identifier { values.add($Identifier.text);})+
// and do something with the list after
;
...Richard
More information about the antlr-interest
mailing list