mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-18 01:30:27 +02:00
read: Support R7RS |...| symbol notation.
* libguile/private-options.h (SCM_R7RS_SYMBOLS_P): New macro. (SCM_N_READ_OPTIONS): Increment. * libguile/read.c (scm_read_opts): Add entry for 'r7rs-symbols'. (t_read_opts): Add field for 'r7rs_symbols_p'. (scm_read_string_like_syntax): New function based on earlier 'scm_read_string' that handles either string literals or R7RS quoted symbols (delimited by vertical bars), depending on the value of 'chr'. (scm_read_string): Reimplement based on 'scm_read_string_like_syntax'. (scm_read_r7rs_symbol): New static function. * doc/ref/api-data.texi (Symbol Read Syntax): Briefly describe the R7RS symbol syntax, mention the 'r7rs-symbols' read option, and give some examples. * doc/ref/api-evaluation.texi (Scheme Read): Mention the 'r7rs-symbols' read option. * test-suite/tests/reader.test ("reading"): Add test.
This commit is contained in:
parent
b306fae0ab
commit
dc59631d30
5 changed files with 58 additions and 10 deletions
|
@ -238,6 +238,11 @@
|
|||
(with-read-options '(case-insensitive)
|
||||
(lambda ()
|
||||
(read-string "GuiLe")))))
|
||||
(pass-if-equal "r7rs-symbols"
|
||||
(list 'a (string->symbol "Hello, this is | a \"test\"") 'b)
|
||||
(with-read-options '(r7rs-symbols)
|
||||
(lambda ()
|
||||
(read-string "(a |H\\x65;llo, this is \\| a \"test\"| b)"))))
|
||||
(pass-if "prefix keywords"
|
||||
(eq? #:keyword
|
||||
(with-read-options '(keywords prefix case-insensitive)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue