mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-12 06:41:13 +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{"}).
|
characters enclosed in double quotes (@nicode{"}).
|
||||||
|
|
||||||
Backslash is an escape character and can be used to insert the following
|
Backslash is an escape character and can be used to insert the following
|
||||||
special characters. @nicode{\"} and @nicode{\\} are R5RS standard, the
|
special characters. @nicode{\"} and @nicode{\\} are R5RS standard,
|
||||||
next seven are R6RS standard --- notice they follow C syntax --- and the
|
@nicode{\|} is R7RS standard, the next seven are R6RS standard ---
|
||||||
remaining four are Guile extensions.
|
notice they follow C syntax --- and the remaining four are Guile
|
||||||
|
extensions.
|
||||||
|
|
||||||
@table @asis
|
@table @asis
|
||||||
@item @nicode{\\}
|
@item @nicode{\\}
|
||||||
|
@ -2950,6 +2951,9 @@ Backslash character.
|
||||||
Double quote character (an unescaped @nicode{"} is otherwise the end
|
Double quote character (an unescaped @nicode{"} is otherwise the end
|
||||||
of the string).
|
of the string).
|
||||||
|
|
||||||
|
@item @nicode{\|}
|
||||||
|
Vertical bar character.
|
||||||
|
|
||||||
@item @nicode{\a}
|
@item @nicode{\a}
|
||||||
Bell character (ASCII 7).
|
Bell character (ASCII 7).
|
||||||
|
|
||||||
|
|
|
@ -624,6 +624,7 @@ scm_read_string (int chr, SCM port, scm_t_read_opts *opts)
|
||||||
case EOF:
|
case EOF:
|
||||||
goto str_eof;
|
goto str_eof;
|
||||||
case '"':
|
case '"':
|
||||||
|
case '|':
|
||||||
case '\\':
|
case '\\':
|
||||||
break;
|
break;
|
||||||
case '\n':
|
case '\n':
|
||||||
|
|
|
@ -74,6 +74,10 @@
|
||||||
(not (equal? (imag-part (read-string "-nan.0-1i"))
|
(not (equal? (imag-part (read-string "-nan.0-1i"))
|
||||||
(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"
|
(pass-if-equal "#true"
|
||||||
'(a #t b)
|
'(a #t b)
|
||||||
(read-string "(a #true b)"))
|
(read-string "(a #true b)"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue