From 793b9a5479fa813bcc4d30da952a91c4bfd8a073 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Sat, 9 Jul 2011 15:43:41 -0400 Subject: [PATCH] Revert "fixing issue #100" This reverts commit d443299722695c2e7eefb8740817ccb31d1c9772. --- j/client.j | 2 +- src/julia-parser.scm | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/j/client.j b/j/client.j index 62baf787da34c..6f611bfbe37a5 100644 --- a/j/client.j +++ b/j/client.j @@ -122,7 +122,7 @@ jl_banner_color = $(jl)_ _ _| |_ __ _$(tx) | pre-release version $(jl)| | | | | | |/ _` |$(tx) | $(jl)| | |_| | | | (_| |$(tx) | - $(jl)_/ |\\__'_|_|_|\\__'_|$(tx) | + $(jl)_/ |\\\\__'_|_|_|\\\\__'_|$(tx) | $(jl)|__/$(tx) | \033[0m" diff --git a/src/julia-parser.scm b/src/julia-parser.scm index b268f14bbfe06..9439f33f001d5 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -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)) @@ -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) @@ -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) @@ -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)))))