[Top][All Lists]

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

Re: Reductions during Bison error handling

From: Paul Hilfinger
Subject: Re: Reductions during Bison error handling
Date: Fri, 10 May 2002 20:35:27 -0700

As further evidence that perhaps something odd is going on, here is an
example where there is a parse error; it is recovered from; but 
Bison never uses the error production!

    prog: 'x' 'y' 'z' ';' { printf (" x y z ;\n"); }
        | r error ';' { printf (" *err*\n"); }
        | r 'x' ';'  { printf (" x x ;\n"); }
        | q ';'
        | q '.' 

    q : 'x' 

    r : 'x' 

With the input 

     x y x ;

we get the output

     Error: parse error
     x x ;

indicating that 'error' was never shifted. 

Why?  Well, when we pop the stack back to the first 'x' and take the 
reduction r : 'x' (which is indicated when the lookahead token is
error),  the algorithm I sent in the last message has us "proceeding
normally", meaning that we use the current lookahead symbol ('x').

Paul Hilfinger


reply via email to

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