Parser - Segmentation fault when calling yytext

前端 未结 2 1201
既然无缘
既然无缘 2021-01-25 08:43

My parser is recognizing the grammar and indicating the correct error line using yylineno. I want to print the symbol wich caused the error.

int yyerror(string s         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-25 09:24

    Are you using lex or flex? If you're using lex,yytext is a char[], not a char*.

    EDIT If you aren't using flex you should be, it is superior in every way and has been from the moment of its appearance nearly 30 years ago. lex was obsoleted on that day.

提交回复
热议问题