Skip to content

Commit

Permalink
strip newline and spaces before dedenting
Browse files Browse the repository at this point in the history
  • Loading branch information
simeonschaub committed Jun 17, 2021
1 parent 53ad86c commit 8e6963a
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -2185,8 +2185,13 @@
(define (unescape-parsed-string-literal strs)
(map-at even? unescape-string strs))

(define (strip-escaped-newline s raw)
(if raw s (map (lambda (s)
(if (string? s) (strip-escaped-newline- s) s))
s)))

;; remove `\` followed by a newline
(define (strip-escaped-newline s)
(define (strip-escaped-newline- s)
(let ((in (open-input-string s))
(out (open-output-string)))
(define (loop preceding-backslash?)
Expand All @@ -2210,13 +2215,14 @@
(if (eqv? (peek-char (take-char p)) delim)
(map-first strip-leading-newline
(dedent-triplequoted-string
(parse-string-literal- 2 (take-char p) s delim raw)))
(strip-escaped-newline
(parse-string-literal- 2 (take-char p) s delim raw)
raw)))
(list ""))
(parse-string-literal- 0 p s delim raw))))
(if raw str (unescape-parsed-string-literal
(map (lambda (s)
(if (string? s) (strip-escaped-newline s) s))
str)))))
(strip-escaped-newline
(parse-string-literal- 0 p s delim raw)
raw))))
(if raw str (unescape-parsed-string-literal str))))

(define (strip-leading-newline s)
(let ((n (sizeof s)))
Expand Down

0 comments on commit 8e6963a

Please sign in to comment.