yacc and bison have the same output in this case. what I understand for that:
64 | IF '(' exp ')' comando . ELSE comando
ELSE shift, and go to state 216
ELSE [reduce using rule 63 (comando)]
$default reduce using rule 63 (comando)
Is that the next token is an ELSE I can shift to state 216 or reduce to state 63 and the default action is to reduce ( $default reduce using rule 63 (comando) ). Or Am I wrong? I'm newbee in yacc.
Main Topics
Browse All Topics





by: Infinity08Posted on 2008-03-31 at 02:11:51ID: 21244036
>> I was told that bison would make shift default.
I usually use yacc, and there the shift is indeed the default - I assume that that's the same for bison.
And it does, no ?
ELSE shift, and go to state 216
where state 216 is probably :
IF '(' exp ')' comando ELSE . comando
so, it does do the shift.
I think (I'm not familiar with bison's output, so I might be mistaken), that this part :
ELSE [reduce using rule 63 (comando)]
$default reduce using rule 63 (comando)
refers to the reduction of the comando rule., not the if rule. Meaning that we've just seen the comando rule, so we reduce it to the comando "token", and can then continue with the ELSE by shifting the ELSE, or reducing the if rule if no ELSE is seen.