mirror of
https://gitlab.cs.washington.edu/fidelp/frustration.git
synced 2024-12-26 21:58:20 +01:00
Fixes
This commit is contained in:
parent
f0657ef8ae
commit
c57c321871
3 changed files with 16 additions and 8 deletions
4
build.sh
4
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
|
||||||
|
|
|
@ -29,10 +29,10 @@ return-from-caller trick quite so much!
|
||||||
|
|
||||||
Let's explain how it works.
|
Let's explain how it works.
|
||||||
|
|
||||||
LINE 1 --> : rdup r> r> dup >r >r >r ;
|
LINE 1 : rdup r> r> dup >r >r >r ;
|
||||||
LINE 2 --> : rdrop r> r> drop >r ;
|
LINE 2 : rdrop r> r> drop >r ;
|
||||||
LINE 3 --> : loop[ [ ' setup lit ] , [ ' rdrop lit ] , ; immediate
|
LINE 3 : loop[ [ ' setup lit ] , [ ' rdrop lit ] , ; immediate
|
||||||
LINE 4 --> : ]loop latest @ 8 + , ; immediate
|
LINE 4 : ]loop latest @ 8 + , ; immediate
|
||||||
|
|
||||||
Line 1-4 are defining a new loop construct called loop[ ... ]loop that
|
Line 1-4 are defining a new loop construct called loop[ ... ]loop that
|
||||||
makes a word tail-recursive.
|
makes a word tail-recursive.
|
||||||
|
@ -157,6 +157,8 @@ LINE 5 --> : ( loop[ key 41 = ? ret ]loop ; immediate
|
||||||
( Here is a riddle for you )
|
( Here is a riddle for you )
|
||||||
|
|
||||||
: :noname ( -- xt ) here @ [ ' ] , ] ; immediate
|
: :noname ( -- xt ) here @ [ ' ] , ] ; immediate
|
||||||
|
|
||||||
|
:noname drop rdrop ;
|
||||||
: stars ( n -- ) loop[ dup 0= ? [ , ] 1 - 42 emit ]loop ;
|
: stars ( n -- ) loop[ dup 0= ? [ , ] 1 - 42 emit ]loop ;
|
||||||
|
|
||||||
( How does the above code work?
|
( How does the above code work?
|
||||||
|
|
|
@ -2137,14 +2137,18 @@ fn main() {
|
||||||
* You can run this Forth with:
|
* You can run this Forth with:
|
||||||
* ./frustration
|
* ./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.
|
* which does a few more setup steps before letting you loose.
|
||||||
*
|
*
|
||||||
* cat frustration.4th - | ./frustration
|
* cat frustration.4th - | ./frustration
|
||||||
*
|
*
|
||||||
* The line above is a good way to run Frustration if you're using Linux.
|
* 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
|
* It concatenates together frustration.4th and - (stdin). This means you
|
||||||
* can type commands once frustration.fs is loaded.
|
* 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
|
* Please read frustration.4th if you want to learn more about Forth and what
|
||||||
* makes it a unique language.
|
* makes it a unique language.
|
||||||
|
|
Loading…
Reference in a new issue