ANTLR3 allows labeling attributes for referencing in actions.
Example:
decl: type id=ID ';' { print "var" + $id.text; }
With the C language target, the $id.text gets converted nicely into:
(id->getText(id))
However, if you have more than one attribute:
decl: ^( TYPE ids+=ID* )
...$ids becomes a pANTLR3_VECTOR, and it appears those helpful attributes no
longer work?
I was hoping something like $ids[i].text would get automatically converted.
Instead, I had to dig into the implementation a bit and hand-expand it to:
pANTLR_BASE_TREE id = (pANTLR_BASE_TREE)$ids->get($ids, i);
const char* name = (const char*)id->getText(id)->chars;
So, I guess a couple questions:
1) Does the java language option suffer the same fate? (i.e. ANTLR3 simply
does not provide syntax for working with attributes on multi-value labels?)
2) Does the C API provide some nice macros I may have missed for making this
less gross? (e.g. its set of SCOPE accessors)
Thanks,
Aaron
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en.