help-bison
[Top][All Lists]
Advanced

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

Tell a rule to shift instead of reduce?


From: Adam Smalin
Subject: Tell a rule to shift instead of reduce?
Date: Tue, 17 Dec 2013 03:25:21 -0500

I still need help with this. I rewrote it maybe this will be more clear?

I want to allow this

var = var
var, var = var
var = var, var

My rules are similar to the below

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

rvalLoop:
    rval
  | rvalLoop ',' rval

The problem is '=' is higher precedence than ','. When I write "a=b,c" it
reduce when it sees ',' making a=b an rval and rval ',' rval is invalid so
my parser fails and "rval '=' rval ',' rvalLoop" is never used. The
conflict file shows

rval '=' rval . ',' rvalLoop
Conflict between rule 352 and token ',' resolved as reduce (',' < '=').

How do I say for this rule shift instead of reduce? I don't want to make
',' higher than '=' because it would be wrong when looking into functions.
For example func(a,b=2,c) should have b=2 as an expression and not (a,b) =
(2,c).


reply via email to

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