Support backslash in string.
* reader.c (read_string): Handle '\\'. * tests/read.test: Add it.
This commit is contained in:
parent
89f771f18a
commit
6b4bf34ff2
3
reader.c
3
reader.c
|
@ -169,7 +169,8 @@ read_string ()
|
|||
int c = getchar ();
|
||||
while (true) {
|
||||
if (c == '"') break;
|
||||
if (c == '\\' && peekchar () == '"') p = append_char (p, getchar ());
|
||||
if (c == '\\' && peekchar () == '\\') p = append_char (p, getchar ());
|
||||
else if (c == '\\' && peekchar () == '"') p = append_char (p, getchar ());
|
||||
else if (c == '\\' && peekchar () == 'n') {getchar (); p = append_char (p, '\n');}
|
||||
else if (c == EOF) assert (!"EOF in string");
|
||||
else p = append_char (p, c);
|
||||
|
|
|
@ -23,6 +23,17 @@ cons
|
|||
(display #x16) (newline)
|
||||
(display #\A) (newline)
|
||||
(display #\newline) (newline)
|
||||
#\alarm
|
||||
#\backspace
|
||||
#\tab
|
||||
#\newline
|
||||
#\vtab
|
||||
#\page
|
||||
#\return
|
||||
#\space
|
||||
(display "\"")
|
||||
(display "\\")
|
||||
(display "\\\"\"\\")
|
||||
(display 'foo)(newline)
|
||||
(display '(foo))(newline)
|
||||
(display '('foo))(newline)
|
||||
|
|
Loading…
Reference in a new issue