From 687fd6ab7031aa573cbcd1b3ae624eb02530a25c Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 6 Nov 2011 17:23:55 -0800 Subject: Task #11581 * match.c (gather_s): New keyword variable. (v_gather): New function. (syms_init): gather_s initialized. (dir_tables_init): v_gather entered into table. * match.h (gather_s): Declared. * parser.l: GATHER token scanning added. * parser.y: GATHER token added. gather_clause nonterminal added. * txr.1: New directive documented. * txr.vim: gather keyword introduced. --- parser.y | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'parser.y') diff --git a/parser.y b/parser.y index 1437e982..115d9fbd 100644 --- a/parser.y +++ b/parser.y @@ -59,7 +59,7 @@ static val parsed_spec; } %token SPACE TEXT IDENT KEYWORD METAVAR -%token ALL SOME NONE MAYBE CASES CHOOSE +%token ALL SOME NONE MAYBE CASES CHOOSE GATHER %token AND OR END COLLECT %token UNTIL COLL OUTPUT REPEAT REP SINGLE FIRST LAST EMPTY DEFINE %token TRY CATCH FINALLY @@ -72,7 +72,7 @@ static val parsed_spec; %type spec clauses clauses_opt clause %type all_clause some_clause none_clause maybe_clause -%type cases_clause choose_clause collect_clause until_last +%type cases_clause choose_clause gather_clause collect_clause until_last %type clause_parts additional_parts %type output_clause define_clause try_clause catch_clauses_opt %type line elems_opt elems clause_parts_h additional_parts_h @@ -123,6 +123,7 @@ clause : all_clause { $$ = list(num(lineno - 1), $1, nao); } | cases_clause { $$ = list(num(lineno - 1), $1, nao); } | choose_clause { $$ = list(num(lineno - 1), $1, nao); } | collect_clause { $$ = list(num(lineno - 1), $1, nao); } + | gather_clause { $$ = list(num(lineno - 1), $1, nao); } | define_clause { $$ = list(num(lineno - 1), define_transform($1), nao); } | try_clause { $$ = list(num(lineno - 1), $1, nao); } @@ -184,6 +185,21 @@ choose_clause : CHOOSE exprs_opt ')' yyerror("empty choose clause"); } ; +gather_clause : GATHER exprs_opt ')' + newl clause_parts { $$ = list(gather_s, + append2(mapcar(curry_12_1(func_n2(cons), nil), + first($5)), rest($5)), + $2, nao); } + | GATHER exprs_opt ')' + newl error { $$ = nil; + yybadtoken(yychar, + lit("gather clause")); } + | GATHER exprs_opt ')' + newl END newl { $$ = nil; + yyerror("empty gather clause"); } + ; + + collect_clause : COLLECT exprs_opt ')' newl clauses END newl { $$ = list(collect_s, $5, nil, $2, -- cgit v1.2.3