Remove Lexer#reset method
Resolves https://github.com/YorickPeterse/oga/issues/153.
This commit is contained in:
parent
9a47c751e4
commit
dc30b8b6c1
|
@ -112,19 +112,8 @@ module Oga
|
|||
@data = data
|
||||
@html = options[:html]
|
||||
@strict = options[:strict] || false
|
||||
|
||||
reset
|
||||
end
|
||||
|
||||
# Resets the internal state of the lexer. Typically you don't need to
|
||||
# call this method yourself as its called by #lex after lexing a given
|
||||
# String.
|
||||
def reset
|
||||
@line = 1
|
||||
@elements = []
|
||||
|
||||
@data.rewind if @data.respond_to?(:rewind)
|
||||
|
||||
reset_native
|
||||
end
|
||||
|
||||
|
@ -149,9 +138,6 @@ module Oga
|
|||
|
||||
# Gathers all the tokens for the input and returns them as an Array.
|
||||
#
|
||||
# This method resets the internal state of the lexer after consuming the
|
||||
# input.
|
||||
#
|
||||
# @see #advance
|
||||
# @return [Array]
|
||||
def lex
|
||||
|
@ -161,7 +147,7 @@ module Oga
|
|||
tokens << [type, value, line]
|
||||
end
|
||||
|
||||
reset
|
||||
reset_native
|
||||
|
||||
tokens
|
||||
end
|
||||
|
@ -178,8 +164,6 @@ module Oga
|
|||
# This method stores the supplied block in `@block` and resets it after
|
||||
# the lexer loop has finished.
|
||||
#
|
||||
# This method does *not* reset the internal state of the lexer.
|
||||
#
|
||||
# @yieldparam [Symbol] type
|
||||
# @yieldparam [String] value
|
||||
# @yieldparam [Fixnum] line
|
||||
|
|
|
@ -245,7 +245,7 @@ string_body
|
|||
def reset
|
||||
@line = 1
|
||||
|
||||
@lexer.reset
|
||||
@lexer.reset_native
|
||||
end
|
||||
|
||||
# Yields the next token from the lexer.
|
||||
|
|
|
@ -17,14 +17,6 @@ describe Oga::XML::Lexer do
|
|||
]
|
||||
end
|
||||
|
||||
it 'rewinds input when resetting the lexer' do
|
||||
io = StringIO.new("<p class='foo'>\nHello</p>")
|
||||
lexer = described_class.new(io)
|
||||
|
||||
lexer.lex.empty?.should == false
|
||||
lexer.lex.empty?.should == false
|
||||
end
|
||||
|
||||
it 'lexes an attribute value starting with a newline' do
|
||||
io = StringIO.new("<foo bar='\n10'></foo>")
|
||||
lexer = described_class.new(io)
|
||||
|
|
Loading…
Reference in New Issue