Handle form-feed.

* module/mes/read-0.mes (eat-whitespace, read-word): Handle form-feed.
* reader.c (eat_whitespace, read_word): Likewise.
This commit is contained in:
Jan Nieuwenhuizen 2016-12-16 18:30:54 +01:00
parent 94d1c65bde
commit 885f48757a
2 changed files with 5 additions and 1 deletions

View file

@ -71,6 +71,7 @@
(cond (cond
((eq? (peek-byte) 9) (read-byte) (eat-whitespace)) ((eq? (peek-byte) 9) (read-byte) (eat-whitespace))
((eq? (peek-byte) 10) (read-byte) (eat-whitespace)) ((eq? (peek-byte) 10) (read-byte) (eat-whitespace))
((eq? (peek-byte) 12) (read-byte) (eat-whitespace))
((eq? (peek-byte) 13) (read-byte) (eat-whitespace)) ((eq? (peek-byte) 13) (read-byte) (eat-whitespace))
((eq? (peek-byte) 32) (read-byte) (eat-whitespace)) ((eq? (peek-byte) 32) (read-byte) (eat-whitespace))
((eq? (peek-byte) 59) (begin (read-line-comment (read-byte)) ((eq? (peek-byte) 59) (begin (read-line-comment (read-byte))
@ -112,6 +113,7 @@
((eq? c -1) (list)) ((eq? c -1) (list))
((eq? c 10) (if (null? w) (read-word (read-byte) (list) a) ((eq? c 10) (if (null? w) (read-word (read-byte) (list) a)
(lookup w a))) (lookup w a)))
((eq? c 12) (read-word 10 w a))
((eq? c 32) (read-word 10 w a)) ((eq? c 32) (read-word 10 w a))
((eq? c 34) (if (null? w) (read-string) ((eq? c 34) (if (null? w) (read-string)
(begin (unread-byte c) (lookup w a)))) (begin (unread-byte c) (lookup w a))))

View file

@ -57,6 +57,8 @@ SCM
read_word (int c, SCM w, SCM a) read_word (int c, SCM w, SCM a)
{ {
if (c == EOF && w == cell_nil) return cell_nil; if (c == EOF && w == cell_nil) return cell_nil;
if (c == '\t') return read_word ('\n', w, a);
if (c == '\f') return read_word ('\n', w, a);
if (c == '\n' && w == cell_nil) return read_word (getchar (), w, a); if (c == '\n' && w == cell_nil) return read_word (getchar (), w, a);
if (c == '\n' && VALUE (car (w)) == '.' && cdr (w) == cell_nil) return cell_dot; if (c == '\n' && VALUE (car (w)) == '.' && cdr (w) == cell_nil) return cell_dot;
if (c == EOF || c == '\n') return lookup (w, a); if (c == EOF || c == '\n') return lookup (w, a);
@ -177,7 +179,7 @@ read_string ()
int int
eat_whitespace (int c) eat_whitespace (int c)
{ {
while (c == ' ' || c == '\t' || c == '\n') c = getchar (); while (c == ' ' || c == '\t' || c == '\n' || c == '\f') c = getchar ();
if (c == ';') return eat_whitespace (read_line_comment (c)); if (c == ';') return eat_whitespace (read_line_comment (c));
#if READER #if READER
if (c == '#' && peekchar () == '!') {getchar (); read_block_comment (getchar ()); return eat_whitespace (getchar ());} if (c == '#' && peekchar () == '!') {getchar (); read_block_comment (getchar ()); return eat_whitespace (getchar ());}