[antlr-interest] Skipping or ignoring whole subtrees in a tree grammar
Frank Smith
fasmith718 at gmail.com
Mon Aug 13 08:44:21 PDT 2007
my mistake: you can access bar by doing foo.start.getChild(0);
Sorry for the mixup
--Frank
On 8/13/07, Frank Smith <fasmith718 at gmail.com> wrote:
>
> Use the wild card. That causes a tree grammar to skip a token e.g.:
>
> ...
> | ^(DELETED_FOO .)
> ...
>
> you can still access bar if you want by using
> DELETED_FOO.start.getChild(0); if you want to use it in an action somehow,
> but not be stepped through automatically by the walker. I used this a lot-
> works great.
>
> Best regards,
> Frank
>
> On 8/13/07, Hardy, Stephen <Stephen_Hardy at rabbit.com> wrote:
> >
> > 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
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070813/3d873796/attachment.html
More information about the antlr-interest
mailing list