This commit is contained in:
vonhyou 2021-04-14 08:56:12 +08:00
parent 6e5d36a823
commit 3cb684840a

View file

@ -44,17 +44,16 @@ end
def atom(token) def atom(token)
# Analyse numbers and symbols # Analyse numbers and symbols
isInteger = ->(atom) { atom.match?(/^-?\d+$/) } is_integer = ->(atom) { atom.match?(/^-?\d+$/) }
isFloat = ->(atom) { atom.match?(/^(-?\d+)(\.\d+)?$/) } is_float = ->(atom) { atom.match?(/^(-?\d+)(\.\d+)?$/) }
return Integer token if isInteger.call token return Integer token if is_integer.call token
return Float token if isFloat.call token return Float token if is_float.call token
token.to_sym token.to_sym
end end
# p parse '(def 1 2 (c 3.3 (r f r) e))' # p parse '(def 1 2 (c 3.3 (r f r) e))'
##### Environments ##### Environments
def generate_env def generate_env