From d0d02a9174dd0a8e4e0c37dc2d990d692ee9a73d Mon Sep 17 00:00:00 2001 From: Tim Vaughan Date: Sat, 7 May 2016 23:51:40 +1200 Subject: [PATCH] Slowly getting lib.4th to compile again. --- src/forth.jl | 9 +++++---- src/lib.4th | 15 ++++----------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/forth.jl b/src/forth.jl index 3305d5e..0803b72 100644 --- a/src/forth.jl +++ b/src/forth.jl @@ -721,6 +721,7 @@ end) # Outer interpreter TRACE = defPrimWord("TRACE", () -> begin + println("Val: $(popPS())") print("RS: "); printRS() print("PS: "); printPS() print("[paused]") @@ -825,7 +826,7 @@ INTERPRET = defWord("INTERPRET", DUP, FETCH, ZE, ZBRANCH, 3, DROP, EXIT, # Exit if TIB is exhausted - STATE_CFA, FETCH, ZBRANCH, 32, + STATE_CFA, FETCH, ZBRANCH, 31, # Compiling DUP, FIND, QDUP, ZBRANCH, 19, @@ -839,16 +840,16 @@ INTERPRET = defWord("INTERPRET", COMMA, BRANCH, -36, # No word found, parse number - NUMBER, BTICK, LIT, COMMA, COMMA, TRACE, BRANCH, -44, + NUMBER, BTICK, LIT, COMMA, COMMA, BRANCH, -43, # Interpreting DUP, FIND, QDUP, ZBRANCH, 7, # Found word. Execute! - SWAP, DROP, TOCFA, EXECUTE, BRANCH, -55, + SWAP, DROP, TOCFA, EXECUTE, BRANCH, -54, # No word found, parse number and leave on stack - NUMBER, BRANCH, -58, + NUMBER, BRANCH, -57, EXIT] ) diff --git a/src/lib.4th b/src/lib.4th index c9df3d9..68bb77b 100644 --- a/src/lib.4th +++ b/src/lib.4th @@ -1,6 +1,5 @@ : \ IMMEDIATE - KEY - 10 = 0BRANCH [ -5 , ] + #TIB @ >IN ! ; \ We can now comment! \ BASIC DEFINITIONS ---------------------------------------------------------------------- @@ -33,10 +32,7 @@ : LITERAL IMMEDIATE ['] LIT , , ; -: CHAR - BL WORD - DROP @ -; +: CHAR BL WORD 1+ @ ; : [CHAR] IMMEDIATE CHAR @@ -59,9 +55,6 @@ , \ compile it ; -: DEBUGON TRUE DEBUG ! ; -: DEBUGOFF FALSE DEBUG ! ; - \ CONTROL STRUCTURES ---------------------------------------------------------------------- : IF IMMEDIATE @@ -220,11 +213,11 @@ : ( IMMEDIATE 1 \ allowed nested parens by keeping track of depth BEGIN - >IN #TIB >= IF \ End of TIB? + >IN @ #TIB @ >= IF \ End of TIB? QUERY \ Get next line THEN - >IN @ 1 >IN +! + TIB >IN @ + @ 1 >IN +! DUP [CHAR] ( = IF \ open paren? DROP \ drop the open paren 1+ \ depth increases -- 2.20.1