mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 03:30:27 +02:00
add read syntax for #nil
* libguile/evalext.c (scm_self_evaluating_p): #nil is self-evaluating. * libguile/read.c (scm_read_nil, scm_read_sharp): Add read syntax for #nil.
This commit is contained in:
parent
c1b7c940ec
commit
7c4aad9cc7
2 changed files with 17 additions and 1 deletions
|
@ -71,7 +71,7 @@ SCM_DEFINE (scm_self_evaluating_p, "self-evaluating?", 1, 0, 0,
|
|||
return SCM_BOOL_T;
|
||||
case scm_tc3_imm24:
|
||||
/* characters, booleans, other immediates */
|
||||
return scm_from_bool (!scm_is_null (obj));
|
||||
return scm_from_bool (!scm_is_null_and_not_nil (obj));
|
||||
case scm_tc3_cons:
|
||||
switch (SCM_TYP7 (obj))
|
||||
{
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
SCM_GLOBAL_SYMBOL (scm_sym_dot, ".");
|
||||
SCM_SYMBOL (scm_keyword_prefix, "prefix");
|
||||
SCM_SYMBOL (scm_keyword_postfix, "postfix");
|
||||
SCM_SYMBOL (sym_nil, "nil");
|
||||
|
||||
scm_t_option scm_read_opts[] = {
|
||||
{ SCM_OPTION_BOOLEAN, "copy", 0,
|
||||
|
@ -846,6 +847,19 @@ scm_read_syntax (int chr, SCM port)
|
|||
return p;
|
||||
}
|
||||
|
||||
static inline SCM
|
||||
scm_read_nil (int chr, SCM port)
|
||||
{
|
||||
SCM id = scm_read_mixed_case_symbol (chr, port);
|
||||
|
||||
if (!scm_is_eq (id, sym_nil))
|
||||
scm_i_input_error ("scm_read_nil", port,
|
||||
"unexpected input while reading #nil: ~a",
|
||||
scm_list_1 (id));
|
||||
|
||||
return SCM_ELISP_NIL;
|
||||
}
|
||||
|
||||
static inline SCM
|
||||
scm_read_semicolon_comment (int chr, SCM port)
|
||||
{
|
||||
|
@ -1316,6 +1330,8 @@ scm_read_sharp (scm_t_wchar chr, SCM port)
|
|||
case '\'':
|
||||
case ',':
|
||||
return (scm_read_syntax (chr, port));
|
||||
case 'n':
|
||||
return (scm_read_nil (chr, port));
|
||||
default:
|
||||
result = scm_read_sharp_extension (chr, port);
|
||||
if (scm_is_eq (result, SCM_UNSPECIFIED))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue