tags:

views:

20

answers:

1

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

I wrote these two lines for post and pre increment

| rval PLUSPLUS
| PLUSPLUS rval

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.

+2  A: 

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.

void
Where is PREFIX_EXPRESSION placed? I have them both in my rval rule.
acidzombie24
I'll accept it because it is pretty right and the other conflict in code disappeared.
acidzombie24