Greetings!

On Tuesday 28 April 2009 08:10:43 am Gabriel Petrovay wrote:
> Hi all,
>
> I have the parser grammar posted at the bottom of this e-mail. (there
> is a corresponding lexer grammar that provides all the necessary
> tokens).
>
> If I try to build the parser for this grammar, I get the following warning:
> -------
>    warning(200): exit_test.g:13:3: Decision can match input such as
> "IF" using multiple alternatives: 1, 3
>    As a result, alternative(s) 3 were disabled for that input
> -------
>
>........ remainder of original posting snipped...

This is very similar, to me, to the classical if-then-else ambiguity.

Consider this, apparently valid, sentence in your language:

REPLACE EXIT WITH EXIT WITH EXIT

now there are 2 ways to parse this sentence.
is it REPLACE EXIT WITH (EXIT WITH EXIT)
or REPLACE (EXIT WITH EXIT) WITH EXIT
where the parens group together the p_ExitExpr within
each version of the parse. the other instance of the word 
EXIT in each parse is a p_NCName.

and here are the parse trees for each hopefully making
the ambiguity clearer:

1) REPLACE p_ExprSingle WITH p_ExprSingle
                                     |                              |
                           p_StepExpr                p_ExitExpr
                                     |                              |
                          p_NCName                EXIT WITH p_ExprSingle
                                     |                                          
           |
                               EXIT                                             
p_StepExpr
                                                                                
           |
                                                                                
     p_NCName
                                                                                
           |
                                                                                
      EXIT

2) REPLACE p_ExprSingle WITH p_ExprSingle
                                    |                              |
                         p_ExitExpr                 p_StepExpr
                                    |                              |
      EXIT WITH p_ExprSingle           p_NCName
                                    |                              |
                           p_StepExpr               EXIT
                                    |
                           p_NCName
                                    |
                               EXIT

and so your grammar is ambiguous, the warning is correct, predicates have
nothing to do with your problem.

Hope this helps...
   --jbb


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-interest@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