From 4e1170250c22dbc1938e60538aef9f800cf8af92 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku <kaz@kylheku.com> Date: Wed, 14 Mar 2012 14:38:51 -0700 Subject: Support quasiquoting over vectors also, and a bugfix for hash quasiquoting. We cannot use the same symbol for the literal form from the parser, and for the expanded form, because this creates a confusion when there are multiple nestings of quasiquote expansion. * eval.c (vector_lit_s, vector_list_s, hash_lit_s): New symbol variables. (hash_construct_s): Relocated here from hash.c. (expand_qquote): Part of bugfix: look for hash_lit_s instead of has_construct_s. Translate to a hash_construct_s form which is no longer recognizes as a hash literal. Implementing recognition of a quasiquote vector literal, handled similarly. (eval_init): Initialize vector_lit_s, vector_list_s, hash_list_s and hash_lit_s. Use vector_list_s when registering vector_list function. * eval.h (vector_lit_s, vector_list_s, hash_lit_s, hash_constuct_s): Declared. * hash.c (hash_construct_s): Variable removed and relocated into eval.c. (hash_init): Initialization of hash_construct_s removed. * hash.h (hash_construct_s): Declaration removed. * parser.y: (vector): Action updated to generate a (vec-lit ...) form if the object contains unquotes, otherwise generate a vector object. (hash): Generate hash-lit form, not a hash-construct form. --- parser.y | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'parser.y') diff --git a/parser.y b/parser.y index a6827a9d..29e678d5 100644 --- a/parser.y +++ b/parser.y @@ -54,7 +54,6 @@ static val optimize_text(val text_form); static val unquotes_occur(val quoted_form); static val choose_quote(val quoted_form); static wchar_t char_from_name(wchar_t *name); -static val hash_from_notation(val notation); static val parsed_spec; @@ -669,11 +668,15 @@ o_var : IDENT { $$ = list(var_s, intern(string_own($1), nil), yybadtoken(yychar, lit("variable spec")); } ; -vector : '#' list { $$ = rlcp(vector_list($2), $2); } +vector : '#' list { if (unquotes_occur($2)) + $$ = rlcp(cons(vector_lit_s, + cons($2, nil)), $2); + else + $$ = rlcp(vector_list($2), $2); } ; hash : HASH_H list { if (unquotes_occur($2)) - $$ = rlcp(cons(hash_construct_s, $2), + $$ = rlcp(cons(hash_lit_s, $2), num($1)); else $$ = rlcp(hash_construct(first($2), -- cgit v1.2.3