From 78a77b00d40befdacd4f5044f504ed132755609e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 29 Oct 2017 19:58:52 -0700 Subject: awk: implement ranges right using functions. * share/txr/stdlib/awk.tl (sys:awk%--rng, sys:awk%--rng-, sys:awk%rng+, sys:awk%-rng+, sys:awk%--rng+): New functions. (sys:awk-mac-let): Rewritten range expander. The four basic ranges rng, rng-, -rng and -rng- are handled with in-line expansion, because by doing that we avoid unnecessarily evaluating the from-expression. The remaining cases expand to function calls to the new functions, which receive the flag vector, the index position in that vector and the values of the from and to expressions. The behavior change is that that the -- forms now do the right thing: they hide all leading records that satisfy the from-expression, right to the last record of the range if necessary. * tests/015/awk-rng.expected: Updated. * txr.1: Revise semantic description the -- range types, plus minor fixes. --- tests/015/awk-rng.expected | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/015/awk-rng.expected b/tests/015/awk-rng.expected index aa79a932..25c4626b 100644 --- a/tests/015/awk-rng.expected +++ b/tests/015/awk-rng.expected @@ -8,22 +8,22 @@ X2 t t t t t t 1 t t t t t t t t t 2 t t t t t t t t t 3 t t t t t t t t t -Y1 t t t end t t t -r end end t t -s end end t t -Y2 end end t t +Y1 t t t t t t t +r t t t t +s t t t t +Y2 t t t t t Y2 X1X2 t t t -Y1Y2 t t t end t t t +Y1Y2 t t t t t t t X1X2 t t t -Y1 t t t end t t t -a end end t t -Y2 end end t t -X1X2Y1Y2 t t end end t t +Y1 t t t t t t t +a t t t t +Y2 t t t t +X1X2Y1Y2 t t t t t a -X1X2Y1Y2 t t end t t -X1X2Y1Y2 t t end end t t +X1X2Y1Y2 t t t +X1X2Y1Y2 t t t t X1 t t t -b t t t t t t -X2 t t t t t t +b t t t t t t t +X2 t t t t t t t -- cgit v1.2.3