diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-12-02 15:39:43 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-12-02 15:39:43 -0800 |
commit | 63211dfd66f3cbd4159885018257022b20a4c975 (patch) | |
tree | 3f38e75739cd8e2f0cdb9e33c903968805580e95 /parser.y | |
parent | 6768cdf7a46856355ccfafc57f147fac14eba06b (diff) | |
download | txr-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.y | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -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")); } ; |