diff options
author | Andy Wingo <wingo@pobox.com> | 2010-04-09 14:15:16 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-04-09 14:15:16 +0200 |
commit | 7c4aad9cc7143ea7c1a7ce3c143ca0581cace5b5 (patch) | |
tree | acd4d0ae57baa19482735f12581ad15e31a747c7 | |
parent | c1b7c940eca528d8875bc9bd00fba1a885b4dddb (diff) | |
download | guile-7c4aad9cc7143ea7c1a7ce3c143ca0581cace5b5.tar.gz |
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.
-rw-r--r-- | libguile/evalext.c | 2 | ||||
-rw-r--r-- | libguile/read.c | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/libguile/evalext.c b/libguile/evalext.c index be775a8e1..b397cbd05 100644 --- a/libguile/evalext.c +++ b/libguile/evalext.c @@ -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)) { diff --git a/libguile/read.c b/libguile/read.c index ee8786133..c54fbb62d 100644 --- a/libguile/read.c +++ b/libguile/read.c @@ -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, @@ -847,6 +848,19 @@ scm_read_syntax (int chr, SCM port) } 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) { int c; @@ -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)) |