summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-05-19 20:36:45 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-05-19 20:36:45 -0700
commitdd3884648c375a775ed1e777e5f8f58db5d226d7 (patch)
tree69efa656bdbc60507ecd6be5fd9f1e98fe884bcb /share
parentfe4c305ba334956e70de9bbbb0292fac7404338a (diff)
downloadtxr-dd3884648c375a775ed1e777e5f8f58db5d226d7.tar.gz
txr-dd3884648c375a775ed1e777e5f8f58db5d226d7.tar.bz2
txr-dd3884648c375a775ed1e777e5f8f58db5d226d7.zip
awk: new feature: again operator.
* share/txr/stdlib/awk.tl (sys:awk-state loop): Wrap a loop around around the two forms that split the record into fields and dispatch the main rule function. The loop repeats if the named block returns :awk-again. (sys:awk-mac-let): New local macro (again) which bails out of the :awk-rec block just like (next) does, but specifies :awk-again as the return value. * txr.1: Documented.
Diffstat (limited to 'share')
-rw-r--r--share/txr/stdlib/awk.tl6
1 files changed, 3 insertions, 3 deletions
diff --git a/share/txr/stdlib/awk.tl b/share/txr/stdlib/awk.tl
index 5b19e706..b0f54aaf 100644
--- a/share/txr/stdlib/awk.tl
+++ b/share/txr/stdlib/awk.tl
@@ -172,9 +172,8 @@
(set aws.rec rec aws.orig-rec rec)
(inc aws.rec-num)
(inc aws.file-rec-num)
- aws.(rec-to-f)
- (block :awk-rec
- [func aws]))
+ (while* (eq :awk-again (block :awk-rec [func aws]))
+ aws.(rec-to-f)))
(when end-file-func
[end-file-func aws])))))))
@@ -294,6 +293,7 @@
(ofs (qref ,aws-sym ofs))
(ors (qref ,aws-sym ors)))
(macrolet ((next () '(return-from :awk-rec))
+ (again () '(return-from :awk-rec :awk-again))
(next-file () '(return-from :awk-file))
(sys:rng (form from-expr to-expr :env e)
(let ((style (car form))