Use a separate machine for closing tags.

This makes it easier to advance column numbers for whitespace as well as
captuing and emitting tokens for the closing tag.
This commit is contained in:
Yorick Peterse 2014-03-11 21:55:36 +01:00
parent eacd9b88cf
commit 77b40d2e81
1 changed files with 20 additions and 9 deletions

View File

@ -269,6 +269,24 @@ module Oga
}; };
*|; *|;
element_closing_tag := |*
whitespace => { advance_column };
element_name => {
emit_text_buffer
add_token(:T_ELEM_CLOSE, nil)
# Advance the column for the </
advance_column(2)
# Advance the column for the closing name.
advance_column(@te - p)
fret;
};
'>' => { fret; };
*|;
element := |* element := |*
whitespace => { advance_column }; whitespace => { advance_column };
@ -289,15 +307,8 @@ module Oga
'=' (dquote @string_dquote | squote @string_squote); '=' (dquote @string_dquote | squote @string_squote);
# Non self-closing elements. # Non self-closing elements.
'</' element_name { '</' => {
emit_text_buffer fcall element_closing_tag;
add_token(:T_ELEM_CLOSE, nil)
# Advance the column for the </
advance_column(2)
# Advance the column for the closing name.
advance_column(@te - p)
fret; fret;
}; };