[antlr-interest] Nondeterminism between alts 1 and 2 of
block...
Thiago F.G. Albuquerque
tfga at terra.com.br
Mon May 19 14:54:46 PDT 2003
At 22:22 18/05/03 -0700, you wrote:
>For now, I'd use syntactic predicates...
I fixed it like this:
I set k=1 in the parser and modified the grammar:
exp : ID ("(") => func_call
| (variable "=") => assignment
| logical_exp
;
Nondeterminism errors appeared in lots of other places in the grammar, but
all of them could be corrected in the same way.
Thank you, for your help, Terrence. I am sorry if I seemed a bit rude in my
previous message.
Thiago
>Terence
>
>On Sunday, May 18, 2003, at 02:42 PM, Thiago F.G. Albuquerque wrote:
>
> > At 13:14 18/05/03 -0700, you wrote:
> >> Hi. You've correctly analyzed this as a Human. :) Unfortunately, for
> >> the moment, ANTLR generates linear approximate k=2 lookahead not the
> >> real thing (which has sequence information). This is a weakness of
> >> the
> >> parsing strategy not your understanding of LL(k). Sorry.
> >>
> >> I'm actually working on the analysis stuff at the moment (full LL(k)
> >> and semantic predicate hoisting). :)
> >>
> >> Ter
> >
> > Ok, thank you for your answer. But how can I fix this? Is there a
> > workaround? I need to write my parser. This example I sent is a
> > simplification of a larger grammar I am working on (a project for
> > school).
> > Here's an excerpt of the original grammar:
> >
> > exp : func_call
> > | (variable "=") => assignment
> > | logical_exp
> > ;
> >
> > logical_exp : rel_exp (("||" | "&&" | "!") rel_exp)*
> > ;
> >
> > rel_exp : add_exp (rel_op add_exp)*
> > ;
> >
> > rel_op : "<" | "<=" | ">" | ">=" | "==" | "!="
> > ;
> >
> > add_exp : mul_exp (( "+" | "-") mul_exp)*
> > ;
> >
> > mul_exp : atom (( "*" | "/" | "%" ) atom)*
> > ;
> >
> > atom : const
> > | variable
> > | "(" exp ")"
> > ;
> >
> > In this grammar I cannot colapse 'exp' and 'atom' into one rule.
> >
> > What should I do?
> >
> > TIA,
> > Thiago
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list