[antlr-interest] Skipping or ignoring whole subtrees in a tree grammar
Hardy, Stephen
Stephen_Hardy at rabbit.com
Mon Aug 13 08:37:02 PDT 2007
Hi all,
supposing I have a tree grammar which includes something like
foo
: ^(FOO bar { some action... } )
| ^(DELETED_FOO bar)
;
Suppose bar is a complex, deeply recursive, subtree; and I wish to avoid
as much as possible the overhead of parsing it in the DELETED_FOO case.
(Imagine that DELETED_FOO was once a FOO, but the parser or application
decided after the fact that it was an irrelevant part of the input, and
changed the token to mark it as deleted, but without actually removing
the subtree. Why not delete the tree? Well, a different tree grammar
may still want to see the contents, just not this one.)
Is there a way of telling ANTLR to basically 'skip' any analysis of the
subtree under DELETED_FOO? For example, a routine which simply consumes
tokens from the DOWN which immediately follows DELETED_FOO until the
matching (balanced) UP token is seen?
I seem to recall a mention of something like this in TDAR, but darned if
I can locate it.
Regards,
SJH
More information about the antlr-interest
mailing list