Related articles |
---|
Help Resolving Shift Reduce Conflicts In Bison Grammar ifo@xnet.com (Fraser Orr) (2001-05-29) |
Re: Help Resolving Shift Reduce Conflicts In Bison Grammar chrisd@reservoir.com (2001-05-31) |
From: | "Fraser Orr" <ifo@xnet.com> |
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:
%token PARA PARA_END BOLD BOLD_END TEXTBLOCK
%%
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
or
(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?
Return to the
comp.compilers page.
Search the
comp.compilers archives again.