Allow \r in pre terminators
This commit is contained in:
parent
f290d7c2c7
commit
21793fb83e
1 changed files with 17 additions and 2 deletions
|
@ -132,13 +132,28 @@
|
||||||
(unget chars))))
|
(unget chars))))
|
||||||
|
|
||||||
(define (next) (get-char port))
|
(define (next) (get-char port))
|
||||||
|
(define (peek) (peek-char port))
|
||||||
|
|
||||||
(define (next-not-eof ctx)
|
(define (next-not-eof ctx)
|
||||||
(let ((ch (next)))
|
(let ((ch (next)))
|
||||||
(if (eof-object? ch)
|
(if (eof-object? ch)
|
||||||
(error "EOF while reading" ctx)
|
(error "EOF while reading" ctx)
|
||||||
ch)))
|
ch)))
|
||||||
(define (next-line-and-delim) (read-line port 'split))
|
(define (next-line-and-delim)
|
||||||
(define (peek) (peek-char port))
|
(let lp ((chars '()))
|
||||||
|
(define (finish delim)
|
||||||
|
(cons (reverse-list->string chars) delim))
|
||||||
|
(let ((ch (next)))
|
||||||
|
(cond
|
||||||
|
((eof-object? ch) (finish ch))
|
||||||
|
((eqv? ch #\return)
|
||||||
|
(if (eqv? (peek) #\newline)
|
||||||
|
(finish (next))
|
||||||
|
(lp (cons ch chars))))
|
||||||
|
((eqv? ch #\newline)
|
||||||
|
(finish ch))
|
||||||
|
(else
|
||||||
|
(lp (cons ch chars)))))))
|
||||||
|
|
||||||
(define (skip-whitespace k)
|
(define (skip-whitespace k)
|
||||||
(let lp ((indent 0))
|
(let lp ((indent 0))
|
||||||
|
|
Loading…
Reference in a new issue