From 746179e5fc7c1b381f30cc71b5bf9a48c516e703 Mon Sep 17 00:00:00 2001 From: elioat Date: Sun, 12 Jan 2025 12:08:42 -0500 Subject: * --- awk/forth/f.awk | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/awk/forth/f.awk b/awk/forth/f.awk index 4675925..3184dde 100755 --- a/awk/forth/f.awk +++ b/awk/forth/f.awk @@ -1,11 +1,18 @@ #!/usr/bin/awk -f +# I wanted to implement something non-trivial using awk. +# If I was clever I wouldn’t implement forth directly in awk, +# instead I’d implement a simple virtual machine using awk, +# and then implement the forth using the virtual machine’s byte code +#…but there is only so much brain power I can exert on such a silly project. + BEGIN { # Initialize stacks and dictionaries stack_ptr = 0 dict_size = 0 - # Built-in words, and some documentation (I could use stack comments, but I find those sort of unintuitive) + # Built-in words, and some documentation (I could use stack comments, + # but I find those sort of unintuitive) dict["+"] = "+ : Adds the top two numbers on the stack." dict["-"] = "- : Subtracts the top number from the second top number on the stack." dict["*"] = "* : Multiplies the top two numbers on the stack." -- cgit 1.4.1-2-gfad0