Skip to content

Commit

Permalink
Revert "fixing issue #100"
Browse files Browse the repository at this point in the history
This reverts commit d443299.
  • Loading branch information
JeffBezanson committed Jul 9, 2011
1 parent b6a1ae0 commit 793b9a5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion j/client.j
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jl_banner_color =
$(jl)_ _ _| |_ __ _$(tx) | pre-release version
$(jl)| | | | | | |/ _` |$(tx) |
$(jl)| | |_| | | | (_| |$(tx) |
$(jl)_/ |\\__'_|_|_|\\__'_|$(tx) |
$(jl)_/ |\\\\__'_|_|_|\\\\__'_|$(tx) |
$(jl)|__/$(tx) |

\033[0m"
Expand Down
26 changes: 22 additions & 4 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@
(not (ts:space? s)))
;; custom prefixed string literals, x"s" => @x_str "s"
(let ((str (begin (take-token s)
(parse-string-literal s)))
(parse-string-literal s #t)))
(macname (symbol (string ex '_str))))
(loop `(macrocall ,macname ,(car str))))
ex))
Expand Down Expand Up @@ -856,10 +856,26 @@
(error "incomplete: invalid string syntax")
c))

(define (unescape-quotes buf)
(let ((b (open-output-string)))
(io.seek buf 0)
(let loop ((c (read-char buf)))
(if (eof-object? c)
#t
(begin (if (eqv? c #\\)
(let ((nextch (read-char buf)))
(if (or (eqv? nextch #\") (eqv? nextch #\\))
(write-char nextch b)
(begin (write-char #\\ b)
(write-char nextch b))))
(write-char c b))
(loop (read-char buf)))))
(io.tostring! b)))

; reads a raw string literal with no processing.
; quote can be escaped with \, but the \ is left in place.
; returns ("str" . b), b is a boolean telling whether interpolation is used
(define (parse-string-literal s)
(define (parse-string-literal s unescape-q)
(let ((b (open-output-string))
(p (ts:port s))
(interpolate #f)
Expand All @@ -878,7 +894,9 @@
(set! interpolate #t))
(write-char (not-eof-3 c) b)))
(loop (read-char p)))))
(cons (io.tostring! b) interpolate)))
(if (and hasquotes (or unescape-q interpolate))
(cons (unescape-quotes b) interpolate)
(cons (io.tostring! b) interpolate))))

(define (not-eof-1 c)
(if (eof-object? c)
Expand Down Expand Up @@ -1017,7 +1035,7 @@
;; string literal
((eqv? t #\")
(take-token s)
(let ((ps (parse-string-literal s)))
(let ((ps (parse-string-literal s #f)))
(if (cdr ps)
`(macrocall str ,(car ps))
(unescape-string (car ps)))))
Expand Down

0 comments on commit 793b9a5

Please sign in to comment.