help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help me to eliminate the reduce/shift confliction


From: Johnny_xia
Subject: Help me to eliminate the reduce/shift confliction
Date: Thu, 6 Jun 2002 08:56:12 +0800

Dear All,

I am to write a XML parser. I know there are so many parsers in the internet
already.
But I have many XML files that are not well-formed. The attribute value is not
enclosed
by the quotation marks. Fortunately, these files use simpilified XML. It only
has elements.
And the content of the element are elements, too.

The following is the grammar I wrote, there are two reduce/shift confiliction.

sxmlDocument                  :sxmlElement
                                   |/*empty*/
                                   ;

sxmlElement                        : sxmlSTag      sxmlContent sxmlETag
                                   {
                                         int i;
                                         i++;
                                   }
                                   | sxmlEmptyElement
                                   {
                                         int i;
                                         i++;
                                   }
                                   ;

sxmlEmptyElement              : OPEN_ANGLE_BRA NAME sxmlAttrList SLASH
CLOSE_ANGLE_BRA
                                   {
                                         int i;
                                         i++;
                                   }
                                   ;

sxmlSTag                      : OPEN_ANGLE_BRA NAME sxmlAttrList CLOSE_ANGLE_BRA
                                   {
                                         int i;
                                         i++;
                                   }
                                   ;

sxmlAttrList                  : /*empty*/
                                   | sxmlAttr sxmlAttrList
                                   {
                                         int i;
                                         i++;
                                   }
                                   ;

sxmlAttr                      : NAME EQUAL QUOTEDSTRING
                                   {
                                         int i;
                                         i++;
                                   }
                                   | NAME EQUAL NUMBER//here is not compliant to
 xml spec.
                                   {
                                         int i;
                                         i++;
                                   }
                                   ;

sxmlETag                      : OPEN_ANGLE_BRA SLASH NAME CLOSE_ANGLE_BRA
                                   {
                                         int i;
                                         i++;
                                   }
                                   ;

sxmlContent                        : sxmlElementList
                                   | /*empty*/
                                   ;

sxmlElementList                    : sxmlElement
                              | sxmlElementList sxmlElement
                                   ;

BTW, if I ignore the warning, the parser doesn't work as expected.

Regards,
Johnny Xia.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]