summaryrefslogtreecommitdiff
path: root/test/self/lexer.mnml
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2025-02-25 13:24:02 +0100
committerDaniel Weipert <git@mail.dweipert.de>2025-02-25 13:24:02 +0100
commit65b36f1b321a71578cd8b568b4a04ef27c6b714a (patch)
tree6b1f69dbecff1b7e08e5efcd2787769a91671023 /test/self/lexer.mnml
parent54b4040a8e46c4104e228264fa57b44d17e245c9 (diff)
value nodes + assigning values one-time to initialized variablesHEADmain
Diffstat (limited to 'test/self/lexer.mnml')
-rw-r--r--test/self/lexer.mnml22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/self/lexer.mnml b/test/self/lexer.mnml
new file mode 100644
index 0000000..8468f66
--- /dev/null
+++ b/test/self/lexer.mnml
@@ -0,0 +1,22 @@
+const main: function = (input: string): array {
+ return lex(input = input, position = 0, output = [])
+}
+
+const lex: function = (input: string, position: integer, output: array): array {
+ if (position == (strlen(input))) {
+ return output
+ }
+
+ const current_char: string = get_char(input, position)
+
+ const appended_output: array
+ if (current_char != " ") {
+ appended_output = array_append(output, current_char)
+ } else {
+ appended_output = output
+ }
+
+ return lex(input = input, position = (position + 1), output = appended_output)
+}
+
+main(input = "a b c d e f g") => dump($)