Collapse float and int into 'number'

This commit is contained in:
Tristan Hume
2013-07-29 11:04:46 -04:00
parent be4a04ed85
commit bc76c0daaf
4 changed files with 12 additions and 14 deletions
+2 -4
View File
@@ -12,8 +12,7 @@ module Liquid
IDENTIFIER = /[\w\-?!]+/
SINGLE_STRING_LITERAL = /'[^\']*'/
DOUBLE_STRING_LITERAL = /"[^\"]*"/
INTEGER_LITERAL = /-?\d+/
FLOAT_LITERAL = /-?\d+\.\d+/
NUMBER_LITERAL = /-?\d+(\.\d+)?/
COMPARISON_OPERATOR = /==|!=|<>|<=?|>=?|contains/
def initialize(input)
@@ -31,8 +30,7 @@ module Liquid
when t = @ss.scan(COMPARISON_OPERATOR) then [:comparison, t]
when t = @ss.scan(SINGLE_STRING_LITERAL) then [:string, t]
when t = @ss.scan(DOUBLE_STRING_LITERAL) then [:string, t]
when t = @ss.scan(FLOAT_LITERAL) then [:float, t]
when t = @ss.scan(INTEGER_LITERAL) then [:integer, t]
when t = @ss.scan(NUMBER_LITERAL) then [:number, t]
when t = @ss.scan(IDENTIFIER) then [:id, t]
else
c = @ss.getch
+1 -1
View File
@@ -52,7 +52,7 @@ module Liquid
token = @tokens[@p]
if token[0] == :id
variable_signature
elsif [:string, :integer, :float].include? token[0]
elsif [:string, :number].include? token[0]
consume
token[1]
else