Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
simonster committed Jun 24, 2015
1 parent ef4b350 commit 61f953b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/matstr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,15 @@ end
function do_mat_str(ex)
# Hack to do interpolation
interp = parse(string("\"\"\"", replace(ex, "\"\"\"", "\\\"\"\""), "\"\"\""))
@assert interp.head == :macrocall
interp = interp.args[2:end]
if isa(interp, String)
interp = [interp]
elseif interp.head == :string
interp = interp.args
elseif interp.head == :macrocall
interp = interp.args[2:end]
else
throw(ArgumentError("unexpected input"))
end

# Handle interpolated variables
putblock = Expr(:block)
Expand Down Expand Up @@ -135,7 +142,7 @@ function do_mat_str(ex)
unshift!(interp, "clear ans;\nmatlab_jl_has_ans = 0;\n")

# Add a semicolon to the end of the last statement to suppress output
interp[end] = rstrip(interp[end])
isa(interp[end], String) && (interp[end] = rstrip(interp[end]))
push!(interp, ";")

# Figure out if `ans` exists in code to avoid an error if it doesn't
Expand Down

0 comments on commit 61f953b

Please sign in to comment.