From 4ddd3e1e56ee0454f968c0a575fd7f7de9eaad1c Mon Sep 17 00:00:00 2001 From: albert Date: Fri, 8 Jan 2016 19:34:40 +0000 Subject: [PATCH] -legacy- now gives a proper classical vocabulary and >IN REFILL behaviour. -tricky-control- handles any control but no security. CS-ROLL has been added. SLITERAL now decompiles better. INLINING has a separate screen. --- blocks.frt | 78 +++++++++++++++++++++++++++++++++-------------- ci86.lina.labtest | 13 ++++++++ ciforth.mi | 3 ++ logforth.txt | 16 ++++++++++ manual.mi | 6 ++++ 5 files changed, 93 insertions(+), 23 deletions(-) diff --git a/blocks.frt b/blocks.frt index 1dca263..b7e52a9 100644 --- a/blocks.frt +++ b/blocks.frt @@ -190,22 +190,22 @@ WANT ALIAS -( -legacy- IN >IN REFILL ) \ AvdH B4Oct25 +( -legacy- IN >IN REFILL 0>IN ) \ AvdH B5jan7 WANT ALIAS -\ Use L_>IN instead of >IN , don't store into it! -: L_>IN PP @ SRC @ - (>IN) ! (>IN) ; -'L_>IN ALIAS >IN -: REFILL 0 ; -: IN PP ; - - - - - - - - - +\ Fake a parse area that starts at address 0. +'PP ALIAS >IN 'PP ALIAS IN +: SOURCE 0 SCR CELL+ @ ; +\ Set parse pointer at start of line. +: 0>IN BEGIN -1 PP +! PP @ 1- C@ ^J = PP @ SRC @ = OR UNTIL ; +\ Closest match to traditional line by line interpreting. +\ Set parse pointer at start of next line +: REFILL BEGIN PP @ 1- C@ ^J <> PP @ SRC CELL+ @ <> AND WHILE + +1 PP +! REPEAT PP @ SRC CELL+ @ <> ; + +\ UNCLEAR IF THIS EVER WORKED, KEEP FOR REFERENCE! +\ \ Use L_>IN instead of >IN , don't store into it! +\ : L_>IN PP @ SRC @ - (>IN) ! (>IN) ; +\ 'L_>IN ALIAS >IN ( -legacy- VOCABULARY ) \ AvdH B5dec01 \ Use replacing vocabularies instead of pushing namespaces. @@ -446,7 +446,7 @@ CURRENT @ 'ONLY >WID CURRENT ! '3 DUP ALIAS Y DUP ALIAS Z DROP CURRENT ! \ Use 'ONLY >WID CURRENT ! instead of DEFINITIONS -( TUCK -ROT PICK ROLL ) \ AvdH B5dec11 +( TUCK -ROT PICK ROLL CS-ROLL ) \ AvdH B6jan6 \ Obscure stack manipulations. : PICK 1+ CELLS DSP@ + @ ; : TUCK SWAP OVER ; @@ -454,14 +454,30 @@ DROP CURRENT ! : ROLL 1+ >R DSP@ DUP CELL+ R> 2 - CELLS 2DUP + @ >R CELL+ MOVE DROP R> ; +\ -pedantic- required when used with DO-LOOP +: CS-ROLL 2* 1+ DUP >R ROLL R> ROLL ; - - +( -tricky-control- ) \ AvdH B6jan6 +WANT CS-ROLL : (F (FORWARD _ ; : F) DROP FORWARD) ; + : (B (BACK _ ; : B) DROP BACK) ; + : AHEAD 'BRANCH , (F ; IMMEDIATE +'IF HIDDEN : IF '0BRANCH , (F ; IMMEDIATE +'ELSE HIDDEN : ELSE 'BRANCH , (F 1 CS-ROLL F) ; IMMEDIATE +'THEN HIDDEN : THEN F) ; IMMEDIATE +'BEGIN HIDDEN : BEGIN (B ; IMMEDIATE +'WHILE HIDDEN : WHILE '0BRANCH , (F 1 CS-ROLL ; IMMEDIATE +'REPEAT HIDDEN : REPEAT 'BRANCH , B) F) ; IMMEDIATE +'AGAIN HIDDEN : AGAIN 'BRANCH , B) ; IMMEDIATE +'UNTIL HIDDEN : UNTIL '0BRANCH , B) ; IMMEDIATE +'DO HIDDEN : DO '(DO) , (FORWARD (BACK ; IMMEDIATE +'?DO HIDDEN : ?DO '(?DO) , (FORWARD (BACK ; IMMEDIATE +'LOOP HIDDEN : LOOP '(LOOP) , BACK) FORWARD) ; IMMEDIATE +'+LOOP HIDDEN : +LOOP '(+LOOP) , BACK) FORWARD) ; IMMEDIATE ( 2>R 2R> 2R@ 2CONSTANT 2VARIABLE 2, ) \ AvdH B5Mar9 @@ -1230,11 +1246,11 @@ $1B CONSTANT ESC -( SLITERAL $. $? ."$" ) \ AvdH B2aug12 +( SLITERAL $. $? ."$" ) \ AvdH B5jan8 \ ISO -: SLITERAL POSTPONE SKIP $, POSTPONE LITERAL POSTPONE $@ ; -IMMEDIATE +: SLITERAL 'SKIP , $, $@ SWAP 'LIT , , 'LIT , , ; IMMEDIATE + \ ISO @@ -1422,7 +1438,7 @@ WANT T] WANT :2 \ Last scripting block! CREATE -scripting- -( :2 :F :R :I INLINING ) \ AvdH B4oct14 +( :2 :F :R :I ) \ AvdH B6jan7 WANT ALIAS \ Alias of : , redefine an existing(!) word. Or crash. : :2 PP @ NAME FOUND >R R@ HIDDEN PP ! : R> HIDDEN ; @@ -1436,8 +1452,24 @@ WANT ALIAS DOES> STATE @ IF BEGIN $@ DUP '(;) <> WHILE , REPEAT 2DROP ELSE >R THEN ; + + +( INLINING ) \ AvdH B6jan7 +\ With INLINING in the search order, all words are inlined. NAMESPACE INLINING -INLINING DEFINITIONS :2 : :I ; PREVIOUS DEFINITIONS +INLINING DEFINITIONS + :2 : :I ; +PREVIOUS DEFINITIONS + + + + + + + + + + ( OLD: RESTORED POSTFIX ) \ AvdH A2jun12 \ WARNING: use these facilities only with high level words. diff --git a/ci86.lina.labtest b/ci86.lina.labtest index 52fd560..bd0e7ae 100644 --- a/ci86.lina.labtest +++ b/ci86.lina.labtest @@ -48,3 +48,16 @@ wordtest( {ROLL}, {3 2 1 0 3 ROLL . . . . },{3 0 1 2 }, {4 3 2 1 0 4 ROLL . . . . . },{4 0 1 2 3 }, }) +wordtest( {REFILL}, +{ { WANT REFILL}, {SOURCE : ISN'T UNIQUE }, + { : _G13 2DUP OVER + SWAP DO I C@ &| = IF ^J I C! THEN LOOP ;},{}, + { " 1 2 3 4 REFILL| 1 . 3 .| .| . . . . " _G13 EVALUATE },{1 3 -1 4 3 2 1 }, +}) +wordtest( {0>IN}, +{ { WANT 0>IN}, {SOURCE : ISN'T UNIQUE }, +{: _G14 DUP IF 1- 0>IN THEN ;},{}, + { : _G13 2DUP OVER + SWAP DO I C@ &| = IF ^J I C! THEN LOOP ;},{}, + { " 4| DUP . _G14 | 9 + . " _G13 EVALUATE},{4 3 2 1 0 9}, + { " 1 2 3 4| DUP . _G14 |. . . ." _G13 EVALUATE},{4 3 2 1 0 0 3 2 1 }, + { " 1 2 3 4| DUP . _G14|. . . ." _G13 EVALUATE},{4 3 2 1 0 0 3 2 1 }, +}) diff --git a/ciforth.mi b/ciforth.mi index d3e6992..5bef92f 100644 --- a/ciforth.mi +++ b/ciforth.mi @@ -559,6 +559,9 @@ This detection mechanism by the ISO standard. You may disable this checking by forthcode({NO-SECURITY}) and re-instate it by forthcode({DO-SECURITY}). +You can compile even combination of forthcode({DO}) and +forthcode({BRANCH}) controls after + forthcode({WANT -tricky-control- }) }) forthitem diff --git a/logforth.txt b/logforth.txt index e62ac59..d270b34 100644 --- a/logforth.txt +++ b/logforth.txt @@ -13852,6 +13852,22 @@ as required. Fixed. The documentation of error 20 is wrong. A DROP should be added. The case about NO-SECURITY merits a place in common problems +2016 jan 8 +Noforth compiles. The option -legacy- has been expanded and +does the following: + The VOCABULARY structure is compatible with gforth etc. + VOCABULARY exist. FORTH replaces the topmost etc. + The parse area SOURCE is changed to start at zero. + 0>IN goes to the start of the line, REFILL to the + start of the next line. This covers a remarkable part of + old style source handling. + +There is a screen -tricky-control- . This has AHEAD , +the ability to jump out of DO LOOP with WHILE etc. +do-sys and orifg's on the control stack are made the +same size. +CS-ROLL has been added. SLITERAL didn't compile well. + -------------------- The description of ACCEPT is no good. diff --git a/manual.mi b/manual.mi index 204871f..9365183 100644 --- a/manual.mi +++ b/manual.mi @@ -475,6 +475,12 @@ The library is not a supposedly ISO-conforming program. It tends to rely on ciforth-specific and thisforth-specific -- but hopefully documented -- behaviour. Understanding it requires some study of non-portable facilities. +forthitem +When a file is forthcode({INCLUDED}) it is read in as a whole, +so there is never a need for forthcode({REFILL}) . +After forthcode({ WANT REFILL}) a forthcode({REFILL}) is loaded that +sets the parse pointer to the start of the next line. + forthendenumerate Here we will explain how you must read the glossary of thisforth,