Lex processing instructions in chunks

Similar to comments (ea8b4aa92f) and CDATA
tags (8acc7fc743) processing instructions
are now lexed in separate chunks _with_ proper support for streaming
input.

Related issue: #93
This commit is contained in:
Yorick Peterse committed 2015-04-15 00:11:57 +02:00
1 parent ea8b4aa92f
commit b2ea20ba61
6 files changed
+118 -13

No files matched your search

+9
View File
@@ -344,6 +344,15 @@ module Oga
add_token(:T_PROC_INS_NAME, value)
end
##
# Called on the body of a processing instruction.
#
# @param [String] value
#
def on_proc_ins_body(value)
add_token(:T_PROC_INS_BODY, value)
end
##
# Called on the end of a processing instruction.
#
+7 -2
View File
@@ -29,7 +29,7 @@
%terminals T_CDATA_START T_CDATA_BODY T_CDATA_END;
%terminals T_ELEM_START T_ELEM_NAME T_ELEM_NS T_ELEM_END T_ATTR T_ATTR_NS;
%terminals T_XML_DECL_START T_XML_DECL_END;
%terminals T_PROC_INS_START T_PROC_INS_NAME T_PROC_INS_END;
%terminals T_PROC_INS_START T_PROC_INS_NAME T_PROC_INS_BODY T_PROC_INS_END;
document
= expressions { on_document(val[0]) }
@@ -117,12 +117,17 @@ comment_body
# Processing Instructions
proc_ins
= T_PROC_INS_START T_PROC_INS_NAME T_TEXT? T_PROC_INS_END
= T_PROC_INS_START T_PROC_INS_NAME proc_ins_body T_PROC_INS_END
{
on_proc_ins(val[1], val[2])
}
;
proc_ins_body
= T_PROC_INS_BODY proc_ins_body { val[0] + val[1] }
| _ { '' }
;
# Elements
element_name_ns