diff --git a/lib/oga/lexer.rl b/lib/oga/lexer.rl index aedf3e9..2a2660f 100644 --- a/lib/oga/lexer.rl +++ b/lib/oga/lexer.rl @@ -356,7 +356,7 @@ module Oga action start_comment { emit_buffer - t(:T_COMMENT_START) + add_token(:T_COMMENT_START, nil) start_buffer @@ -368,7 +368,7 @@ module Oga comment := |* comment_end => { emit_buffer - t(:T_COMMENT_END) + add_token(:T_COMMENT_END, nil) fret; }; diff --git a/spec/oga/lexer/comments_spec.rb b/spec/oga/lexer/comments_spec.rb index ac87f36..68f5985 100644 --- a/spec/oga/lexer/comments_spec.rb +++ b/spec/oga/lexer/comments_spec.rb @@ -4,32 +4,32 @@ describe Oga::Lexer do context 'comments' do example 'lex a comment' do lex('').should == [ - [:T_COMMENT_START, '', 1] + [:T_COMMENT_END, nil, 1] ] end example 'lex a comment containing --' do lex('').should == [ - [:T_COMMENT_START, '', 1] + [:T_COMMENT_END, nil, 1] ] end example 'lex a comment containing ->' do lex('').should == [ - [:T_COMMENT_START, '', 1] + [:T_COMMENT_END, nil, 1] ] end example 'lex a comment followed by text' do lex('foo').should == [ - [:T_COMMENT_START, '', 1], + [:T_COMMENT_START, nil, 1], + [:T_COMMENT_END, nil, 1], [:T_TEXT, 'foo', 1] ] end @@ -37,8 +37,8 @@ describe Oga::Lexer do example 'lex text followed by a comment' do lex('foo').should == [ [:T_TEXT, 'foo', 1], - [:T_COMMENT_START, '', 1] + [:T_COMMENT_START, nil, 1], + [:T_COMMENT_END, nil, 1] ] end @@ -47,8 +47,8 @@ describe Oga::Lexer do [:T_ELEM_START, nil, 1], [:T_ELEM_NAME, 'p', 1], [:T_ELEM_END, nil, 1], - [:T_COMMENT_START, '', 1] + [:T_COMMENT_START, nil, 1], + [:T_COMMENT_END, nil, 1] ] end end