From: Tim Vaughan Date: Sun, 24 Apr 2016 02:28:42 +0000 (+1200) Subject: Adding core forth words. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=19b36fc0c147c5d98fe346ad62771fd615d137bb;p=forth.jl.git Adding core forth words. --- diff --git a/src/forth.jl b/src/forth.jl index a3c55f0..19e5965 100644 --- a/src/forth.jl +++ b/src/forth.jl @@ -882,7 +882,7 @@ BYE = defPrimWord("BYE", () -> begin end) NL = defPrimWord("\n", () -> begin - if mem[STATE] == 0 + if mem[STATE] == 0 && reg.source == STDIN println(" ok") end return NEXT diff --git a/src/lib.fs b/src/lib.fs new file mode 100644 index 0000000..14194cd --- /dev/null +++ b/src/lib.fs @@ -0,0 +1,22 @@ +: / /MOD SWAP DROP ; +: MOD /MOD DROP ; + +: '\n' 10 ; +: BL 32 ; + +: CR '\n' emit ; +: SPACE BL emit ; + +: NEGATE 0 swap - ; + +: TRUE -1 ; +: FALSE 0 ; +: NOT 0= ; + +: LITERAL IMMEDIATE + ' LIT , + , + ; + +: ':' [ CHAR : ] LITERAL ; +