diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-12-29 23:28:45 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-12-29 23:28:45 -0800 |
commit | 0b81b8b4c39b6c60cbbe8de5a6a785beb43c3dbb (patch) | |
tree | fcdcd0614874951ad5d9521f3cc75febd765302a /txr.1 | |
parent | 3e09c38f75b087e583abb30762a9a251b8f424f9 (diff) | |
download | txr-0b81b8b4c39b6c60cbbe8de5a6a785beb43c3dbb.tar.gz txr-0b81b8b4c39b6c60cbbe8de5a6a785beb43c3dbb.tar.bz2 txr-0b81b8b4c39b6c60cbbe8de5a6a785beb43c3dbb.zip |
New functionality: mod and modlast directives in repeat and rep.
* eval.c (eval_init): Use new symbol variable mod_s instead
of calling intern.
* match.c (mod_s, modlast_s): Symbol variables defined.
(do_output_line): mod and modlast directives implemented under rep.
(do_output): likewise under repeat.
(syms_init): Initialize new symbol variables.
* match.h (mod_s, modlast_s): Declared.
* parser.l (MOD, MODLAST): Parse new token types.
* parser.y (MOD, MODLAST): New tokens.
(repeat_parts_opt, rep_parts_opt): New syntax.
(repeat_rep_helper): Handle mod and modlast syntax.
* txr.1: Updated.
* txr.vim: Updated.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 33 |
1 files changed, 24 insertions, 9 deletions
@@ -3354,17 +3354,32 @@ repetition. If the repeat produces no repetitions, then the body of this clause is output. If this clause is absent or empty, the repeat produces no output. +.IP @(mod n m) +The forms n and m are expressions that evaluate to integers. The value of +m should be nonzero. The clause denoted this way is active if the repetition +modulo m is equal to n. The first repetition is numbered zero. +For instance the clause headed by @(mod 0 2) will be used on repetitions +0, 2, 4, 6, ... and @(mod 1 2) will be used on repetitions 1, 3, 5, 7, ... + +.IP @(modlast n m) +The meaning of n and m is the same as in @(mod n m), but one more condition +is imposed. This clause is used if the repetition modulo m is +equal to n, and if it is the last repetition. + .PP The precedence among the clauses which take an iteration is: -single > first > last > main. That is if two or more of these clauses -can apply to a repetition, then the leftmost one in this precedence list -applies. For instance, if there is just a single repetition, then any of these -special clause types can apply to that repetition, since it is the only -repetition, as well as the first and last one. In this situation, if -there is a single clause present, then the repetition is processed -using that clause. Otherwise, if there is a first clause present, that -clause is used. Failing that, a last clause applies. Only if none of these -clauses are present will the repetition be processed using the main clause. +single > first > mod > modlast > last > main. That is if two or more of these +clauses can apply to a repetition, then the leftmost one in this precedence +list applies. For instance, if there is just a single repetition, then any of +these special clause types can apply to that repetition, since it is the only +repetition, as well as the first and last one. In this situation, if there is a +@(single) clause present, then the repetition is processed using that clause. +Otherwise, if there is a @(first) clause present, that clause is used. Failing +that, @(mod) is used if there is such a clause and its numeric conditions +are satisfied. If not then @(modlast) clauses are considered, and if there +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. .SS Nested Repeats |