shift/reduce problem

JohnSmith <csnews77@gmail.com>
Thu, 2 Dec 2010 12:29:06 -0800 (PST)

          From comp.compilers

Related articles
shift/reduce problem csnews77@gmail.com (JohnSmith) (2010-12-02)
Re: shift/reduce problem haberg-news@telia.com (Hans Aberg) (2010-12-03)
Re: shift/reduce problem csnews77@gmail.com (JohnSmith) (2010-12-03)
Re: shift/reduce problem haberg-news@telia.com (Hans Aberg) (2010-12-03)
Re: shift/reduce problem gene.ressler@gmail.com (Gene) (2010-12-03)
Re: shift/reduce problem chakaram@auth.gr (Chariton Karamitas) (2010-12-05)
Re: shift/reduce problem seimarao@gmail.com (Seima) (2010-12-30)
[1 later articles]
| List of all articles for this month |

From: JohnSmith <csnews77@gmail.com>
Newsgroups: comp.compilers
Date: Thu, 2 Dec 2010 12:29:06 -0800 (PST)
Organization: Compilers Central
Keywords: parse, question, bison
Posted-Date: 02 Dec 2010 16:05:43 EST

Hi,


I have to parse the following string like this


"(input i, j, k, input u, v, w)"




I have the following rules


top_rule: K_LEFTPAREN function_port_list K_RIGHTPAREN


list_of_variables
: IDENTIFIER
| list_of_variables K_COMMA IDENTIFIER
;


input_declaration0: K_input list_of_variables
;


function_port_list:
      input_declaration0
      | function_port_list K_COMMA input_declaration0
      ;




IDENTIFIER: token for the identifier
K_COMMA: token for comma
K_input: token for "input"
K_LEFTPAREN: token for "("
K_RIGHTPAREN: token for ")"




I'm using bison and flex. Bison reports shift/reduce conflict:
probably because cannot decide on "," when "input" coming (is this an
error or should reduce). How to resolve this problem? Probably I have
to use %left, %right, %prec but I dont know how.




Thanks



Post a followup to this message

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