user34537
user34537

Reputation:

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

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.

Upvotes: 1

Views: 197

Answers (1)

void
void

Reputation: 36

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.

Upvotes: 2

Related Questions