mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 22:10:21 +02:00
read: Accept "\|" in string literals.
* libguile/read.c (scm_read_string): Accept "\|" in string literals. * doc/ref/api-data.texi (String Syntax): Add "\|" to the list of supported backslash escapes. * test-suite/tests/reader.test ("reading"): Add test.
This commit is contained in:
parent
7a329029cf
commit
6579c3308d
3 changed files with 12 additions and 3 deletions
|
@ -2938,9 +2938,10 @@ The read syntax for strings is an arbitrarily long sequence of
|
|||
characters enclosed in double quotes (@nicode{"}).
|
||||
|
||||
Backslash is an escape character and can be used to insert the following
|
||||
special characters. @nicode{\"} and @nicode{\\} are R5RS standard, the
|
||||
next seven are R6RS standard --- notice they follow C syntax --- and the
|
||||
remaining four are Guile extensions.
|
||||
special characters. @nicode{\"} and @nicode{\\} are R5RS standard,
|
||||
@nicode{\|} is R7RS standard, the next seven are R6RS standard ---
|
||||
notice they follow C syntax --- and the remaining four are Guile
|
||||
extensions.
|
||||
|
||||
@table @asis
|
||||
@item @nicode{\\}
|
||||
|
@ -2950,6 +2951,9 @@ Backslash character.
|
|||
Double quote character (an unescaped @nicode{"} is otherwise the end
|
||||
of the string).
|
||||
|
||||
@item @nicode{\|}
|
||||
Vertical bar character.
|
||||
|
||||
@item @nicode{\a}
|
||||
Bell character (ASCII 7).
|
||||
|
||||
|
|
|
@ -624,6 +624,7 @@ scm_read_string (int chr, SCM port, scm_t_read_opts *opts)
|
|||
case EOF:
|
||||
goto str_eof;
|
||||
case '"':
|
||||
case '|':
|
||||
case '\\':
|
||||
break;
|
||||
case '\n':
|
||||
|
|
|
@ -74,6 +74,10 @@
|
|||
(not (equal? (imag-part (read-string "-nan.0-1i"))
|
||||
(imag-part (read-string "-nan.0+1i")))))
|
||||
|
||||
(pass-if-equal "'\|' in string literals"
|
||||
"a|b"
|
||||
(read-string "\"a\\|b\""))
|
||||
|
||||
(pass-if-equal "#true"
|
||||
'(a #t b)
|
||||
(read-string "(a #true b)"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue