summaryrefslogtreecommitdiffstats
path: root/parser.l
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-01-25 09:59:40 -0800
committerKaz Kylheku <kaz@kylheku.com>2012-01-25 09:59:40 -0800
commit11173ced6d65339869fe74fbc9c4452a75e3fe26 (patch)
tree6c7e21fa0f7ebab6d5b4af9dc960fd96660682be /parser.l
parent8b4578f295cc022e8bf0bb62d1a8cf8673636f27 (diff)
downloadtxr-11173ced6d65339869fe74fbc9c4452a75e3fe26.tar.gz
txr-11173ced6d65339869fe74fbc9c4452a75e3fe26.tar.bz2
txr-11173ced6d65339869fe74fbc9c4452a75e3fe26.zip
* eval.c (dwim_s): New symbol variable.
(dwim_loc, op_dwim): New static functions. (op_modplace): Support assignment to dwim forms with the help of dwim_loc. (expand_place): Handle dwim places. (eval_init): Initialize dwim_s. Register dwim operator in op_table. * eval.h (dwim_s): Declared. * lib.c (chr_str, chr_str_set): Allow negative indices to index backwards from end of string. (vecref, vecref_l): Allow negative indices to index from rear of array. (obj_print, obj_pprint): Render (dwim ...) forms as [...]. * parser.l: Peoduce new METABKT token type for @[, and '[', ']' tokens. * parser.y (METABKT): New token. %type declaration for '['. (list): Support square-bracket style of list, translated into dwim form. (meta_expr): Support @[...] variant. (yybadtoken): Handle METABKT in switch. * txr.1: Documented [...] syntax and dwim operator. * txr.vim: Updated.
Diffstat (limited to 'parser.l')
-rw-r--r--parser.l10
1 files changed, 5 insertions, 5 deletions
diff --git a/parser.l b/parser.l
index 59e7767e..7875f81b 100644
--- a/parser.l
+++ b/parser.l
@@ -358,12 +358,12 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
return FINALLY;
}
-<NESTED>@\( |
-<SPECIAL,NESTED>\{|\( {
+<NESTED>@[\(\[] |
+<SPECIAL,NESTED>[{(\[] {
yy_push_state(NESTED);
if (yytext[0] == '@') {
- yylval.chr = '(';
- return METAPAR;
+ yylval.chr = yytext[1];
+ return yytext[1] == '(' ? METAPAR : METABKT;
}
yylval.lineno = lineno;
return yytext[0];
@@ -379,7 +379,7 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
return yytext[0];
}
-<SPECIAL,NESTED>\}|\) {
+<SPECIAL,NESTED>[})\]] {
yy_pop_state();
if (yy_top_state() == INITIAL
|| yy_top_state() == QSILIT)