reader: fix parsing of here strings

This commit is contained in:
Matthew Flatt 2018-02-26 14:59:25 -07:00
parent 61fffa4646
commit 014441bceb
3 changed files with 24 additions and 14 deletions

View File

@ -213,6 +213,12 @@
(err/rt-test (readstr "\"\\uD800\\uDD\"") exn:fail:read?)
(err/rt-test (readstr "\"\\uD800\\uDD1\"") exn:fail:read?)
(test "abc" readstr "#<<EOS\nabc\nEOS\n")
(test "abc" readstr "#<<EOS\nabc\nEOS")
(test "ok\r\nmore\r" readstr "#<<EOS\r\nok\r\nmore\r\nEOS\r")
(err/rt-test (readstr "#<<EOS\nabc\nEO") exn:fail:read?)
(err/rt-test (readstr "#<<EOS\r\nabc\nEOS") exn:fail:read?)
(test (bytes 7) readstr "#\"\\a\"")
(test (bytes 8) readstr "#\"\\b\"")
(test (bytes 9) readstr "#\"\\t\"")

View File

@ -171,6 +171,8 @@
;; Parse terminator
(define full-terminator
(cons
#\newline
(let loop ()
(define c (read-char/special in config source))
(cond
@ -181,7 +183,7 @@
(reader-error in config #:due-to c
"found non-character while reading `#<<`")]
[(char=? c #\newline) null]
[else (cons c (loop))])))
[else (cons c (loop))]))))
;; Get string content
(let loop ([terminator full-terminator] [terminator-accum null])

View File

@ -51999,6 +51999,8 @@ static const char *startup_source =
"(let-values(((source_28)(read-config-source config_48)))"
"(let-values(((accum-str_5)(accum-string-init! config_48)))"
"(let-values(((full-terminator_0)"
"(cons"
" '#\\newline"
"((letrec-values(((loop_112)"
"(lambda()"
"(begin"
@ -52041,7 +52043,7 @@ static const char *startup_source =
"(if(char=? c_87 '#\\newline)"
"(let-values() null)"
"(let-values()(cons c_87(loop_112)))))))))))"
" loop_112))))"
" loop_112)))))"
"(let-values((()"
"(begin"
"((letrec-values(((loop_113)"