Skip to content

Commit

Permalink
synchronize printing of QuoteNode and :quote exprs. ref JuliaLang#6104
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Mar 11, 2014
1 parent 9718fcf commit bbbaf88
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,16 @@ function show_unquoted(io::IO, ex::SymbolNode, ::Int, ::Int)
show_expr_type(io, ex.typ)
end

function show_unquoted(io::IO, ex::QuoteNode, indent::Int, prec::Int)
if isa(ex.value, Symbol) && !(ex.value in quoted_syms)
show_unquoted(io::IO, ex::QuoteNode, indent::Int, prec::Int) =
show_unquoted_quote_expr(io, ex.value, indent, prec)

function show_unquoted_quote_expr(io::IO, value, indent::Int, prec::Int)
if isa(value, Symbol) && !(value in quoted_syms)
print(io, ":")
print(io, ex.value)
print(io, value)
else
print(io, ":(")
show_unquoted(io, ex.value, indent+indent_width, 0)
show_unquoted(io, value, indent+indent_width, 0)
print(io, ")")
end
end
Expand Down Expand Up @@ -496,7 +499,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int)
elseif is(head, :block) || is(head, :body)
show_block(io, "begin", ex, indent); print(io, "end")
elseif is(head, :quote) && nargs == 1
show_unquoted(io, args[1], indent)
show_unquoted_quote_expr(io, args[1], indent, 0)
elseif is(head, :gotoifnot) && nargs == 2
print(io, "unless ")
show_list(io, args, " goto ", indent)
Expand Down

0 comments on commit bbbaf88

Please sign in to comment.