Make Parser.expression parse comparisons

This commit is contained in:
Charles-P. Clermont
2026-01-26 16:52:31 -05:00
parent 6f03452245
commit b161dae495
4 changed files with 88 additions and 0 deletions
+17
View File
@@ -47,7 +47,24 @@ module Liquid
tok[0] == type
end
# expression := comparison
# comparison := primary ((">=" | ">" | "<" | "<=" | ... ) primary)*
# primary := string | number | variable_lookup | range | boolean
def expression
comparison
end
# comparison := primary ((">=" | ">" | "<" | "<=" | ... ) primary)*
def comparison
expr = primary
while look(:comparison)
operator = consume
expr = BinaryExpression.new(expr, operator, primary)
end
expr
end
def primary
token = @tokens[@p]
case token[0]
when :id