Use the ? operator in the XML parser

This commit is contained in:
Yorick Peterse 2015-03-20 00:13:23 +01:00
parent a4be89aca7
commit 3b74a55d73
1 changed files with 5 additions and 20 deletions

View File

@ -86,13 +86,8 @@ doctype_inline
;
doctype_types
= string doctype_types_follow { [val[0], val[1]] }
| T_DOCTYPE_END { nil }
;
doctype_types_follow
= string T_DOCTYPE_END { val[0] }
| T_DOCTYPE_END { nil }
= string string? T_DOCTYPE_END { [val[0], val[1]] }
| T_DOCTYPE_END { nil }
;
# CDATA tags
@ -110,17 +105,12 @@ comment
# Processing Instructions
proc_ins
= T_PROC_INS_START T_PROC_INS_NAME proc_ins_follow
= T_PROC_INS_START T_PROC_INS_NAME T_TEXT? T_PROC_INS_END
{
on_proc_ins(val[1], val[2])
}
;
proc_ins_follow
= T_PROC_INS_END { nil }
| T_TEXT T_PROC_INS_END { val[0] }
;
# Elements
element_name_ns
@ -154,15 +144,10 @@ attributes
attribute
# x:foo="bar"
= T_ATTR_NS T_ATTR attribute_follow { on_attribute(val[1], val[0], val[2]) }
= T_ATTR_NS T_ATTR string? { on_attribute(val[1], val[0], val[2]) }
# foo="bar"
| T_ATTR attribute_follow { on_attribute(val[0], nil, val[1]) }
;
attribute_follow
= string { val[0] }
| _ { nil }
| T_ATTR string? { on_attribute(val[0], nil, val[1]) }
;
# XML declarations