I want to handle error recovery from bison2.4.1.
I referred to a oreilly's book(lex&yacc) and some websites to put the error token in my rule,
but I think it doesn't work. it doesn't help me handling error recovery!
my code is as follows:
PDL:
DataDesc ComputationDesc {Build_front_proc($1,$2);}
;
DataDesc:
PartyDecl AccLvDesc {$$ = echo_dataDesc($1, $2);}
;
// Party Description
PartyDecl:
PARTY ':' ID ',' ID ENDL {if($3->is_func || $5->is_func)
yyerror("it is a reserved word!\n");
$$ = echo_partyDecl($3->name,$5->name);}
|error ENDL {printf("There is a error");}
;
I gave words of "Party: id_a ;" (it should be two id name after "Party".)
and it went straight to yyerror() and showed syntax error...
I have no idea why it doesn't handle this error.