summaryrefslogtreecommitdiff
path: root/sh9util.b
diff options
context:
space:
mode:
authorKonstantin Kirik (snegovick) <snegovick@uprojects.org>2025-12-12 03:51:07 +0300
committerKonstantin Kirik (snegovick) <snegovick@uprojects.org>2025-12-12 03:51:07 +0300
commita40ef1434889babbd88c9d0c5913c70e96ac2774 (patch)
treea71e4f3cb1d6056554e3958468ddfcee0300e08e /sh9util.b
parentcc280d7e5d07fd61e45825b3850c8baaa4147639 (diff)
Add simple parser for future shell-like lang
Diffstat (limited to 'sh9util.b')
-rw-r--r--sh9util.b26
1 files changed, 26 insertions, 0 deletions
diff --git a/sh9util.b b/sh9util.b
new file mode 100644
index 0000000..f74032e
--- /dev/null
+++ b/sh9util.b
@@ -0,0 +1,26 @@
+implement Sh9Util;
+
+include "sh9util.m";
+
+reverse_list[T](toks: list of T): list of T
+{
+ lt := len toks;
+ out : list of T;
+ for (i := 0; i < lt; i ++) {
+ tok := hd toks;
+ #toks = tl toks;
+ out = tok :: out;
+ }
+ return out;
+}
+
+to_array[T](toks: list of T): array of T {
+ lt := len toks;
+ out := array[lt] of T;
+ for (i := 0; i < lt; i ++) {
+ tok := hd toks;
+ toks = tl toks;
+ out[i] = tok;
+ }
+ return out;
+}