Use a case statement in Liquid::Parser#expression

This commit is contained in:
Dylan Thacker-Smith
2020-10-19 12:10:11 -04:00
parent 077bf2a409
commit 6d39050e1e
+4 -6
View File
@@ -46,16 +46,14 @@ module Liquid
tok[0] == type tok[0] == type
end end
SINGLE_TOKEN_EXPRESSION_TYPES = [:string, :number].freeze
private_constant :SINGLE_TOKEN_EXPRESSION_TYPES
def expression def expression
token = @tokens[@p] token = @tokens[@p]
if token[0] == :id case token[0]
when :id
variable_signature variable_signature
elsif SINGLE_TOKEN_EXPRESSION_TYPES.include?(token[0]) when :string, :number
consume consume
elsif token.first == :open_round when :open_round
consume consume
first = expression first = expression
consume(:dotdot) consume(:dotdot)