Simple Flex/Bison C++

拥有回忆 提交于 2019-11-30 05:04:11

You need the extern "C" {} for yylex to be in shady.l:

%{
    extern "C"
    {
        int yylex(void);
    }

    #include "shady.tab.h"
%}

%%

"MOV"|"mov" { return T_MOV; }
"NOP"|"nop" { return T_NOP; }

...etc...

Also, after adding a dummy grammar rule, I was able to build and run this with just:

  559  flex shady.l
  560  bison -d shady.y
  561  g++ shady.tab.c lex.yy.c 
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!