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
: texts
| texts elements { val }
| texts elements texts { val }
| elements
| elements texts { val }
| elements texts elements { val }
: element_body element_body_ { val }
| element_body_
| /* none */ { nil }
;
element_body_
: texts
| elements
;
# Attributes
attributes

View File

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