help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Change a reduce into Shift?


From: Adam Smalin
Subject: Change a reduce into Shift?
Date: Tue, 10 Dec 2013 02:22:14 -0500

My rules are similar to the below

body:
    recursive-expr //rval = rval is here
  | rval '=' rvalLoop
//  | rval ',' rval //problem line

rvalLoop:
    rval
  | rvalLoop ',' rval

In my test file when I do "var = 5, 6" it works fine. When I uncomment the
problem line my parser breaks. The problem is that line introduces ',' to
recursive-expr. Without the comma the parser would shift into rvalLoop
because comma doesn't lead to any other state. Now with the problem line
the parser sees the ',' is lower than '=' and reduces instead of shifts
which breaks the parser.

How do I tell it to shift in this case? I tried writing "%token
OVERRIDE_PREC" and "%left OVERRIDE_PREC" at the bottom of my %left/%right
directives. Then I used %prec OVERRIDE_PREC on the non recursive-expr lines
but it appears to not have worked.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]