mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 20:45:06 +02:00
Recognize | and x char escapes
This commit is contained in:
parent
ac23534bde
commit
ddefaa4167
2 changed files with 24 additions and 0 deletions
|
@ -1,6 +1,9 @@
|
||||||
# Next Release - Date TBD
|
# Next Release - Date TBD
|
||||||
|
|
||||||
TODO: SRFI 113
|
TODO: SRFI 113
|
||||||
|
Features:
|
||||||
|
|
||||||
|
- Recognize escaped vertical line and hex scalar value characters when reading a string.
|
||||||
|
|
||||||
# 0.3.1 - November 20, 2016
|
# 0.3.1 - November 20, 2016
|
||||||
|
|
||||||
|
|
|
@ -471,6 +471,25 @@
|
||||||
(loop (cons (read-char fp) buf))))))
|
(loop (cons (read-char fp) buf))))))
|
||||||
(loop '()))
|
(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)
|
(define (read-str fp buf ptbl)
|
||||||
(let ((c (read-char fp)))
|
(let ((c (read-char fp)))
|
||||||
(cond
|
(cond
|
||||||
|
@ -505,6 +524,8 @@
|
||||||
((equal? #\n c) (cons #\newline buf))
|
((equal? #\n c) (cons #\newline buf))
|
||||||
((equal? #\r c) (cons #\return buf))
|
((equal? #\r c) (cons #\return buf))
|
||||||
((equal? #\t c) (cons #\tab buf))
|
((equal? #\t c) (cons #\tab buf))
|
||||||
|
((equal? #\x c)
|
||||||
|
(cons (read-hex-scalar-value fp ptbl) buf))
|
||||||
(else
|
(else
|
||||||
(parse-error (string-append
|
(parse-error (string-append
|
||||||
"invalid escape character ["
|
"invalid escape character ["
|
||||||
|
|
Loading…
Add table
Reference in a new issue