swadey / LispSyntax.jl

lisp-like syntax in julia
Other
229 stars 24 forks source link

Issue parsing floats #34

Open ahumenberger opened 4 years ago

ahumenberger commented 4 years ago

When setting a float value I'm getting the following error:

julia> lisp"(def x 2.5)"
ERROR: LoadError: Malformed def: Length of list must be == 3
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] codegen(::Array{Any,1}) at /Users/ahumenberger/.julia/packages/LispSyntax/ykFIL/src/LispSyntax.jl:91
 [3] lisp_eval_helper(::String) at /Users/ahumenberger/.julia/packages/LispSyntax/ykFIL/src/LispSyntax.jl:154
 [4] @lisp_str(::LineNumberNode, ::Module, ::Any) at /Users/ahumenberger/.julia/packages/LispSyntax/ykFIL/src/LispSyntax.jl:158
in expression starting at REPL[3]:1

which might be because of

julia> LispSyntax.read("(2.5)")
LispSyntax.s_expr(Any[2, Symbol(".5")])
TheodoreEhrenborg commented 1 year ago

This works:

julia> lisp"(def x 2.5d)"
2.5

Alternatively append f to get it parsed as a Float32; see https://github.com/swadey/LispSyntax.jl/blob/master/src/parser.jl