summaryrefslogtreecommitdiffstats
path: root/parser.y
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-12-02 15:39:43 -0800
committerKaz Kylheku <kaz@kylheku.com>2011-12-02 15:39:43 -0800
commit63211dfd66f3cbd4159885018257022b20a4c975 (patch)
tree3f38e75739cd8e2f0cdb9e33c903968805580e95 /parser.y
parent6768cdf7a46856355ccfafc57f147fac14eba06b (diff)
downloadtxr-63211dfd66f3cbd4159885018257022b20a4c975.tar.gz
txr-63211dfd66f3cbd4159885018257022b20a4c975.tar.bz2
txr-63211dfd66f3cbd4159885018257022b20a4c975.zip
* parser.y (list): unquote and splice actions look inside the
argument form. If an unquote or splice are applied to a quoted form, its quote becomes a regular quote. This behavior is necessary to make ,',form work in nested quotes, otherwise the ' is a quasiquote which captures the comma in ,form, reducing ,',form to ,form. * txr.1: Documented this special behavior.
Diffstat (limited to 'parser.y')
-rw-r--r--parser.y10
1 files changed, 8 insertions, 2 deletions
diff --git a/parser.y b/parser.y
index affcd636..82fd9101 100644
--- a/parser.y
+++ b/parser.y
@@ -607,10 +607,16 @@ var_op : '*' { $$ = list(t, nao); }
list : '(' exprs ')' { $$ = rl($2, num($1)); }
| '(' ')' { $$ = nil; }
- | ',' expr { $$ = rlcp(list(unquote_s, $2, nao), $2); }
+ | ',' expr { val expr = $2;
+ if (consp(expr) && first(expr) == qquote_s)
+ expr = cons(quote_s, rest(expr));
+ $$ = rlcp(list(unquote_s, expr, nao), $2); }
| '\'' expr { $$ = rlcp(list(choose_quote($2),
$2, nao), $2); }
- | SPLICE expr { $$ = rlcp(list(splice_s, $2, nao), $2); }
+ | SPLICE expr { val expr = $2;
+ if (consp(expr) && first(expr) == qquote_s)
+ expr = cons(quote_s, rest(expr));
+ $$ = rlcp(list(splice_s, expr, nao), $2); }
| '(' error { $$ = nil;
yybadtoken(yychar, lit("list expression")); }
;