Why is yylval null?

拈花ヽ惹草 提交于 2019-12-06 01:00:11

Normally, yylval is a global struct and not a pointer, and if you remove the %option bison-bridge from your test.l file, that's what you get (you'll need to change yylval->real to yylval.real as well to make it work).

The %option bison-bridge in flex is meant to match up to %define api.pure in bison, which uses a different API for communicating between yyparse and yylex (yylval becomes a pointer argument to yylex instead of a global var).

So your basic problem is an incompatible API between flex and bison -- you need to specify the pure api/bison-bridge in BOTH or NEITHER -- if you do it in one and not the other, things break.

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