[antlr-interest] Re: syntactic predicates and semantic predicates
Bryan Ewbank
ewbank at gmail.com
Wed Aug 24 14:36:03 PDT 2005
So, does anyone have a similar syntactic->semantic transform for tree
parsers? I'm currently using
{ _t->getType() == BLEAH }? do_me_now
to replace the more expensive:
( BLEAH ) => do_me_now
What's really amusing is that in quite a few cases, the predicate I'm
adding is a duplicate of generated code...
On 8/24/05, Bill Canfield <canfield at computer.org> wrote:
> > From: Bryan Ewbank <ewbank at gmail.com>
> >
> > I've been doing some profiling (generating C++ code), and come to the
> > conclusion - no real surprise - that throwing exceptions are very
> > expensive.
> >
> > How this works out in ANTLR is that I'm replacing syntactic predicates
> > with semantic predicates whereever possible:
>
> That's a good observation. I had a similar epiphany a few weeks ago,
> due to TokenStreamSelector::retry(). retry() is just a wrapper around a
> throw(), so if you switch streams a lot, you'll want to have something
> besides retry() to stitch them all together.
>
> Bill
>
More information about the antlr-interest
mailing list