开发者

What does the -y/-yacc flag do in bison?

I searched the man page and found this. But... what does it mean? without it my bison file doesnt compile and i would like to know why it doesnt (admittedly i have a few shift/reduce and reduce/reduce errors. But that shouldnt stop it?).

Does anyone have a link to what it actually does or why it would not compile my code?

   -开发者_Python百科y, --yacc
          emulate POSIX Yacc


By default, Bison generates one set of file names, but POSIX requires a different set of file names. The -y flag makes Bison generate the POSIX names instead of its own set of names.

For input file name grammar.y, Bison normally produces grammar.tab.c (and grammar.tab.h if you request the header). With the -y flag, Bison produces y.tab.c and y.tab.h.

Note that the -y flag should only affect the output file names. It should have no effect on what is acceptable as a grammar, nor on the number of conflicts.

Interestingly, on the same grammar, the output is slightly different; the action lines have an empty statement in them:

$ diff y.tab.c grammar.tab.c
558c558
< #line 559 "y.tab.c"
---
> #line 559 "grammar.tab.c"
2828c2828
<     { stmt_type = STMT_NONE; }
---
>     { stmt_type = STMT_NONE; ;}
2833c2833
<     { stmt_type = STMT_LOAD; }
---
>     { stmt_type = STMT_LOAD; ;}
...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜