开发者

Conflict with ++ in bison, how to write post / pre?

I get a conflict with ++ and -- in bison.

I wrote these two lines for post and pre increment

| rval PLUSPLUS
| PLUSPLUS rval
开发者_StackOverflow

I get a conflict. It only happens when both are included. I thought it may be involved with syntax like var+++var2 confusing with + pre or post +. However the conflict remained removing removing + in my syntax.

How do i implement ++ and -- for post and pre without syntax problems?

Note This StackExchange proposal is relevant

-edit- its been a while since i worked on this. I found other syntax i can comment out to make no conflicts. I still dont understand it but now i see it isnt just post and pre.


These are two different rules i.e.

POSTFIX_EXPRESSION := rval PLUSPLUS | rval MINUSMINUS
PREFIX_EXPRESSION := PLUSPLUS rval | MINUSMINUS rval

If you have The C Language book (K&R) then look at Appendix A it gives the grammar of the C language which is a good example.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜