Lexing of comments.

This fixes #4.
This commit is contained in:
Yorick Peterse committed 2014-02-28 23:27:23 +01:00
1 parent 92ae48f905
commit d9ef33e1f8
2 files changed
+48 -17

No files matched your search

+29 -7
View File
@@ -197,14 +197,34 @@ module Oga
cdata := |*
cdata_end => {
emit_text_buffer
t(:T_CDATA_END)
fret;
};
# Consume everything else character by character and store it in a
# separate buffer.
any => buffer_text;
*|;
# Comments
#
# http://www.w3.org/TR/html-markup/syntax.html#comments
#
# Comments are lexed into 3 parts: the start tag, the content and the end
# tag.
#
# Unlike the W3 specification these rules *do* allow character sequences
# such as `--` and `->`. Putting extra checks in for these sequences
# would actually make the rules/actions more complex.
#
comment_start = '<!--';
comment_end = '-->';
comment := |*
comment_end => {
emit_text_buffer
t(:T_COMMENT_END)
fret;
};
any => buffer_text;
*|;
@@ -214,17 +234,19 @@ module Oga
doctype_start => {
t(:T_DOCTYPE_START)
fcall doctype;
};
# @cdata_buffer is used to store the content of the CDATA tag.
cdata_start => {
t(:T_CDATA_START)
fcall cdata;
};
comment_start => {
t(:T_COMMENT_START)
fcall comment;
};
# General rules and actions.
'<' => { t(:T_SMALLER) };
'>' => { t(:T_GREATER) };