LispSyntax.jl icon indicating copy to clipboard operation
LispSyntax.jl copied to clipboard

Issue parsing floats

Open ahumenberger opened this issue 5 years ago • 1 comments

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")])

ahumenberger avatar Oct 28 '19 08:10 ahumenberger

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

TheodoreEhrenborg avatar Sep 06 '23 20:09 TheodoreEhrenborg