推 sophialiege:cout<<strcmp(str,"syntax error")?str:"ill.. syn."; 05/24 10:54
※ 引述《sophialiege (with friends)》之銘言:
: ※ 引述《wens ( )》之銘言:
: : 發現只要用 error,
: : yacc 一定會印 syntax error.
: : 有沒有辦法避免他印出來啊?
: 我想我知道為什麼你的會印"syntax error"了
: 因為error token出現會去call yyerror而你的yyerror大概是這樣寫
: void yyerror(const char* str){
: ....
: cout << str << endl;
: ....
: }
: 我的寫法是
: void yyerror(const char* str){
: /* do nothing, make compiler happy only */
: }
不過這樣一來就要自己去抓syntax error啦
有程式幫忙抓還滿爽的XD
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.90.104