From c57c3218717f0ab7f0f6d7a9354d94824b5d9c15 Mon Sep 17 00:00:00 2001 From: psf Date: Sat, 21 May 2022 23:05:40 -0700 Subject: [PATCH] Fixes --- build.sh | 4 +++- frustration.4th | 10 ++++++---- frustration.rs | 10 +++++++--- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/build.sh b/build.sh index c1ff34e..5a70771 100644 --- a/build.sh +++ b/build.sh @@ -1 +1,3 @@ -rustc frustration.rs && cat frustration.4th - | ./frustration +(echo "Compiling..." ; rustc frustration.rs) || exit +echo "Forth is now running." +cat frustration.4th - | ./frustration diff --git a/frustration.4th b/frustration.4th index e7baea4..cd2be05 100644 --- a/frustration.4th +++ b/frustration.4th @@ -29,10 +29,10 @@ return-from-caller trick quite so much! Let's explain how it works. -LINE 1 --> : rdup r> r> dup >r >r >r ; -LINE 2 --> : rdrop r> r> drop >r ; -LINE 3 --> : loop[ [ ' setup lit ] , [ ' rdrop lit ] , ; immediate -LINE 4 --> : ]loop latest @ 8 + , ; immediate +LINE 1 : rdup r> r> dup >r >r >r ; +LINE 2 : rdrop r> r> drop >r ; +LINE 3 : loop[ [ ' setup lit ] , [ ' rdrop lit ] , ; immediate +LINE 4 : ]loop latest @ 8 + , ; immediate Line 1-4 are defining a new loop construct called loop[ ... ]loop that makes a word tail-recursive. @@ -157,6 +157,8 @@ LINE 5 --> : ( loop[ key 41 = ? ret ]loop ; immediate ( Here is a riddle for you ) : :noname ( -- xt ) here @ [ ' ] , ] ; immediate + +:noname drop rdrop ; : stars ( n -- ) loop[ dup 0= ? [ , ] 1 - 42 emit ]loop ; ( How does the above code work? diff --git a/frustration.rs b/frustration.rs index 0b1158c..c3fb2a6 100644 --- a/frustration.rs +++ b/frustration.rs @@ -2137,14 +2137,18 @@ fn main() { * You can run this Forth with: * ./frustration * - * However, I recommend loading a Forth program (frustration.fs, provided) + * However, I recommend loading a Forth program (frustration.4th, provided) * which does a few more setup steps before letting you loose. * * cat frustration.4th - | ./frustration * * The line above is a good way to run Frustration if you're using Linux. - * It concatenates together frustration.fs and - (stdin). This means you - * can type commands once frustration.fs is loaded. + * It concatenates together frustration.4th and - (stdin). This means you + * can type commands once frustration.4th has been executed. + * + * There is a shell script supplied that will do all of the above for you. + * + * bash build.sh * * Please read frustration.4th if you want to learn more about Forth and what * makes it a unique language.