Yecc bug (possibly related to mutually recursive rules)

Manolis Papadakis manopapad@REDACTED
Mon Mar 1 17:16:25 CET 2010


This grammar file:

Nonterminals elem seq.
Terminals 'foo' 'bar' ':'.
Rootsymbol elem.
elem -> 'foo'.
elem -> 'bar'.
elem -> seq.
seq -> elem.
seq -> seq ':' elem.
% or seq -> elem ':' seq.

when fed to yecc (git version) produces this error:

2> yecc:file("bug.yrl").

=ERROR REPORT==== 1-Mar-2010::18:16:06 ===
Error in process <0.36.0> with exit value:
{function_clause,[{yecc,find_reduce_reduce,[[accept,{reduce,10,seq,1,{0,none},undefined}],{cxt,'$end',2,{yecc,"bug.yrl","bug.erl",[],{1,2},bug,[file_attributes,{includefile,[]},{parserfile,[]},report_errors,report_warnings],false...

** exception exit: function_clause
     in function  yecc:find_reduce_reduce/2
        called as
yecc:find_reduce_reduce([accept,{reduce,10,seq,1,{0,none},undefined}],
                                          {cxt,'$end',2,
                                               {yecc,"bug.yrl","bug.erl",[],
                                                     {1,2},
                                                     bug,
                                                     [file_attributes,
                                                      {includefile,[]},
                                                      {parserfile,[]},

report_errors,report_warnings],
                                                     false,true,[],[],false,
                                                     [{1,':'}],
                                                     [],6,<0.37.0>,<0.38.0>,1,

[{0,[{...}|...]},{1,[...]},{2,...},{...}|...],
                                                     16400,20497,[],32786,...},
                                               []})
     in call from yecc:'-find_action_conflicts/1-fun-0-'/3
     in call from lists:foldl/3
     in call from yecc:'-find_action_conflicts/1-fun-1-'/2
     in call from lists:foldl/3
     in call from yecc:find_action_conflicts/1
     in call from yecc:action_conflicts/1
     in call from yecc:'-generate/1-fun-8-'/3

When I stumbled on this, I figured It's easy to achieve the intended
behavior without using a separate non-terminal, simply by declaring
the separator as a left- (or right-) associative operator - and the
resulting grammar file compiles normally.


More information about the erlang-bugs mailing list