From a40ef1434889babbd88c9d0c5913c70e96ac2774 Mon Sep 17 00:00:00 2001 From: "Konstantin Kirik (snegovick)" Date: Fri, 12 Dec 2025 03:51:07 +0300 Subject: Add simple parser for future shell-like lang --- sh9util.b | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 sh9util.b (limited to 'sh9util.b') 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; +} -- cgit v1.2.3