Skip to content

Commit

Permalink
-legacy- now gives a proper classical vocabulary and >IN REFILL behav…
Browse files Browse the repository at this point in the history
…iour.

-tricky-control- handles any control but no security.
CS-ROLL has been added. SLITERAL now decompiles better.
INLINING has a separate screen.
  • Loading branch information
albert committed Jan 8, 2016
1 parent a884abf commit 4ddd3e1
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 23 deletions.
78 changes: 55 additions & 23 deletions blocks.frt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -446,22 +446,38 @@ 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 ;
: -ROT ROT ROT ;
: 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


Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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 ;
Expand All @@ -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.

Expand Down
13 changes: 13 additions & 0 deletions ci86.lina.labtest
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
})
3 changes: 3 additions & 0 deletions ciforth.mi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions logforth.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
6 changes: 6 additions & 0 deletions manual.mi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4ddd3e1

Please sign in to comment.