Help Resolving Shift Reduce Conflicts In Bison Grammar

"Fraser Orr" <>
29 May 2001 23:57:21 -0400

          From comp.compilers

Related articles
Help Resolving Shift Reduce Conflicts In Bison Grammar (Fraser Orr) (2001-05-29)
Re: Help Resolving Shift Reduce Conflicts In Bison Grammar (2001-05-31)
| List of all articles for this month |

From: "Fraser Orr" <>
Newsgroups: comp.compilers
Date: 29 May 2001 23:57:21 -0400
Organization: XNet Information Systems (Winstar)
Keywords: parse, question
Posted-Date: 29 May 2001 23:57:21 EDT

I have a simple grammar that parses a small language similar
to HTML. A fragment looks something like this:

text : /* empty */
        | text textElement

textElement: inlineElement
                        | paragraph

inlineText : /* empty */
                        | inlineText inlineElement

inlineElement : TEXTBLOCK
                        | BOLD inlineText BOLD_END

paragraph: PARA inlineText optParaEnd

optParaEnd: /* empty */
                    | PARA_END

This produces two shift reduce conflicts. The problem
being that the grammar does not specify how to group a
sequence of inlineElement. For example:

<P> textblock1 textblock2

when parsed at text can either resolve to
              (PARA textblock1) textblock2
              (PARA textblock1 textblock2)

The latter is correct, that is the shift is correct behavior,
however, I would like to eliminate the shift reduce conflict
since this problem is spreading all over the grammar. Does
anyone have a suggestion?

Post a followup to this message

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