reduce/reduce conflict in CSS2?

Andreas Schlapbach <schlpbch@iam.unibe.ch>
31 Dec 2000 03:02:39 -0500

          From comp.compilers

Related articles
reduce/reduce conflict in CSS2? schlpbch@iam.unibe.ch (Andreas Schlapbach) (2000-12-31)
Re: reduce/reduce conflict in CSS2? schlpbch@iam.unibe.ch (Andreas Schlapbach) (2001-01-04)
Re: reduce/reduce conflict in CSS2? loewis@informatik.hu-berlin.de (Martin von Loewis) (2001-01-04)
Re: reduce/reduce conflict in CSS2? mike@dimmick.demon.co.uk (Mike Dimmick) (2001-01-04)
| List of all articles for this month |
From: Andreas Schlapbach <schlpbch@iam.unibe.ch>
Newsgroups: comp.compilers
Date: 31 Dec 2000 03:02:39 -0500
Organization: bluewin
Keywords: WWW, parse, question
Posted-Date: 31 Dec 2000 03:02:39 EST

Dear Group


The CSS 2 Grammar (http://www.w3.org/TR/REC-CSS2/grammar.html) has the
following rules:


combinator
    : '+' S*
    | '>' S*
    | /* empty */
    ;


selector
    : simple_selector [ combinator simple_selector ]*
    ;


This is how I'm modelling * (0toN: 0 or more)


s_0toN
  : S s_0toN
  | /* empty */
  ;


combinator
    : '+' s_0toN
    | '>' s_0toN
    | /* empty */
    ;


selector
    : simple_selector combinator_simple_selector_0toN
    ;


combinator_simple_selector_0toN
    : /* empty */
    | combinator simple_selector combinator_simple_selector_0toN
    ;


Bison complains about the following reduce/reduce conflict:


combinator_simple_selector_0toN -> combinator -> /*empty*/


but also


combinator_simple_selector_0toN -> /*empty*/


How do I resolve this conflict?


Andreas


------------
BISON output:
state 68


combinator_simple_selector_0toN -> combinator simple_selector .
combinator_simple_selector_0toN (rule 50)


        '+' shift, and go to state 44
        '>' shift, and go to state 45


        ',' reduce using rule 49 (combinator_simple_selector_0toN)
        ',' [reduce using rule 53 (combinator)]
        '{' reduce using rule 49 (combinator_simple_selector_0toN)
        '{' [reduce using rule 53 (combinator)]
        '+' [reduce using rule 53 (combinator)]
        '>' [reduce using rule 53 (combinator)]
        $default reduce using rule 53 (combinator)


        combinator_simple_selector_0toN go to state 87
        combinator go to state 47


Post a followup to this message

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