[antlr-interest] Querying the parse tree
Steve Bennett
stevagewp at gmail.com
Mon Dec 3 20:20:21 PST 2007
Hi all,
Just wondering if there is a way to get information about the parse
tree during a parse. For example, I'm frequently using code like this:
----
rule @init { in_rule_levels ++; }
...;
finally { in_rule_levels --; }
...
other_rule: { in_rule_levels < 1 }? => ... ;
----
Sometimes I just want to know at some other point whether I'm
currently "inside" a certain rule, other times I need to know how many
times inside it I am.
Perhaps there is a more elegant way to do this? I briefly looked at
@scope, but it seems more complicated than my approach above. All I
would ever need is the number of times a certain rule has been called
to get to the current point, and possibly a list of callers, like
["rule", "rule", "other_rule"].
Steve
More information about the antlr-interest
mailing list