Non-Contradiction / JuliaCall

Embed Julia in R
https://non-contradiction.github.io/JuliaCall/index.html
Other
266 stars 36 forks source link

Multiline expression fails: "extra token after end of expression" #197

Open DominiqueMakowski opened 1 year ago

DominiqueMakowski commented 1 year ago

This issue is a follow-up on this one, but the solutions provided there did not solve the case.

This works:

x <- julia_eval("a = 1+1; a + 2")
x
[1] 4

But this doesn't:

juliacode <- "
a = 1+1
a + 2
"

x <- julia_eval(juliacode)
Error: Error happens in Julia.
Base.Meta.ParseError("extra token after end of expression")
Stacktrace:
 [1] parse(str::SubString{String}; raise::Bool, depwarn::Bool)
   @ Base.Meta .\meta.jl:272
 [2] parse
   @ .\meta.jl:266 [inlined]
 [3] eval_string(x::String)
   @ Main.JuliaCall C:\Users\domma\AppData\Local\R\win-library\4.2\JuliaCall\julia\setup.jl:203
 [4] docall(call1::Ptr{Nothing})
   @ Main.JuliaCall C:\Users\domma\AppData\Local\R\win-library\4.2\JuliaCall\julia\setup.jl:176
>

Trimming the string or changing the position of the opening/closing quotes did not seem to help... Any help is welcome :)

AdrienNguyenHuu commented 3 weeks ago

I have the same problem, and the only solution I found is to break the code in single lines julia_command("...").