Extract Parser#range_lookup out of Expression.parse

This commit is contained in:
Charles-P. Clermont
2026-01-26 16:52:17 -05:00
parent 8b04c52ab2
commit dff829ec72
4 changed files with 25 additions and 3 deletions
+12 -1
View File
@@ -58,8 +58,10 @@ module Liquid
string
when :number
number
when :open_round
range_lookup
else
parse_expression(expression_string)
raise SyntaxError, "#{token} is not a valid expression"
end
end
@@ -88,6 +90,15 @@ module Liquid
VariableLookup.new(name, lookups, command_flags)
end
def range_lookup
consume(:open_round)
first = expression
consume(:dotdot)
last = expression
consume(:close_round)
RangeLookup.create(first, last)
end
def expression_string
token = @tokens[@p]
case token[0]