summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-10-01 06:18:20 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-10-01 06:18:20 -0700
commitf9fab0b2b0285aeb6e06b782886a33f2fc96e436 (patch)
tree14b11f22a4ae0a82f0b27840fe2de451f7d713a9 /tests
parentbcc860a154403fa9063b55e87e0b168ec2448e04 (diff)
downloadtxr-f9fab0b2b0285aeb6e06b782886a33f2fc96e436.tar.gz
txr-f9fab0b2b0285aeb6e06b782886a33f2fc96e436.tar.bz2
txr-f9fab0b2b0285aeb6e06b782886a33f2fc96e436.zip
awk: new :fields feature for named fields.
* stdlib/awk.tl (sys:awk-compile-time): New slot, field-names. (sys:awk-expander): Validate and store field-names into compile-time structure. (sys:awk-symac-let): New macro. (awk): Wrap sys:awk-symac-let around code to generate field name macros. * tests/015/awk-fields.tl: New file. * txr.1: Documented.
Diffstat (limited to 'tests')
-rw-r--r--tests/015/awk-fields.tl18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/015/awk-fields.tl b/tests/015/awk-fields.tl
new file mode 100644
index 00000000..7f27e9e4
--- /dev/null
+++ b/tests/015/awk-fields.tl
@@ -0,0 +1,18 @@
+(load "../common")
+
+(mtest
+ (awk (:fields) (:begin (return-from awk))) nil
+ (awk (:fields t) (:begin (return-from awk))) :error
+ (awk (:fields nil) (:begin (return-from awk))) :error
+ (awk (:fields - -) (:begin (return-from awk))) nil
+ (awk (:fields a - - b) (:begin (return-from awk))) nil
+ (awk (:fields a - - a) (:begin (return-from awk))) :error
+ (awk (:fields a) (:fields b) (:begin (return-from awk))) :error)
+
+(test
+ (build
+ (awk
+ (:inputs '("How now brown cow"))
+ (:fields h n - c)
+ (t (add h n c))))
+ ("How" "now" "cow"))