Hi,
I need some help from the ANTLR wizards :)
I'm trying to match expressions with field accesses and array indexes.
For example:
costumers.length
costumers[0].address
costumers[costumers.length - 1].orders[0].total
The following rule seems to work:
fieldExpr : atom ('.'^ identifier | ('['^ expr ']'!))*;
However, it creates trees with notes annotated with '[', and I'd
prefer to have a dummy token like INDEX. For example, costumers[0] now
returns
([ (ID costumers) (INT 0))
But I'd like it to return
(INDEX (ID costumers) (INT 0))
I tried to create the AST manually with -> ^(...), but I ended up
nowhere. Maybe I should've tried to refactor the grammar, but that
would make it a little less readable, so I didn't do it.
How do you suggest I do this?
Thank you!
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.