Parsing support for multiple nested nodes.

This commit is contained in:
Yorick Peterse 2014-03-15 20:19:54 +01:00
parent 05ee3c13c9
commit ce8bbdb64a
2 changed files with 17 additions and 7 deletions

View File

@ -95,15 +95,16 @@ rule
; ;
element_body element_body
: texts : element_body element_body_ { val }
| texts elements { val } | element_body_
| texts elements texts { val }
| elements
| elements texts { val }
| elements texts elements { val }
| /* none */ { nil } | /* none */ { nil }
; ;
element_body_
: texts
| elements
;
# Attributes # Attributes
attributes attributes

View File

@ -16,6 +16,7 @@ describe Oga::Parser do
parse_html(html).should == s( parse_html(html).should == s(
:document, :document,
s(:doctype), s(:doctype),
s(:text, "\n"),
# <html> # <html>
s( s(
@ -24,6 +25,8 @@ describe Oga::Parser do
'html', 'html',
nil, nil,
s(:text, "\n"),
# <head> # <head>
s( s(
:element, :element,
@ -31,6 +34,8 @@ describe Oga::Parser do
'head', 'head',
nil, nil,
s(:text, "\n"),
# <title> # <title>
s( s(
:element, :element,
@ -38,11 +43,15 @@ describe Oga::Parser do
'title', 'title',
nil, nil,
s(:text, 'Title') s(:text, 'Title')
) ),
s(:text, "\n")
), ),
# <body> # <body>
s(:element, nil, 'body', nil, nil) s(:text, "\n"),
s(:element, nil, 'body', nil, nil),
s(:text, "\n")
), ),
s(:text, "\n") s(:text, "\n")
) )