> -----Original Message-----
> From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
> boun...@antlr.org] On Behalf Of Ruslan Zasukhin
> Sent: Thursday, October 13, 2011 2:03 AM
> To: antlr-interest@antlr.org
> Subject: Re: [antlr-interest] Advice on best practice?
>
> On 10/12/11 9:15 PM, "Jim Idle" <j...@temporal-wave.com> wrote:
>
> Hi Jim,
>
> > Avoid backtracking like the plague if you need performance. But if
> you
> > are careful in the order of your alts and use it on just a few
> > decisions/rules, then it might not be so bad (but remember that your
> > error messages will be weak).
>
> Then next question comes to mind:
>     does ANTLR allow us somehow easy to see that during parsing
>     was made 2-3 or 4 backtracking.
>
> Like profiler ... So we can see that and start learn where and why ..
> ?

You can turn on the trace rule stuff, but not in the C target as I never
implemented that, but I am not sure that it would help as there would be
too much information. Some of the other -X options might help. But really,
it is better to just turn off backtracking and resolve the ambiguities as
that is where all the backtracking will be done.

>
> > If k=1 on a decision then ANTLR will work that out so you don't need
> > to specify but if you want to avoid ANTLR following every possible
> alt
> > then you can use k=1 on a particular rule or sub rule to avoid
> > ambiguity errors.
>
> Aha, so playing with k=1 option,
> We can even kill ambiguity errors/warnings.
>
> Interesting.
>
> This is what I ask for -- it will be great to have list of such
> tricks/rules from ANTLR experts ..
>
> >  Basically if you know that a decision will be correct at k=1 even
> > though ANTLR can see ambiguities, then tell it so.
>
> > Before 3.4 this would still give a warning unless you added a 1 token
> > predicate, but I believe that Ter changed this for 3.4 so that I
> could
> > remove a lot of those predicates from my own T-SQL grammar.
>
> So we do not need that one-token predicates now ... Good.
> But I do not understand how it looks?
>
> Can you show example of such predicate just for interest ?


In order to turn off a warning, you would have to do this:

FRED: FRED ((WAS)=>WAS))? var;

Now you can use k=1 to turn that warning off (but experiment on small
grammars to get it right).


Jim

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to