From: Tim Vaughan Date: Sun, 29 May 2016 01:45:25 +0000 (+1200) Subject: Removed unnecessary ['] primitive. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=6cb12b03e2a154214fc60d7c437e650e79fb42e5;p=forth.jl.git Removed unnecessary ['] primitive. --- diff --git a/src/forth.jl b/src/forth.jl index c8cd131..9439dea 100644 --- a/src/forth.jl +++ b/src/forth.jl @@ -840,9 +840,6 @@ COMMA_CFA = defPrimWord(",", () -> begin return NEXT end) -BTICK_CFA = defWord("[']", - [FROMR_CFA, DUP_CFA, INCR_CFA, TOR_CFA, FETCH_CFA, EXIT_CFA]) - HERE_CFA = defWord("HERE", [H_CFA, FETCH_CFA, EXIT_CFA]) @@ -885,8 +882,8 @@ DOES_HELPER_CFA = defPrimWord("(DOES>)", () -> begin end, flags=F_IMMED) DOES_CFA = defWord("DOES>", - [BTICK_CFA, LIT_CFA, COMMA_CFA, HERE_CFA, LIT_CFA, 3, ADD_CFA, COMMA_CFA, - BTICK_CFA, DOES_HELPER_CFA, COMMA_CFA, BTICK_CFA, EXIT_CFA, COMMA_CFA, EXIT_CFA], + [LIT_CFA, LIT_CFA, COMMA_CFA, HERE_CFA, LIT_CFA, 3, ADD_CFA, COMMA_CFA, + LIT_CFA, DOES_HELPER_CFA, COMMA_CFA, LIT_CFA, EXIT_CFA, COMMA_CFA, EXIT_CFA], flags=F_IMMED) LBRAC_CFA = defPrimWord("[", () -> begin @@ -952,7 +949,7 @@ INTERPRET_CFA = defWord("INTERPRET", COMMA_CFA, BRANCH_CFA, -29, # No word found, parse number - NUMBER_CFA, BTICK_CFA, LIT_CFA, COMMA_CFA, COMMA_CFA, BRANCH_CFA, -36, + NUMBER_CFA, LIT_CFA, LIT_CFA, COMMA_CFA, COMMA_CFA, BRANCH_CFA, -36, # Interpreting FIND_CFA, QDUP_CFA, ZBRANCH_CFA, 5, diff --git a/src/lib_1_basic.4th b/src/lib_1_basic.4th index 1764723..40851f3 100644 --- a/src/lib_1_basic.4th +++ b/src/lib_1_basic.4th @@ -40,10 +40,15 @@ : '\n' 10 ; : BL 32 ; - -: LITERAL IMMEDIATE ['] LIT , , ; +: CR '\n' emit ; +: SPACE BL emit ; : ' BL WORD FIND DROP ; +: [COMPILE] IMMEDIATE ' , ; +: ['] IMMEDIATE + LIT LIT , ' , ; + +: LITERAL IMMEDIATE ['] LIT , , ; : CHAR BL WORD 1+ @ ; : [CHAR] IMMEDIATE @@ -51,15 +56,6 @@ ['] LIT , , ; -: CR '\n' emit ; -: SPACE BL emit ; - -: [COMPILE] IMMEDIATE - BL WORD \ get the next word - FIND DROP \ find it in the dictionary - , \ and compile that -; - : RECURSE IMMEDIATE LATEST @ \ LATEST points to the word being compiled at the moment >CFA \ get the codeword