X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=forth.jl.git;a=blobdiff_plain;f=src%2Fforth.jl;h=f10ea045cedc74258f737254a55e0cce0746c3a7;hp=37ce5d1a7e01f478dda01b87f3efcc3290a7fda4;hb=e57561fe2d6e29350b0bfb580d7129910ece9689;hpb=90a9b8ad41a542c3ca7d150d4d1168cb8ec97b81 diff --git a/src/forth.jl b/src/forth.jl index 37ce5d1..f10ea04 100644 --- a/src/forth.jl +++ b/src/forth.jl @@ -13,7 +13,7 @@ mem = Array{Int64,1}(size_mem) primitives = Array{Function,1}() primNames = Array{ASCIIString,1}() -# Built-in variables +# Memory geography and built-in variables nextVarAddr = 1 H = nextVarAddr; nextVarAddr += 1 # Next free memory address @@ -84,6 +84,8 @@ function putString(str::ASCIIString, addr::Int64) mem[addr:(addr+length(str)-1)] = [Int64(c) for c in str] end +stringAsInts(str::ASCIIString) = [Int(c) for c in collect(str)] + # Primitive creation and calling functions function defPrim(f::Function; name="nameless") @@ -1010,8 +1012,11 @@ INTERPRET_CFA = defWord("INTERPRET", EXIT_CFA]) PROMPT_CFA = defPrimWord("PROMPT", () -> begin - if (mem[STATE] == 0 && currentSource() == STDIN) - println(" ok") + if currentSource() == STDIN + if mem[STATE] == 0 + print(" ok") + end + println() end return NEXT