mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 19:00:39 -07:00
avoid using StringScanner eos
This commit is contained in:
+3
-3
@@ -181,7 +181,7 @@ module Liquid
|
|||||||
@output << DOTDOT
|
@output << DOTDOT
|
||||||
elsif special == DASH
|
elsif special == DASH
|
||||||
# Special case for negative numbers
|
# Special case for negative numbers
|
||||||
if !@ss.eos? && NUMBER_TABLE[@ss.peek_byte]
|
if (peeked_byte = @ss.peek_byte) && NUMBER_TABLE[peeked_byte]
|
||||||
@ss.pos -= 1
|
@ss.pos -= 1
|
||||||
@output << [:number, @ss.scan(NUMBER_LITERAL)]
|
@output << [:number, @ss.scan(NUMBER_LITERAL)]
|
||||||
else
|
else
|
||||||
@@ -192,7 +192,7 @@ module Liquid
|
|||||||
end
|
end
|
||||||
elsif (sub_table = TWO_CHARS_COMPARISON_JUMP_TABLE[peeked])
|
elsif (sub_table = TWO_CHARS_COMPARISON_JUMP_TABLE[peeked])
|
||||||
@ss.scan_byte
|
@ss.scan_byte
|
||||||
if !@ss.eos? && (found = sub_table[@ss.peek_byte])
|
if (peeked_byte = @ss.peek_byte) && (found = sub_table[peeked_byte])
|
||||||
@output << found
|
@output << found
|
||||||
@ss.scan_byte
|
@ss.scan_byte
|
||||||
else
|
else
|
||||||
@@ -200,7 +200,7 @@ module Liquid
|
|||||||
end
|
end
|
||||||
elsif (sub_table = COMPARISON_JUMP_TABLE[peeked])
|
elsif (sub_table = COMPARISON_JUMP_TABLE[peeked])
|
||||||
@ss.scan_byte
|
@ss.scan_byte
|
||||||
if !@ss.eos? && (found = sub_table[@ss.peek_byte])
|
if (peeked_byte = @ss.peek_byte) && (found = sub_table[peeked_byte])
|
||||||
@output << found
|
@output << found
|
||||||
@ss.scan_byte
|
@ss.scan_byte
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ class LexerUnitTest < Minitest::Test
|
|||||||
|
|
||||||
def test_error_with_utf8_character
|
def test_error_with_utf8_character
|
||||||
error = assert_raises(SyntaxError) do
|
error = assert_raises(SyntaxError) do
|
||||||
Lexer.new("1 < 1Ø").tokenize
|
tokenize("1 < 1Ø")
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal(
|
assert_equal(
|
||||||
@@ -120,7 +120,7 @@ class LexerUnitTest < Minitest::Test
|
|||||||
def test_contains_as_attribute_name
|
def test_contains_as_attribute_name
|
||||||
assert_equal(
|
assert_equal(
|
||||||
[[:id, "a"], [:dot, "."], [:id, "contains"], [:dot, "."], [:id, "b"], [:end_of_string]],
|
[[:id, "a"], [:dot, "."], [:id, "contains"], [:dot, "."], [:id, "b"], [:end_of_string]],
|
||||||
Lexer.new("a.contains.b").tokenize,
|
tokenize("a.contains.b"),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user