From 338fa0de2bb5c943775278eef608ce21723cde19 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 17 May 2012 20:39:21 -0700 Subject: * match.c (v_collect): Implemented semantics for repeat symbol. (dir_tables_init): Register dispatch for repeat to v_collect function. * parser.y (collect_repeat): New nonterminal symbol. (clause): Removed repeat_clause error case because that now clashes with the syntax in collect_clause. (collect_clause): Repeat syntax implemented, with help of collect_repeat. (out_clause): Error case for collect_clause removed due to syntactic clash. * txr.1: Added mention of @(collect :vars nil) and documented @(repeat) as the shorthand. --- match.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'match.c') diff --git a/match.c b/match.c index b85488e7..9964bd83 100644 --- a/match.c +++ b/match.c @@ -2617,6 +2617,7 @@ static val v_gather(match_files_ctx *c) static val v_collect(match_files_ctx *c) { spec_bind (specline, first_spec, c->spec); + val op_sym = first(first_spec); val coll_spec = second(first_spec); val until_last_spec = third(first_spec); val args = fourth(first_spec); @@ -2644,7 +2645,15 @@ static val v_collect(match_files_ctx *c) val iter; if (gap && (max || min)) - sem_error(specline, lit("collect: cannot mix :gap with :mingap or :maxgap"), nao); + sem_error(specline, lit("~s: cannot mix :gap with :mingap or :maxgap"), + op_sym, nao); + + if (op_sym == repeat_s) { + if (have_vars) + sem_error(specline, lit("~s: collect takes :vars, repeat does not"), + op_sym, nao); + have_vars = t; + } vars = vars_to_bindings(specline, vars, c->bindings); @@ -3787,6 +3796,7 @@ static void dir_tables_init(void) sethash(v_directive_table, choose_s, cptr((mem_t *) v_parallel)); sethash(v_directive_table, gather_s, cptr((mem_t *) v_gather)); sethash(v_directive_table, collect_s, cptr((mem_t *) v_collect)); + sethash(v_directive_table, repeat_s, cptr((mem_t *) v_collect)); sethash(v_directive_table, flatten_s, cptr((mem_t *) v_flatten)); sethash(v_directive_table, forget_s, cptr((mem_t *) v_forget_local)); sethash(v_directive_table, local_s, cptr((mem_t *) v_forget_local)); -- cgit v1.2.3