diff options
author | elioat <elioat@tilde.institute> | 2025-01-12 12:08:42 -0500 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2025-01-12 12:08:42 -0500 |
commit | 746179e5fc7c1b381f30cc71b5bf9a48c516e703 (patch) | |
tree | eb19778ed15dcd6f0e6a91747ed48d6c87d486f5 | |
parent | 8a82de9db980e711ffd1eb597990429ff2db5b11 (diff) | |
download | tour-746179e5fc7c1b381f30cc71b5bf9a48c516e703.tar.gz |
*
-rwxr-xr-x | awk/forth/f.awk | 9 |
1 files changed, 8 insertions, 1 deletions
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." |