Support #; comment.

* module/mes/read-0.mes (read-word): Implement #;.
* reader.c (read_word)[READER]: Likewise.
* tests/read.test: Test it.
* NEWS: Mention it.
This commit is contained in:
Jan Nieuwenhuizen 2016-12-18 10:02:49 +01:00
parent a8b16ba013
commit 9dcff14bba
4 changed files with 6 additions and 0 deletions

1
NEWS
View file

@ -20,6 +20,7 @@ block-comments are all handled by the Scheme reader later.
*** Keywords are supported.
*** Cond now supports =>.
*** Lambda* and define* are now supported.
*** #;-comment is now supported.
* Changes in 0.3 since 0.2
** Core
*** Number-based rather than pointer-based cells.

View file

@ -133,6 +133,9 @@
((eq? (peek-byte) 39) (read-byte)
(cons (lookup (cons (integer->char 35) (cons (integer->char 39) (list))) a)
(cons (read-word (read-byte) w a) (list))))
((eq? (peek-byte) 59) (read-byte)
(read-word (read-byte) w a)
(read-word (read-byte) w a))
((eq? (peek-byte) 96) (read-byte)
(cons (lookup (cons (integer->char 35) (cons (integer->char 96) (list))) a)
(cons (read-word (read-byte) w a) (list))))

View file

@ -94,6 +94,7 @@ read_word (int c, SCM w, SCM a)
if (c == '#' && peekchar () == 'x') {getchar (); return read_hex ();}
if (c == '#' && peekchar () == '\\') {getchar (); return read_character ();}
if (c == '#' && w == cell_nil && peekchar () == '(') {getchar (); return list_to_vector (read_list (a));}
if (c == '#' && peekchar () == ';') {getchar (); read_word (getchar (), w, a); return read_word (getchar (), w, a);}
if (c == '#' && peekchar () == '!') {getchar (); read_block_comment (getchar ()); return read_word (getchar (), w, a);}
#endif //READER
return read_word (getchar (), append2 (w, cons (make_char (c), cell_nil)), a);

View file

@ -32,6 +32,7 @@ cons
#!
barf
!#
#;(bla) (display "must see!\n")
(display `(display ,display)) (newline)
(display `(display ,@'(string port))) (newline)
(display #(0 1 2)) (newline)