looks like ruleunop should be one level higher in the expression tree. Are
you trying to type in a grammar straight from a spec by any chance? Specs
are rarely written in LL(k) form as they are more descriptions of a
language perhaps for programmers and so on, but not usually for parser
writers. You will have to left disambiguate as you read the spec, and then
express it in LL terms. Unfortunately only experience will tell you how to
do this well. It looks like you have basically typed in all the things
that ruleExpression can be, but not in any kind of structured form. If it
is a simple language, then it should be easy enough to sort out.

Here is why you have an ambiguity (not a disambiguity):

1) See a ruleunop, which is followed by another ruleexpression.
2) At the end of that rule expression, the [ can be consumed, or it can be
left to the end of the first expression. Ther is no way to no which
expression it should belong to.

So:

ruleExpression
  : ruleUnop exprlevel2
  | exprlevel2
  ;

exprlevel2
   : exprlevel3 rulesSelector?
   ;

exprlevel3
  : the other stuff ...


Should begin to give you some hints on structure.

Jim

> -----Original Message-----
> From: [email protected] [mailto:antlr-interest-
> [email protected]] On Behalf Of Martin Becker
> Sent: Monday, March 21, 2011 6:14 AM
> To: [email protected]
> Subject: [antlr-interest] How to Read ANTLR Ambiguous Path
> Visualization?
>
> Hi there,
>
> I'm new to grammars and ANTLR(Works) and having a problem now. I
> understand there is some disambiguity in my grammar, but due to lack of
> documentation of the 'Ambiguous Path Visualization' in ANTLRWorks, I
> don't understand what it is trying to tell me. Please have a look at
> this screenshot: http://picfront.de/d/87zv
>
> The error is "Decision can match input such as "'['" using multiple
> alternatives: 1, 2"
>
> Please note that the line between the state "ruleSelector" in the upper
> right corner and the rule "ruleSelector" on the left side is green and
> red, so this seems to be a path for both alternatives.
>
> First of all...does it mean, that the disambiguity starts at the upper
> right corner, before "ruleSelector"? And then...the red path is just
> confusing. I don't understand from where to where it goes...
>
> Could anyone explain that to me, please?
>
> Thanks, Martin
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address

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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to