help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Utterly confused at the Error recovery


From: Joel E. Denny
Subject: Re: Utterly confused at the Error recovery
Date: Sat, 19 Feb 2011 13:19:43 -0500 (EST)
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)

On Sun, 13 Feb 2011, Adam Smalin wrote:

> funcBodyLoop2:
>     | funcBodyLoop2 funcBody
>     | funcBodyLoop2 error aEOS
> 
> What i am expecting is if funcBody gets an error anywhere at all it will use
> the rule funcBodyLoop2 error aEOS. However this is NOT THE CASE. Why? The
> code completely stops because for testing i made it the only error rule.

Perhaps the empty rule for funcBodyLoop2 hasn't been reduced yet when the 
syntax error is encountered, so error can't be shifted.  To see if that's 
the case, you might look at a parser trace.  See the section "Tracing Your 
Parser" in the Bison manual.

> If
> i have a rule in classBody it will use that. Then for fun i tried `| error
> aEOS` in funcBodyLoop2 and that rule was used!!! WTF!!!! My thoughts are why
> is that ever use when it didnt use the other error rule?

That rule can match without having an empty funcBodyLoop2 on the stack.

> (ibm has terrible grammer, its created by someone who
> loops on the right side!)

Right-recursion can be useful.  For example, by delaying the initial 
reduce action in a recursion, it can help with eliminating or resolving 
conflicts.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]