diff --git a/lib/oga/xml/lexer.rb b/lib/oga/xml/lexer.rb index 4a8d2b3..acb85d4 100644 --- a/lib/oga/xml/lexer.rb +++ b/lib/oga/xml/lexer.rb @@ -77,8 +77,8 @@ module Oga def lex tokens = [] - advance do |token| - tokens << token + advance do |type, value, line| + tokens << [type, value, line] end reset @@ -130,15 +130,17 @@ module Oga end ## - # Adds a token with the given type and value to the list. + # Calls the supplied block with the information of the current token. # # @param [Symbol] type The token type. # @param [String] value The token value. # + # @yieldparam [String] type + # @yieldparam [String] value + # @yieldparam [Fixnum] line + # def add_token(type, value = nil) - token = [type, value, @line] - - @block.call(token) + @block.call(type, value, @line) end ## diff --git a/lib/oga/xml/parser.y b/lib/oga/xml/parser.y index 84733e4..a89d350 100644 --- a/lib/oga/xml/parser.y +++ b/lib/oga/xml/parser.y @@ -184,7 +184,7 @@ end # @yieldparam [Array] # def yield_next_token - @lexer.advance do |(type, value, line)| + @lexer.advance do |type, value, line| @line = line if line yield [type, value]