From f9fab0b2b0285aeb6e06b782886a33f2fc96e436 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 1 Oct 2021 06:18:20 -0700 Subject: 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. --- tests/015/awk-fields.tl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/015/awk-fields.tl (limited to 'tests/015/awk-fields.tl') 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")) -- cgit v1.2.3