Skip to content

Commit

Permalink
allow quoting all reserved words using : and no space. fixes JuliaL…
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Aug 11, 2014
1 parent 640ccec commit 3ce4298
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ show_unquoted(io::IO, ex::QuoteNode, indent::Int, prec::Int) =
function show_unquoted_quote_expr(io::IO, value, indent::Int, prec::Int)
if isa(value, Symbol) && !(value in quoted_syms)
s = string(value)
if (isidentifier(s) || isoperator(value)) && s != "end"
if isidentifier(s) || isoperator(value)
print(io, ":")
print(io, value)
else
Expand Down
9 changes: 6 additions & 3 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1689,9 +1689,12 @@
;; symbol/expression quote
((eq? t ':)
(take-token s)
(if (closing-token? (peek-token s))
':
(list 'quote (parse-atom- s))))
(let ((nxt (peek-token s)))
(if (and (closing-token? nxt)
(or (not (symbol? nxt))
(ts:space? s)))
':
(list 'quote (parse-atom- s)))))

;; misplaced =
((eq? t '=) (error "unexpected \"=\""))
Expand Down
2 changes: 1 addition & 1 deletion test/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ end"""
@test sprint(show, symbol("foo bar")) == "symbol(\"foo bar\")"
@test sprint(show, symbol("foo \"bar")) == "symbol(\"foo \\\"bar\")"
@test sprint(show, :+) == ":+"
@test sprint(show, symbol("end")) == "symbol(\"end\")"
@test sprint(show, :end) == ":end"

# Function and array reference precedence
@test_repr "([2] + 3)[1]"
Expand Down

0 comments on commit 3ce4298

Please sign in to comment.