Recognize | and x char escapes

This commit is contained in:
Justin Ethier 2016-11-19 04:07:46 +00:00
parent ac23534bde
commit ddefaa4167
2 changed files with 24 additions and 0 deletions

View file

@ -1,6 +1,9 @@
# Next Release - Date TBD
TODO: SRFI 113
Features:
- Recognize escaped vertical line and hex scalar value characters when reading a string.
# 0.3.1 - November 20, 2016

View file

@ -471,6 +471,25 @@
(loop (cons (read-char fp) buf))))))
(loop '()))
(define (read-hex-scalar-value fp ptbl)
(define (done buf)
(cond
((= 0 (length buf))
(parse-error "missing character"
(in-port:get-lnum ptbl)
(in-port:get-cnum ptbl)))
(else
(integer->char (string->number (list->string buf) 16)))))
(define (loop buf)
(let ((c (read-char fp)))
(cond
((or (eof-object? c)
(eq? #\; c))
(done (reverse buf)))
(else
(loop (cons c buf))))))
(loop '()))
(define (read-str fp buf ptbl)
(let ((c (read-char fp)))
(cond
@ -505,6 +524,8 @@
((equal? #\n c) (cons #\newline buf))
((equal? #\r c) (cons #\return buf))
((equal? #\t c) (cons #\tab buf))
((equal? #\x c)
(cons (read-hex-scalar-value fp ptbl) buf))
(else
(parse-error (string-append
"invalid escape character ["