From: Tim Vaughan Date: Tue, 11 Oct 2016 08:37:54 +0000 (+1300) Subject: Moved some input stream words to library. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;ds=sidebyside;h=30a093845e2d1097242e948bb577fb71f73bc860;hp=c52194127d604bd365f7222936b46f34f62a4814;p=forth.jl.git Moved some input stream words to library. --- diff --git a/src/forth.jl b/src/forth.jl index c540313..6afe492 100644 --- a/src/forth.jl +++ b/src/forth.jl @@ -969,29 +969,18 @@ FIB_CFA = defConst("FIB", FIB) NUMFIB, NUMFIB_CFA = defNewVar("#FIB", 0) IB_CFA = defPrimWord("IB", () -> begin - pushPS(mem[SOURCE_ID] == 0 ? TIB : FIB) + pushPS(mem[SOURCE_ID_VAR] == 0 ? TIB : FIB) return NEXT end) NUMIB_CFA = defPrimWord("#IB", () -> begin - pushPS(mem[SOURCE_ID] == 0 ? NUMTIB : NUMFIB) + pushPS(mem[SOURCE_ID_VAR] == 0 ? NUMTIB : NUMFIB) return NEXT end) TOIN, TOIN_CFA = defNewVar(">IN", 0) -SOURCE_ID, SOURCE_ID_CFA = defNewVar("SOURCE-ID", 0) - -SOURCE_CFA = defPrimWord("SOURCE", () -> begin - if mem[SOURCE_ID] == 0 - pushPS(TIB) - pushPS(NUMTIB) - else - pushPS(FIB) - pushPS(NUMFIB) - end - return NEXT -end) +SOURCE_ID_VAR, SOURCE_ID_VAR_CFA = defNewVar("SOURCE-ID-VAR", 0) QUERY_CFA = defWord("QUERY", [TIB_CFA, LIT_CFA, 160, EXPECT_CFA, @@ -1010,17 +999,16 @@ QUERY_FILE_CFA = defWord("QUERY-FILE", LIT_CFA, 0, TOIN_CFA, STORE_CFA, EXIT_CFA]) -QUERY_INPUT_CFA = defWord("QUERY-INPUT", - [SOURCE_ID_CFA, FETCH_CFA, QDUP_CFA, ZBRANCH_CFA, 3, - QUERY_FILE_CFA, EXIT_CFA, - QUERY_CFA, EXIT_CFA]) - WORD_CFA = defPrimWord("WORD", () -> begin delim = popPS() - callPrim(mem[SOURCE_CFA]) - sizeAddr = popPS() - bufferAddr = popPS() + if mem[SOURCE_ID_VAR] == 0 + bufferAddr = TIB + sizeAddr = NUMTIB + else + bufferAddr = FIB + sizeAddr = NUMFIB + end # Chew up initial occurrences of delim while (mem[TOIN]