From ead5c71fee1b3f02039f266395ab0781f55e088a Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Thu, 29 May 2014 01:37:19 +0200 Subject: [PATCH] Cleaned up the XML parser grammar. This resolves all shift/reduce and reduce/reduce conflicts that were previously present. --- lib/oga/xml/parser.y | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/oga/xml/parser.y b/lib/oga/xml/parser.y index 02efd75..62047e7 100644 --- a/lib/oga/xml/parser.y +++ b/lib/oga/xml/parser.y @@ -21,13 +21,16 @@ options no_result_var rule document : expressions { on_document(val[0]) } - | /* none */ { on_document } ; expressions - : expressions expression { val[0] << val[1] } - | expression { val } - | /* none */ { [] } + : expressions_ { val[0] } + | /* none */ { [] } + ; + + expressions_ + : expressions_ expression { val[0] << val[1] } + | expression { val } ; expression @@ -138,8 +141,8 @@ rule # XML declarations xmldecl - : T_XML_DECL_START T_XML_DECL_END { on_xml_decl } - | T_XML_DECL_START attributes T_XML_DECL_END { on_xml_decl(val[1]) } + : T_XML_DECL_START attributes T_XML_DECL_END { on_xml_decl(val[1]) } + ; # Plain text