From 8e8e14991164f2ddd33cac040a68b155847fa724 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 24 Feb 2014 02:04:40 -0800 Subject: Symbol macros. * eval.c (top_smb, defsymacro_s, symacrolet_s): New global variables. (lookup_symac, get_opt_param_syms, get_param_syms, op_defsymacro, expand_symacrolet, make_var_shadowing_env): New static functions. (expand_tree_cases, expand_catch_clause): Install shadowing environment so lexical bindings hide any symbol macrolets. (expand_place): Fix neglect to expand an atomic form, which breaks symbol macros used as places. (expand): Expand symbol macros, expand symacrolet binding forms. Make sure symbol macros are shadowed in the lexical binding constructs. Take advantage of return value of rlcp_tree in a few places. (macro_form_p): Support for symbol macros; bugfix: not handling default argument. (macroexpand_1): Streamlined, and support added for symbol macros. (eval_init): Protect top_smb from gc. Create new hash, stored in top_smb. Initialize defsymacro_s and symacrolet_s. Register op_defsymacro. * parser.y (rlcp_tree): Return the to form instead of useless t and nil. * txr.1: Documented. --- parser.y | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'parser.y') diff --git a/parser.y b/parser.y index 819630b9..3ea01e43 100644 --- a/parser.y +++ b/parser.y @@ -1153,15 +1153,14 @@ val rlset(val form, val info) val rlcp_tree(val to, val from) { - if (atom(to)) { - return nil; - } else { + val ret = to; + if (consp(to)) { if (!source_loc(to)) rlcp(to, from); for (; consp(to); to = cdr(to)) rlcp_tree(car(to), from); - return t; } + return ret; } static wchar_t char_from_name(const wchar_t *name) -- cgit v1.2.3