Making bison/flex parser reentrant with integral YYSTYPE

送分小仙女□ 提交于 2019-12-04 18:23:23
Chris Dodd

Normally to make a reentrant parser/scanner, you'll use %option bison-bridge in your .l file and %define api.pure in your .y file. This makes yylval an argument to yylex instead of a global variable. In addition, you need have:

%{
#define YYPARSE_PARAM yyscan_t scanner
#define YYLEX_PARAM scanner
%}

in the top of your .y file to pass the extra scanner parameter through your parser to your lexer.

Now if YYSTYPE is int (you have no %union or declaration of YYSTYPE in your .y file), then you'd set the token value in your .l by just saying *yylval = whatever;

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!