Bison reduce/reduce problem

mroof@nmt.edu (Morey Roof)
23 Sep 2003 13:04:43 -0400

          From comp.compilers

Related articles
Bison reduce/reduce problem mroof@nmt.edu (2003-09-23)
Re: Bison reduce/reduce problem venkatesha.murthy@windriver.com (Venkatesha Murthy) (2003-09-27)
Re: Bison reduce/reduce problem pjj@cs.man.ac.uk (Pete Jinks) (2003-09-27)
| List of all articles for this month |

From: mroof@nmt.edu (Morey Roof)
Newsgroups: comp.compilers
Date: 23 Sep 2003 13:04:43 -0400
Organization: http://groups.google.com/
Keywords: parse
Posted-Date: 23 Sep 2003 13:04:43 EDT

Hello. I have been trying to figure out how to solve some of these
reduce/reduce errors in bison and have looked through their manual on
it and still don't have much luck. So, here is their example changed
to show the type of problem I am having.


%token ID


%%


def: param_spec {}
      | return_spec ',' {}
;


param_spec: type {}
      | name_list ':' type {}
;


return_spec: type {}
      | name ':' type {}
;


type: ID {}
;


name: ID {}
;


name_list: name {}
      | name ',' name_list {}


So hopefully someone on here could show me how to fix it and could you
sort of walk me through the process. I understand the it caused by
the merging of states and how it happens, but I just can't seem to
find a good solution for it.


Thanks.
[Your grammar isn't LR(k) since it has to look arbitrarily far ahead
to see if there's a comma to tell whether something's a param_spec
or a return_spec. I'd combine them in the grammar and separate them
semantically. -John]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.