On Wed, Dec 1, 2010 at 6:21 PM, Kevin J. Cummings wrote:

> I think you need to disambiguate your grammar further.

Could you clarify why do i need to disambiguate the grammar? May be i should
mention that this grammar is working correctly (i.e. i am able to generate
the parser, antlrworks does not issue any warning or errors, and it parses
the input correctly), but my problem is
when the input is invalid (i.e. when doing error reporting).
i described the problem here:
http://www.antlr.org/pipermail/antlr-interest/2010-November/040147.html


Thank you for your time :)

Amr Muhammad
Cairo Univ. Computer Eng. Grad.
twitter:@amrmuhammad <http://twitter.com/amrmuhammad>



On Wed, Dec 1, 2010 at 6:21 PM, Kevin J. Cummings <
[email protected]> wrote:

> On 12/01/2010 10:32 AM, Amr Muhammad wrote:
> > Hello,
> >
> > I have a rule like this:
> >
> > version1 ---  rule1: (rule2 (a+ b* | b* a+) )* (rule2 a*)*
>                        ^^^^^^^^^^^^^^^^^^^^^^^^^
> Hmmm, 1 or more a followed by 0 or more b OR zero or more b followed by
> 1 or more a.
>
> What happens when there are 0 b.  Your code reduces to 1 or more a OR 1
> or more a.
>
> I would re-write this as:
>
> rule1: (rule2 ( (a+ b*) | (b+ a+)) )* (rule2 a*)*
>
> as the case of just matching a+ is handled by the first alternative.
>
> Now you need to handle the problem of the which rule2 case to match
> given that the first one could be empty and you want to match the
> second.  I think you need to disambiguate your grammar further.
>
> --
> Kevin J. Cummings
> [email protected]
> [email protected]
> [email protected]
> Registered Linux User #1232 (http://counter.li.org)
>
> 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