version 1.15, 1994/08/25 15:25:28
|
version 1.18, 1994/09/02 15:23:36
|
Line 756 Avariable leave-sp leave-stack 3 cells
|
Line 756 Avariable leave-sp leave-stack 3 cells
|
: ." state @ IF postpone (.") ," align |
: ." state @ IF postpone (.") ," align |
ELSE [char] " parse type THEN ; immediate |
ELSE [char] " parse type THEN ; immediate |
: ( [char] ) parse 2drop ; immediate |
: ( [char] ) parse 2drop ; immediate |
: \ source >in ! drop ; immediate |
: \ blk @ IF >in @ c/l / 1+ c/l * >in ! EXIT THEN |
|
source >in ! drop ; immediate |
|
|
\ error handling 22feb93py |
\ error handling 22feb93py |
\ 'abort thrown out! 11may93jaw |
\ 'abort thrown out! 11may93jaw |
Line 965 AVariable current
|
Line 966 AVariable current
|
Create f83search ' f83find A, ' (reveal) A, ' drop A, |
Create f83search ' f83find A, ' (reveal) A, ' drop A, |
|
|
Create forth-wordlist NIL A, G f83search T A, NIL A, NIL A, |
Create forth-wordlist NIL A, G f83search T A, NIL A, NIL A, |
AVariable search G forth-wordlist search T ! |
AVariable lookup G forth-wordlist lookup T ! |
G forth-wordlist current T ! |
G forth-wordlist current T ! |
|
|
: (search-wordlist) ( addr count wid -- nfa / false ) |
: (search-wordlist) ( addr count wid -- nfa / false ) |
dup ( @ swap ) cell+ @ @ execute ; |
dup cell+ @ @ execute ; |
|
|
: search-wordlist ( addr count wid -- 0 / xt +-1 ) |
: search-wordlist ( addr count wid -- 0 / xt +-1 ) |
(search-wordlist) dup IF found THEN ; |
(search-wordlist) dup IF found THEN ; |
Line 991 Variable warnings G -1 warnings T !
|
Line 992 Variable warnings G -1 warnings T !
|
2drop 2drop ; |
2drop 2drop ; |
|
|
: sfind ( c-addr u -- xt n / 0 ) |
: sfind ( c-addr u -- xt n / 0 ) |
search @ search-wordlist ; |
lookup @ search-wordlist ; |
|
|
: find ( addr -- cfa +-1 / string false ) |
: find ( addr -- cfa +-1 / string false ) |
\ !! not ANS conformant: returns +-2 for restricted words |
\ !! not ANS conformant: returns +-2 for restricted words |
Line 1013 Variable warnings G -1 warnings T !
|
Line 1014 Variable warnings G -1 warnings T !
|
|
|
07 constant #bell |
07 constant #bell |
08 constant #bs |
08 constant #bs |
|
09 constant #tab |
7F constant #del |
7F constant #del |
0D constant #cr \ the newline key code |
0D constant #cr \ the newline key code |
|
0C constant #ff |
0A constant #lf |
0A constant #lf |
|
|
: bell #bell emit ; |
: bell #bell emit ; |
Line 1060 Create crtlkeys
|
Line 1063 Create crtlkeys
|
|
|
\ Output 13feb93py |
\ Output 13feb93py |
|
|
DEFER type \ defer type for a output buffer or fast |
Defer type \ defer type for a output buffer or fast |
\ screen write |
\ screen write |
|
|
\ : (type) ( addr len -- ) |
\ : (type) ( addr len -- ) |
\ bounds ?DO I c@ emit LOOP ; |
\ bounds ?DO I c@ emit LOOP ; |
|
|
' (TYPE) IS Type |
' (type) IS Type |
|
|
DEFER Emit |
Defer emit |
|
|
' (Emit) IS Emit |
' (Emit) IS Emit |
|
|
|
Defer key |
|
' (key) IS key |
|
|
\ : form ( -- rows cols ) &24 &80 ; |
\ : form ( -- rows cols ) &24 &80 ; |
\ form should be implemented using TERMCAPS or CURSES |
\ form should be implemented using TERMCAPS or CURSES |
\ : rows form drop ; |
\ : rows form drop ; |
Line 1080 DEFER Emit
|
Line 1086 DEFER Emit
|
\ Query 07apr93py |
\ Query 07apr93py |
|
|
: refill ( -- flag ) |
: refill ( -- flag ) |
|
blk @ IF 1 blk +! true EXIT THEN |
tib /line |
tib /line |
loadfile @ ?dup |
loadfile @ ?dup |
IF \ dup file-position throw linestart 2! |
IF read-line throw |
read-line throw |
|
ELSE loadline @ 0< IF 2drop false EXIT THEN |
ELSE loadline @ 0< IF 2drop false EXIT THEN |
accept true |
accept true |
THEN |
THEN |
1 loadline +! |
1 loadline +! |
swap #tib ! 0 >in ! ; |
swap #tib ! 0 >in ! ; |
|
|
: Query ( -- ) 0 loadfile ! refill drop ; |
: Query ( -- ) loadfile off blk off refill drop ; |
|
|
\ File specifiers 11jun93jaw |
\ File specifiers 11jun93jaw |
|
|
Line 1119 create nl$ 1 c, A c, 0 c, \ gnu includes
|
Line 1125 create nl$ 1 c, A c, 0 c, \ gnu includes
|
\ include-file 07apr93py |
\ include-file 07apr93py |
|
|
: push-file ( -- ) r> |
: push-file ( -- ) r> |
( linestart 2@ >r >r ) loadline @ >r loadfile @ >r |
loadline @ >r loadfile @ >r |
blk @ >r >tib @ >r #tib @ dup >r >tib +! >in @ >r >r ; |
blk @ >r >tib @ >r #tib @ dup >r >tib +! >in @ >r >r ; |
|
|
: pop-file ( -- ) r> |
: pop-file ( throw-code -- throw-code ) |
r> >in ! r> #tib ! r> >tib ! r> blk ! |
dup IF |
r> loadfile ! r> loadline ! ( r> r> linestart 2! ) >r ; |
source >in @ loadline @ loadfilename 2@ |
|
error-stack dup @ dup 1+ |
|
max-errors 1- min error-stack ! |
|
6 * cells + cell+ |
|
5 cells bounds swap DO |
|
I ! |
|
-1 cells +LOOP |
|
THEN |
|
r> |
|
r> >in ! r> #tib ! r> >tib ! r> blk ! |
|
r> loadfile ! r> loadline ! >r ; |
|
|
|
: read-loop ( i*x -- j*x ) |
|
BEGIN refill WHILE interpret REPEAT ; |
|
|
: include-file ( i*x fid -- j*x ) |
: include-file ( i*x fid -- j*x ) |
push-file loadfile ! |
push-file loadfile ! |
0 loadline ! blk off |
0 loadline ! blk off ['] read-loop catch |
BEGIN refill WHILE interpret REPEAT |
loadfile @ close-file swap |
loadfile @ close-file throw |
pop-file throw throw ; |
pop-file ; |
|
|
|
: included ( i*x addr u -- j*x ) |
: included ( i*x addr u -- j*x ) |
loadfilename 2@ >r >r |
loadfilename 2@ >r >r |
Line 1176 create nl$ 1 c, A c, 0 c, \ gnu includes
|
Line 1194 create nl$ 1 c, A c, 0 c, \ gnu includes
|
push-file dup #tib ! >tib @ swap move |
push-file dup #tib ! >tib @ swap move |
>in off blk off loadfile off -1 loadline ! |
>in off blk off loadfile off -1 loadline ! |
|
|
BEGIN interpret >in @ #tib @ u>= UNTIL |
\ BEGIN interpret >in @ #tib @ u>= UNTIL |
|
['] interpret catch |
pop-file ; |
pop-file throw ; |
|
|
|
|
: abort -1 throw ; |
: abort -1 throw ; |
Line 1196 Defer .status
|
Line 1214 Defer .status
|
|
|
\ DOERROR (DOERROR) 13jun93jaw |
\ DOERROR (DOERROR) 13jun93jaw |
|
|
|
8 Constant max-errors |
|
Variable error-stack 0 error-stack ! |
|
max-errors 6 * cells allot |
|
\ format of one cell: |
|
\ source ( addr u ) |
|
\ >in |
|
\ line-number |
|
\ Loadfilename ( addr u ) |
|
|
: dec. ( n -- ) |
: dec. ( n -- ) |
\ print value in decimal representation |
\ print value in decimal representation |
base @ decimal swap . base ! ; |
base @ decimal swap . base ! ; |
|
|
: typewhite ( addr u -- ) |
: typewhite ( addr u -- ) |
\ like type, but white space is printed instead of the characters |
\ like type, but white space is printed instead of the characters |
0 ?do |
bounds ?do |
dup i + c@ 9 = if \ check for tab |
i c@ 9 = if \ check for tab |
9 |
9 |
else |
else |
bl |
bl |
then |
then |
emit |
emit |
loop |
loop |
drop ; |
; |
|
|
DEFER DOERROR |
DEFER DOERROR |
|
|
|
: .error-frame ( addr1 u1 n1 n2 addr2 u2 -- ) |
|
cr error-stack @ |
|
IF |
|
." in file included from " |
|
type ." :" dec. drop 2drop |
|
ELSE |
|
type ." :" dec. |
|
cr dup 2over type cr drop |
|
nip -trailing ( line-start index2 ) |
|
0 >r BEGIN |
|
1- 2dup + c@ bl > WHILE |
|
r> 1+ >r dup 0< UNTIL THEN 1+ |
|
( line-start index1 ) |
|
typewhite |
|
r> 1 max 0 ?do \ we want at least one "^", even if the length is 0 |
|
[char] ^ emit |
|
loop |
|
THEN |
|
; |
|
|
: (DoError) ( throw-code -- ) |
: (DoError) ( throw-code -- ) |
LoadFile @ |
loadline @ IF |
IF |
source >in @ loadline @ 0 0 .error-frame |
cr loadfilename 2@ type ." :" Loadline @ dec. |
THEN |
THEN |
error-stack @ 0 ?DO |
cr source type cr |
-1 error-stack +! |
source drop >in @ -trailing ( throw-code line-start index2 ) |
error-stack dup @ 6 * cells + cell+ |
here c@ 1F min dup >r - 0 max ( throw-code line-start index1 ) |
6 cells bounds DO |
typewhite |
I @ |
r> 1 max 0 ?do \ we want at least one "^", even if the length is 0 |
cell +LOOP |
." ^" |
.error-frame |
loop |
LOOP |
dup -2 = |
dup -2 = |
IF |
IF |
"error @ ?dup |
"error @ ?dup |
IF |
IF |
cr count type |
cr count type |
THEN |
THEN |
drop |
drop |
ELSE |
ELSE |
.error |
.error |
THEN |
THEN |
normal-dp dpp ! ; |
normal-dp dpp ! ; |
|
|
' (DoError) IS DoError |
' (DoError) IS DoError |
|
|