help-bison
[Top][All Lists]
Advanced

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

Re: Reduce-Reduce problem choosing a path


From: Adam Smalin
Subject: Re: Reduce-Reduce problem choosing a path
Date: Sat, 1 Jun 2013 12:45:49 -0400

I thought I fixed it but I was incorrect. I reworked the rules and the
error is like this

Ambiguity detected.
Option 1,
  A -> <Rule 43, tokens 226 .. 229>
    B -> <Rule 41, tokens 226 .. 228>
      A -> <Rule 43, tokens 226 .. 228>
        B -> <Rule 41, tokens 226 .. 227>
          A -> <Rule 44, tokens 226 .. 227>
            C -> <Rule 45, tokens 226 .. 227>
              D -> <Rule 52, tokens 226 .. 227>
                E -> <Rule 175, tokens 226 .. 227>
                  '$' <tokens 226 .. 226>
                  VarName <tokens 227 .. 227>
        C -> <Rule 45, tokens 228 .. 228>
          D -> <Rule 53, tokens 228 .. 228>
            F -> <Rule 55, tokens 228 .. 228>
              G -> <Rule 59, tokens 228 .. 228>
                '.' <tokens 228 .. 228>
    C -> <Rule 45, tokens 229 .. 229>
      D -> <Rule 46, tokens 229 .. 229>
        H -> <Rule 79, tokens 229 .. 229>
          I -> <Rule 81, tokens 229 .. 229>
            Var -> <Rule 1065, tokens 229 .. 229>
              VarFilter -> <Rule 1066, tokens 229 .. 229>
                VAR <tokens 229 .. 229>

Option 2,
  A -> <Rule 44, tokens 226 .. 229>
    C -> <Rule 45, tokens 226 .. 229>
      D -> <Rule 52, tokens 226 .. 229>
        E -> <Rule 175, tokens 226 .. 229>
          '$' <tokens 226 .. 226>
          VarName -> <Rule 1025, tokens 227 .. 229>
            VarName <tokens 227 .. 227>
            '.' <tokens 228 .. 228>
            Var -> <Rule 1065, tokens 229 .. 229>
              VarFilter -> <Rule 1066, tokens 229 .. 229>
                VAR <tokens 229 .. 229>

I notice they both start at A so maybe I can get it to use C and avoid B
A:
      C          %dprec 2
    | B C       %dprec 1
    | B ',' C    %dprec 1

When I compile and ran it I got no more ambiguity error. HOWEVER it seems
to ALWAYS take the B C path instead of plain C. The line i run is

h.i=$j.k
and my code output says `h  (Tok .) i (Tok .)k
I'm missing `=$j` because it belongs to the i AST and I only print the
left. The `.k` should belong to the $j (see option 2 path). Var name is
basically  `VarName: Var | VarName '.' Var`.

Since in my A rule I say C has a higher precedence why isn't it taking that
path? It seemed to fix the Ambiguity but doesn't seem to listen to the
dprec. I tried making the C rule last of the three and it didnt work.
Doesn't bison always shift when possible? why is it reducing? :(


reply via email to

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