Re: reduce/reduce conflict in CSS2?

"Mike Dimmick" <mike@dimmick.demon.co.uk>
4 Jan 2001 01:00:41 -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: "Mike Dimmick" <mike@dimmick.demon.co.uk>
Newsgroups: comp.compilers
Date: 4 Jan 2001 01:00:41 -0500
Organization: Compilers Central
References: 00-12-121
Keywords: parse
Posted-Date: 04 Jan 2001 01:00:40 EST

"Andreas Schlapbach" <schlpbch@iam.unibe.ch> wrote in message
> 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 ]*
> ;
>
[...]


Bison has troubles with multiple empty rules, I've found (on the few
bits I attempted to use it for, before discarding it for a different
tool). You're probably better using the rules:


combinator
        : '+' s_0toN
        | '>' s_0toN
        ;


selector
        : simple_selector
        | selector simple_selector
        | selector combinator simple_selector
        ;


Which also makes your rules left-recursive, so your stack space will be
lower.


HTH,


--
Mike Dimmick


Post a followup to this message

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