diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-11-17 21:12:08 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-11-17 21:12:08 -0800 |
commit | df70e45dae4adccca01441e0911d2f5e114e8e7f (patch) | |
tree | ab71125a6493e59b609eb5bc80bae30690d1baa9 /parser.y | |
parent | 68ca87bc780e25dea1418019161d99727225d1ce (diff) | |
download | txr-df70e45dae4adccca01441e0911d2f5e114e8e7f.tar.gz txr-df70e45dae4adccca01441e0911d2f5e114e8e7f.tar.bz2 txr-df70e45dae4adccca01441e0911d2f5e114e8e7f.zip |
Adding quote and unquote read syntax to list forms, resembling
Lisp. The difference is that splice is spelled ,* because @
already means something, and that there is only one quote operator.
None of this does anything; it is only syntax.
* lib.c (quote_s, qquote_s, unquote_s, splice_s): New variables.
(obj_init): New variables initialized.
* lib.h (quote_s, qquote_s, unquote_s, splice_s): Declared.
* parser.l: Added recognition rules.
* parser.y (SPLICE): New symbolic token.
(list): Added new syntax for quote and splicing.
Diffstat (limited to 'parser.y')
-rw-r--r-- | parser.y | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -71,7 +71,7 @@ static val parsed_spec; %token <num> NUMBER %token <chr> REGCHAR LITCHAR -%token <chr> METAPAR +%token <chr> METAPAR SPLICE %type <val> spec clauses clauses_opt clause %type <val> all_clause some_clause none_clause maybe_clause @@ -96,7 +96,7 @@ static val parsed_spec; %right OUTPUT REPEAT REP FIRST LAST EMPTY DEFINE %right SPACE TEXT NUMBER %nonassoc '[' ']' '(' ')' -%left '-' +%left '-' ',' '\'' SPLICE %left '|' '/' %left '&' %right '~' '*' '?' '+' '%' @@ -587,6 +587,9 @@ var_op : '*' { $$ = list(t, nao); } list : '(' exprs ')' { $$ = rl($2, num($1)); } | '(' ')' { $$ = nil; } + | ',' expr { $$ = rlcp(list(unquote_s, $2, nao), $2); } + | '\'' expr { $$ = rlcp(list(qquote_s, $2, nao), $2); } + | SPLICE expr { $$ = rlcp(list(splice_s, $2, nao), $2); } | '(' error { $$ = nil; yybadtoken(yychar, lit("list expression")); } ; |