1 \ @(#) quit.fth 98/01/26 1.2
2 \ Outer Interpreter in Forth
4 \ This used so that THROW can be caught by QUIT.
7 \ Copyright 1994 3DO, Phil Burk, Larry Polansky, Devid Rosenboom
9 \ The pForth software code is dedicated to the public domain,
10 \ and any third party may reproduce, distribute and modify
11 \ the pForth software code or any derivative works thereof
12 \ without any compensation or license. The pForth software
13 \ code is provided on an "as is" basis without any warranty
14 \ of any kind, including, without limitation, the implied
15 \ warranties of merchantability and fitness for a particular
16 \ purpose and their equivalents under the laws of any jurisdiction.
18 include? catch catch.fth
22 : FIND&COMPILE ( $word -- {n} , find word in dictionary and handle it )
23 dup >r \ save in case needed
24 find ( -- xt flag | $word 0 )
34 1 OF execute \ immediate, so execute regardless of STATE
38 number? \ is it a number?
40 IF ?literal \ compile it or leave it on stack
42 r@ count type ." is not recognized!!" cr
51 : CHECK.STACK \ throw exception if stack underflows
54 ." QUIT: Stack underflow!" cr
55 depth negate 0 \ restore depth
62 \ interpret whatever is in source
63 : INTERPRET ( ?? -- ?? )
65 >in @ source nip ( 1- ) < \ any input left? !!! is -1 needed?
73 dup local-compiler @ execute ( ?? -- ?? )
78 find&compile ( -- {n} , may leave numbers on stack )
87 : EVALUATE ( i*x c-addr num -- j*x , evaluate string of Forth )
88 \ save current input state and switch to pased in string
94 \ interpret the string
102 : POSTPONE ( <name> -- )
105 0 OF ." Postpone could not find " count type cr abort ENDOF
106 1 OF compile, ENDOF \ immediate
107 -1 OF (compile) ENDOF \ normal
121 : QUIT ( -- , interpret input until none left )
128 \ ." TIB = " source type cr
129 ['] interpret catch ?dup
131 ." Exception # " . cr
133 state @ 0= IF ok THEN