From ac08d22c2b916fbd88c938569e0cd6af488b7a67 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 30 Dec 2011 12:26:41 -0800 Subject: * match.c (counter_k): New keyword symbol variable. (do_output_line): Process new :counter argument of rep. (do_output): Ditto, for repeat. (syms_init): Intern new keyword symbol. * match.h (counter_k): Declared. * parser.l (REPEAT, REP): Lexical syntax changed to allow arguments. * parser.y (repeat_rep_helper): Takes extra argument, representing the repeat/rep args. This is inserted into the second position of the output list. (repeat_clause, rep_elem): Extract repeat/rep arguments and pass to repeat_rep_helper. (yybadtoken): Do not put quotes around the word "number". * txr.1: Updated. --- txr.1 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index 1b360ea8..8ba7afaf 100644 --- a/txr.1 +++ b/txr.1 @@ -3295,9 +3295,11 @@ like this: @(end) Repeat has four types of special clauses, any of which may be -specified with empty contents, or omitted entirely. They are explained +specified with empty contents, or omitted entirely. They are described below. +Repeat takes arguments, also described below. + All of the material in the main clause and optional clauses is examined for the presence of variables. If none of the variables hold lists which contain at least one item, then no output is performed, @@ -3381,6 +3383,14 @@ are none, or none of them activate, then @(last) is considered. If none of those clauses are present or apply, then the repetition is processed using the main clause. +Repeat supports an optional keyword argument: + + @(repeat [:counter ]) + +This designates a symbol which will behave as an integer variable over the +scope of the clauses inside the repeat. The variable provides access to the +reptition count, starting at zero, incrementing with each repetition. + .SS Nested Repeats If a repeat clause encloses variables which holds multidimensional lists, -- cgit v1.2.3