mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-17 01:40:42 -07:00
Extract Parser#range_lookup out of Expression.parse
This commit is contained in:
+12
-1
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user