summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-07-30 07:29:44 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-07-30 07:29:44 -0700
commitff4d78c938128cd0572f6469425005d9019a7f38 (patch)
tree877b69ca541b02dd8dccd4de14f04dd7ef21db7a
parent550c1292e61f52cd1bdcf135520706bbfd6a3464 (diff)
downloadtxr-ff4d78c938128cd0572f6469425005d9019a7f38.tar.gz
txr-ff4d78c938128cd0572f6469425005d9019a7f38.tar.bz2
txr-ff4d78c938128cd0572f6469425005d9019a7f38.zip
* parser.l: Allow unquotes and splices in QSPECIAL and BRACED states.
* parser.y (quasi_item): Support splices as items. * genvim.txr: Syntax highlighting support for unquotes in quasiliterals. * txr.vim: Updated.
-rw-r--r--ChangeLog11
-rw-r--r--genvim.txr10
-rw-r--r--parser.l7
-rw-r--r--parser.y2
-rw-r--r--txr.112
-rw-r--r--txr.vim10
6 files changed, 45 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 073faff1..c5d9a706 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2014-07-30 Kaz Kylheku <kaz@kylheku.com>
+
+ * parser.l: Allow unquotes and splices in QSPECIAL and BRACED states.
+
+ * parser.y (quasi_item): Support splices as items.
+
+ * genvim.txr: Syntax highlighting support for unquotes in
+ quasiliterals.
+
+ * txr.vim: Updated.
+
2014-07-29 Kaz Kylheku <kaz@kylheku.com>
* eval.c (eval_init): Register uniq function.
diff --git a/genvim.txr b/genvim.txr
index a2b79c49..d41b2466 100644
--- a/genvim.txr
+++ b/genvim.txr
@@ -80,6 +80,7 @@ syn match txr_char "@@[ \t]*\\x[0-9A-Fa-f]\+"
syn match txr_char "@@[ \t]*\\[0-9]\+"
syn match txr_variable "@@[ \t]*[*]\?[ \t]*[A-Za-z_][A-Za-z0-9_]*"
syn match txr_metanum "@@[0-9]\+"
+syn match txr_splicevar "@@[ \t,*]*[A-Za-z_][A-Za-z0-9_]*"
syn match txr_regdir "@@[ \t]*/\(\\/\|[^/]\|\\\n\)*/"
syn match txr_chr "#\\x[A-Fa-f0-9]\+" contained
@@ -92,7 +93,6 @@ syn match txr_dot "\." contained
syn match txr_num "#x[+\-]\?[0-9A-Fa-f]\+" contained
syn match txr_num "#o[+\-]\?[0-7]\+" contained
syn match txr_num "#b[+\-]\?[0-1]\+" contained
-syn match txr_ident "[:@@][A-Za-z0-9!#$%&*+\-<=>?\\^_~]\+" contained
syn match txr_ident "[A-Za-z0-9!$%&*+\-<=>?\\_~]*[A-Za-z!$#%&*+\-<=>?\\^_~][A-Za-z0-9!$#%&*+\-<=>?\\^_~]*" contained
syn match txl_ident "[:@@][A-Za-z0-9!$%&*+\-<=>?\\\^_~/]\+" contained
syn match txl_ident "[A-Za-z0-9!$%&*+\-<=>?\\_~/]*[A-Za-z!$#%&*+\-<=>?\\^_~/][A-Za-z0-9!$#%&*+\-<=>?\\^_~/]*" contained
@@ -101,6 +101,7 @@ syn match txr_badnum "[+\-]\?[0-9]*[.][0-9]\+\([eE][+\-]\?[0-9]\+\)\?[A-Za-z!$#%
syn match txr_num "[+\-]\?[0-9]*[.][0-9]\+\([eE][+\-]\?[0-9]\+\)\?\([^A-Za-z0-9!$#%&*+\-<=>?\\^_~/]\|\n\)"me=e-1 contained
syn match txr_num "[+\-]\?[0-9]\+\([eE][+\-]\?[0-9]\+\)\([^A-Za-z0-9!$#%&*+\-<=>?\\^_~/]\|\n\)"me=e-1 contained
syn match txl_ident ":" contained
+syn match txl_splice "[ \t,]\|,[*]" contained
syn match txr_unquote "," contained
syn match txr_splice ",\*" contained
@@ -109,14 +110,14 @@ syn match txr_quote "\^" contained
syn match txr_dotdot "\.\." contained
syn match txr_metaat "@@" contained
-syn region txr_bracevar matchgroup=Delimiter start="@@[ \t]*[*]\?{" matchgroup=Delimiter end="}" contains=txr_num,txr_ident,txr_string,txr_list,txr_bracket,txr_mlist,txr_mbracket,txr_regex,txr_quasilit,txr_chr,txr_nested_error
+syn region txr_bracevar matchgroup=Delimiter start="@@[ \t]*[*]\?{" matchgroup=Delimiter end="}" contains=txr_num,txr_ident,txr_string,txr_list,txr_bracket,txr_mlist,txr_mbracket,txr_regex,txr_quasilit,txr_chr,txl_splice,txr_nested_error
syn region txr_directive matchgroup=Delimiter start="@@[ \t]*(" matchgroup=Delimiter end=")" contains=txr_keyword,txr_string,txr_list,txr_bracket,txr_mlist,txr_mbracket,txr_quasilit,txr_num,txr_badnum,txl_ident,txl_regex,txr_string,txr_chr,txr_quote,txr_unquote,txr_splice,txr_dot,txr_dotdot,txr_metaat,txr_ncomment,txr_nested_error
syn region txr_list contained matchgroup=Delimiter start="#\?H\?(" matchgroup=Delimiter end=")" contains=txl_keyword,txr_string,txl_regex,txr_num,txr_badnum,txl_ident,txr_metanum,txr_list,txr_bracket,txr_mlist,txr_mbracket,txr_quasilit,txr_chr,txr_quote,txr_unquote,txr_splice,txr_dot,txr_dotdot,txr_metaat,txr_ncomment,txr_nested_error
syn region txr_bracket contained matchgroup=Delimiter start="\[" matchgroup=Delimiter end="\]" contains=txl_keyword,txr_string,txl_regex,txr_num,txr_badnum,txl_ident,txr_metanum,txr_list,txr_bracket,txr_mlist,txr_mbracket,txr_quasilit,txr_chr,txr_quote,txr_unquote,txr_splice,txr_dot,txr_dotdot,txr_metaat,txr_ncomment,txr_nested_error
syn region txr_mlist contained matchgroup=Delimiter start="@@[ \t]*(" matchgroup=Delimiter end=")" contains=txl_keyword,txr_string,txl_regex,txr_num,txr_badnum,txl_ident,txr_metanum,txr_list,txr_bracket,txr_mlist,txr_mbracket,txr_quasilit,txr_chr,txr_quote,txr_unquote,txr_splice,txr_dot,txr_dotdot,txr_metaat,txr_ncomment,txr_nested_error
syn region txr_mbracket matchgroup=Delimiter start="@@[ \t]*\[" matchgroup=Delimiter end="\]" contains=txl_keyword,txr_string,txl_regex,txr_num,txr_badnum,txl_ident,txr_metanum,txr_list,txr_bracket,txr_mlist,txr_mbracket,txr_quasilit,txr_chr,txr_quote,txr_unquote,txr_splice,txr_dot,txr_dotdot,txr_metaat,txr_ncomment,txr_nested_error
syn region txr_string contained start=+#\?\*\?"+ skip=+\\\\\|\\"\|\\\n+ end=+"\|\n+
-syn region txr_quasilit contained start=+#\?\*\?`+ skip=+\\\\\|\\`\|\\\n+ end=+`\|\n+ contains=txr_variable,txr_metanum,txr_bracevar,txr_mlist,txr_mbracket
+syn region txr_quasilit contained start=+#\?\*\?`+ skip=+\\\\\|\\`\|\\\n+ end=+`\|\n+ contains=txr_splicevar,txr_metanum,txr_bracevar,txr_mlist,txr_mbracket
syn region txr_regex contained start="/" skip="\\\\\|\\/\|\\\n" end="/\|\n"
syn region txl_regex contained start="#/" skip="\\\\\|\\/\|\\\n" end="/\|\n"
@@ -137,6 +138,7 @@ hi def link txr_regex String
hi def link txl_regex String
hi def link txr_regdir String
hi def link txr_variable Identifier
+hi def link txr_splicevar Identifier
hi def link txr_metanum Identifier
hi def link txr_ident Identifier
hi def link txl_ident Identifier
@@ -148,6 +150,8 @@ hi def link txr_splice Special
hi def link txr_dot Special
hi def link txr_dotdot Special
hi def link txr_metaat Special
+hi def link txr_munqspl Special
+hi def link txl_splice Special
hi def link txr_error Error
hi def link txr_nested_error Error
diff --git a/parser.l b/parser.l
index be3365e2..4edb90ee 100644
--- a/parser.l
+++ b/parser.l
@@ -547,7 +547,7 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
return yytext[0];
}
-<NESTED>,[*] {
+<NESTED,QSPECIAL,BRACED>,[*] {
yylval.chr = '*';
return SPLICE;
}
@@ -557,6 +557,11 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
return yytext[0];
}
+<QSPECIAL,BRACED>[,'] {
+ yylval.chr = yytext[0];
+ return yytext[0];
+}
+
<BRACED>[}] {
yy_pop_state();
if (yy_top_state() == INITIAL
diff --git a/parser.y b/parser.y
index 68f54fc0..d59657c5 100644
--- a/parser.y
+++ b/parser.y
@@ -950,6 +950,8 @@ quasi_item : litchars { $$ = lit_char_helper($1); }
| METANUM { $$ = cons(var_s, cons($1, nil));
rl($$, num(lineno)); }
| list { $$ = rlcp(cons(expr_s, $1), $1); }
+ | ',' n_expr { $$ = rlcp(cons(expr_s, list(sys_unquote_s, $2, nao)), $2); }
+ | SPLICE n_expr { $$ = rlcp(cons(expr_s, list(sys_splice_s, $2, nao)), $2); }
;
litchars : LITCHAR { $$ = rl(cons(chr($1), nil), num(lineno)); }
diff --git a/txr.1 b/txr.1
index 3f3879e8..53826f82 100644
--- a/txr.1
+++ b/txr.1
@@ -5352,6 +5352,18 @@ This is correct:
(hash-contents '((a 1) (b 2))))
^#H(,hash-args ,*hash-contents))
+.SS Quasiquoting combined with Quasiliterals
+
+When a quasiliteral is embedded in a quasiquote, it is possible to use
+splicing to insert material into the quasiliteral.
+
+.TP
+Example:
+
+ (eval (let ((a 3)) ^`abc @,a @{,a} @{(list 1 2 ,a)}`))
+
+ -> "abc 3 3 1 2 3"
+
.SS Vectors
.IP "#(...)"
diff --git a/txr.vim b/txr.vim
index 6f0a7d16..03440c0f 100644
--- a/txr.vim
+++ b/txr.vim
@@ -198,6 +198,7 @@ syn match txr_char "@[ \t]*\\x[0-9A-Fa-f]\+"
syn match txr_char "@[ \t]*\\[0-9]\+"
syn match txr_variable "@[ \t]*[*]\?[ \t]*[A-Za-z_][A-Za-z0-9_]*"
syn match txr_metanum "@[0-9]\+"
+syn match txr_splicevar "@[ \t,*]*[A-Za-z_][A-Za-z0-9_]*"
syn match txr_regdir "@[ \t]*/\(\\/\|[^/]\|\\\n\)*/"
syn match txr_chr "#\\x[A-Fa-f0-9]\+" contained
@@ -210,7 +211,6 @@ syn match txr_dot "\." contained
syn match txr_num "#x[+\-]\?[0-9A-Fa-f]\+" contained
syn match txr_num "#o[+\-]\?[0-7]\+" contained
syn match txr_num "#b[+\-]\?[0-1]\+" contained
-syn match txr_ident "[:@][A-Za-z0-9!#$%&*+\-<=>?\\^_~]\+" contained
syn match txr_ident "[A-Za-z0-9!$%&*+\-<=>?\\_~]*[A-Za-z!$#%&*+\-<=>?\\^_~][A-Za-z0-9!$#%&*+\-<=>?\\^_~]*" contained
syn match txl_ident "[:@][A-Za-z0-9!$%&*+\-<=>?\\\^_~/]\+" contained
syn match txl_ident "[A-Za-z0-9!$%&*+\-<=>?\\_~/]*[A-Za-z!$#%&*+\-<=>?\\^_~/][A-Za-z0-9!$#%&*+\-<=>?\\^_~/]*" contained
@@ -219,6 +219,7 @@ syn match txr_badnum "[+\-]\?[0-9]*[.][0-9]\+\([eE][+\-]\?[0-9]\+\)\?[A-Za-z!$#%
syn match txr_num "[+\-]\?[0-9]*[.][0-9]\+\([eE][+\-]\?[0-9]\+\)\?\([^A-Za-z0-9!$#%&*+\-<=>?\\^_~/]\|\n\)"me=e-1 contained
syn match txr_num "[+\-]\?[0-9]\+\([eE][+\-]\?[0-9]\+\)\([^A-Za-z0-9!$#%&*+\-<=>?\\^_~/]\|\n\)"me=e-1 contained
syn match txl_ident ":" contained
+syn match txl_splice "[ \t,]\|,[*]" contained
syn match txr_unquote "," contained
syn match txr_splice ",\*" contained
@@ -227,14 +228,14 @@ syn match txr_quote "\^" contained
syn match txr_dotdot "\.\." contained
syn match txr_metaat "@" contained
-syn region txr_bracevar matchgroup=Delimiter start="@[ \t]*[*]\?{" matchgroup=Delimiter end="}" contains=txr_num,txr_ident,txr_string,txr_list,txr_bracket,txr_mlist,txr_mbracket,txr_regex,txr_quasilit,txr_chr,txr_nested_error
+syn region txr_bracevar matchgroup=Delimiter start="@[ \t]*[*]\?{" matchgroup=Delimiter end="}" contains=txr_num,txr_ident,txr_string,txr_list,txr_bracket,txr_mlist,txr_mbracket,txr_regex,txr_quasilit,txr_chr,txl_splice,txr_nested_error
syn region txr_directive matchgroup=Delimiter start="@[ \t]*(" matchgroup=Delimiter end=")" contains=txr_keyword,txr_string,txr_list,txr_bracket,txr_mlist,txr_mbracket,txr_quasilit,txr_num,txr_badnum,txl_ident,txl_regex,txr_string,txr_chr,txr_quote,txr_unquote,txr_splice,txr_dot,txr_dotdot,txr_metaat,txr_ncomment,txr_nested_error
syn region txr_list contained matchgroup=Delimiter start="#\?H\?(" matchgroup=Delimiter end=")" contains=txl_keyword,txr_string,txl_regex,txr_num,txr_badnum,txl_ident,txr_metanum,txr_list,txr_bracket,txr_mlist,txr_mbracket,txr_quasilit,txr_chr,txr_quote,txr_unquote,txr_splice,txr_dot,txr_dotdot,txr_metaat,txr_ncomment,txr_nested_error
syn region txr_bracket contained matchgroup=Delimiter start="\[" matchgroup=Delimiter end="\]" contains=txl_keyword,txr_string,txl_regex,txr_num,txr_badnum,txl_ident,txr_metanum,txr_list,txr_bracket,txr_mlist,txr_mbracket,txr_quasilit,txr_chr,txr_quote,txr_unquote,txr_splice,txr_dot,txr_dotdot,txr_metaat,txr_ncomment,txr_nested_error
syn region txr_mlist contained matchgroup=Delimiter start="@[ \t]*(" matchgroup=Delimiter end=")" contains=txl_keyword,txr_string,txl_regex,txr_num,txr_badnum,txl_ident,txr_metanum,txr_list,txr_bracket,txr_mlist,txr_mbracket,txr_quasilit,txr_chr,txr_quote,txr_unquote,txr_splice,txr_dot,txr_dotdot,txr_metaat,txr_ncomment,txr_nested_error
syn region txr_mbracket matchgroup=Delimiter start="@[ \t]*\[" matchgroup=Delimiter end="\]" contains=txl_keyword,txr_string,txl_regex,txr_num,txr_badnum,txl_ident,txr_metanum,txr_list,txr_bracket,txr_mlist,txr_mbracket,txr_quasilit,txr_chr,txr_quote,txr_unquote,txr_splice,txr_dot,txr_dotdot,txr_metaat,txr_ncomment,txr_nested_error
syn region txr_string contained start=+#\?\*\?"+ skip=+\\\\\|\\"\|\\\n+ end=+"\|\n+
-syn region txr_quasilit contained start=+#\?\*\?`+ skip=+\\\\\|\\`\|\\\n+ end=+`\|\n+ contains=txr_variable,txr_metanum,txr_bracevar,txr_mlist,txr_mbracket
+syn region txr_quasilit contained start=+#\?\*\?`+ skip=+\\\\\|\\`\|\\\n+ end=+`\|\n+ contains=txr_splicevar,txr_metanum,txr_bracevar,txr_mlist,txr_mbracket
syn region txr_regex contained start="/" skip="\\\\\|\\/\|\\\n" end="/\|\n"
syn region txl_regex contained start="#/" skip="\\\\\|\\/\|\\\n" end="/\|\n"
@@ -255,6 +256,7 @@ hi def link txr_regex String
hi def link txl_regex String
hi def link txr_regdir String
hi def link txr_variable Identifier
+hi def link txr_splicevar Identifier
hi def link txr_metanum Identifier
hi def link txr_ident Identifier
hi def link txl_ident Identifier
@@ -266,6 +268,8 @@ hi def link txr_splice Special
hi def link txr_dot Special
hi def link txr_dotdot Special
hi def link txr_metaat Special
+hi def link txr_munqspl Special
+hi def link txl_splice Special
hi def link txr_error Error
hi def link txr_nested_error Error