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
|
@data = data
|
||||||
@html = options[:html]
|
@html = options[:html]
|
||||||
@strict = options[:strict] || false
|
@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
|
@line = 1
|
||||||
@elements = []
|
@elements = []
|
||||||
|
|
||||||
@data.rewind if @data.respond_to?(:rewind)
|
|
||||||
|
|
||||||
reset_native
|
reset_native
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -149,9 +138,6 @@ module Oga
|
||||||
|
|
||||||
# Gathers all the tokens for the input and returns them as an Array.
|
# 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
|
# @see #advance
|
||||||
# @return [Array]
|
# @return [Array]
|
||||||
def lex
|
def lex
|
||||||
|
@ -161,7 +147,7 @@ module Oga
|
||||||
tokens << [type, value, line]
|
tokens << [type, value, line]
|
||||||
end
|
end
|
||||||
|
|
||||||
reset
|
reset_native
|
||||||
|
|
||||||
tokens
|
tokens
|
||||||
end
|
end
|
||||||
|
@ -178,8 +164,6 @@ module Oga
|
||||||
# This method stores the supplied block in `@block` and resets it after
|
# This method stores the supplied block in `@block` and resets it after
|
||||||
# the lexer loop has finished.
|
# the lexer loop has finished.
|
||||||
#
|
#
|
||||||
# This method does *not* reset the internal state of the lexer.
|
|
||||||
#
|
|
||||||
# @yieldparam [Symbol] type
|
# @yieldparam [Symbol] type
|
||||||
# @yieldparam [String] value
|
# @yieldparam [String] value
|
||||||
# @yieldparam [Fixnum] line
|
# @yieldparam [Fixnum] line
|
||||||
|
|
|
@ -245,7 +245,7 @@ string_body
|
||||||
def reset
|
def reset
|
||||||
@line = 1
|
@line = 1
|
||||||
|
|
||||||
@lexer.reset
|
@lexer.reset_native
|
||||||
end
|
end
|
||||||
|
|
||||||
# Yields the next token from the lexer.
|
# Yields the next token from the lexer.
|
||||||
|
|
|
@ -17,14 +17,6 @@ describe Oga::XML::Lexer do
|
||||||
]
|
]
|
||||||
end
|
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
|
it 'lexes an attribute value starting with a newline' do
|
||||||
io = StringIO.new("<foo bar='\n10'></foo>")
|
io = StringIO.new("<foo bar='\n10'></foo>")
|
||||||
lexer = described_class.new(io)
|
lexer = described_class.new(io)
|
||||||
|
|
Loading…
Reference in New Issue