mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-18 18:30:40 -07:00
Prepare logical for grouping
This commit is contained in:
@@ -62,14 +62,10 @@ module Liquid
|
||||
#
|
||||
# `a == b and b or c` is evaluated like (a and (b or c))
|
||||
def logical
|
||||
operator = nil
|
||||
expr = equality
|
||||
while (operator = id?('and') || id?('or'))
|
||||
if expr.is_a?(BinaryExpression) && (expr.operator == 'and' || expr.operator == 'or')
|
||||
expr.right_node = BinaryExpression.new(expr.right_node, operator, equality)
|
||||
else
|
||||
expr = BinaryExpression.new(expr, operator, equality)
|
||||
end
|
||||
end
|
||||
expr = BinaryExpression.new(expr, operator, equality) if (operator = consume?(:logical))
|
||||
expr.right_node = BinaryExpression.new(expr.right_node, operator, equality) while (operator = consume?(:logical))
|
||||
expr
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user