diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-05-17 20:39:21 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-05-17 20:39:21 -0700 |
commit | 338fa0de2bb5c943775278eef608ce21723cde19 (patch) | |
tree | 8ee038310c988cdb43f4d9c7543c351c1fe1d24f /match.c | |
parent | f1d3884b7492e8c08f964b893153d6b2b5b44361 (diff) | |
download | txr-338fa0de2bb5c943775278eef608ce21723cde19.tar.gz txr-338fa0de2bb5c943775278eef608ce21723cde19.tar.bz2 txr-338fa0de2bb5c943775278eef608ce21723cde19.zip |
* 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.
Diffstat (limited to 'match.c')
-rw-r--r-- | match.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -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)); |