[antlr-interest] ANTLR Kudos...
Foust
javafoust at gmail.com
Fri Aug 15 14:23:33 PDT 2008
>
> How do you turn on backtracking on a per rule basis?
>
The name of the backtracking option is "backtrack".
options {backtrack=true;}
As noted, per-rule options go before the colon
rule options {backtrack=true; memoize=true;}
: <rule pattern>
;
Brent
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Johannes Luber
> Sent: Friday, August 15, 2008 5:15 AM
> To: Ian Kaplan
> Cc: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] ANTLR Kudos...
>
> Ian Kaplan schrieb:
> >
> >
> > /
> > Performance is not bad with backtracking and memoization; linear
> > time cost. Still better to let ANTLR predict with a simple DFA
> > rather than backtracking. Also can set backtracking per rule./
> >
> >
> >
> > Only a part of my grammar requires more than two symbols of
> look
> > a head. How do you turn on backtracking on a per rule basis? I've
> got
> > it set globally and it may not need to be.
>
> You can put an options block into a rule definition like so (didn't
> test it, so syntax may be a bit off):
>
> rule
> options {
> backtracking=true;
> memoize=true;
> }
> : otherRule;
>
> Johannes
>
> >
> > Thanks,
> >
> > Ian
> >
More information about the antlr-interest
mailing list