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