From a50043207b773dab02167e03d8528fa91ae43439 Mon Sep 17 00:00:00 2001 From: Wei-Ting Lin Date: Fri, 25 Sep 2020 18:09:15 -0500 Subject: [PATCH 1/2] Changed p[i] to p[j]. This gives the correct split function. --- src/io.jl | 1 + src/mexpr.jl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/io.jl b/src/io.jl index e48b1bf..bc388e4 100644 --- a/src/io.jl +++ b/src/io.jl @@ -14,6 +14,7 @@ show(io::IO, m::MExpr) = print(io, convert(String, m)) function show(io::IO, ::MIME"text/plain", m::MExpr) input = "'(" * replace(convert(String, m), r";" => ");\n'(") * ")" + println(input) write(ms.input, "$(replace(input, r";" => "\$"))\$\n print(ascii(4))\$") out = (readuntil(ms.output, EOT) |> String |> str -> rstrip(str, EOT)) diff --git a/src/mexpr.jl b/src/mexpr.jl index 266e9bd..c4d26f0 100644 --- a/src/mexpr.jl +++ b/src/mexpr.jl @@ -134,7 +134,7 @@ function split(m::MExpr) for i in 1:length(m.str) p = split(replace(m.str[i], r"\$" => ";"), ';') for j in 1:length(p) - push!(n, p[i]) + push!(n, p[j]) end end return MExpr(n) From 5bf065f980ca31796a36e7a7e81a1ef6bd0bbeaf Mon Sep 17 00:00:00 2001 From: Wei-Ting Lin Date: Fri, 25 Sep 2020 19:52:53 -0500 Subject: [PATCH 2/2] Modified the constructor MExpr(str::String) to work around the semicolon problem. Removed print functions. --- src/io.jl | 1 - src/mexpr.jl | 9 ++++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/io.jl b/src/io.jl index bc388e4..e48b1bf 100644 --- a/src/io.jl +++ b/src/io.jl @@ -14,7 +14,6 @@ show(io::IO, m::MExpr) = print(io, convert(String, m)) function show(io::IO, ::MIME"text/plain", m::MExpr) input = "'(" * replace(convert(String, m), r";" => ");\n'(") * ")" - println(input) write(ms.input, "$(replace(input, r";" => "\$"))\$\n print(ascii(4))\$") out = (readuntil(ms.output, EOT) |> String |> str -> rstrip(str, EOT)) diff --git a/src/mexpr.jl b/src/mexpr.jl index c4d26f0..93b40ff 100644 --- a/src/mexpr.jl +++ b/src/mexpr.jl @@ -106,7 +106,14 @@ end MExpr(m::Array{SubString{String},1}) = MExpr(convert(Array{String, 1}, m)) -MExpr(str::String) = MExpr(push!(String[], str)) +# MExpr(str::String) = MExpr(push!(String[], str)) +function MExpr(str::String) + if str[end] in ";\$" + return MExpr(push!(String[], str[1:end-1])) + else + return MExpr(push!(String[], str)) + end +end MExpr(m::Any) = MExpr("$m")