mirror of
https://github.com/nineties/planckforth
synced 2024-12-27 21:58:35 +01:00
Add inner interpret loop
This commit is contained in:
parent
fbe4a77dc4
commit
ce31b9160e
1 changed files with 35 additions and 30 deletions
65
bootstrap.fs
65
bootstrap.fs
|
@ -1836,42 +1836,47 @@ stdin_ push-inputstream
|
||||||
: interpret
|
: interpret
|
||||||
word \ read name from input
|
word \ read name from input
|
||||||
|
|
||||||
\ EOF at this point is not an error
|
: interpret-inner
|
||||||
UNEXPECTED-EOF-ERROR = if QUIT throw then
|
begin
|
||||||
|
word \ read name from input
|
||||||
|
|
||||||
dup word-buffer strcpy \ save input
|
\ EOF at this point is not an error
|
||||||
dup find \ lookup dictionary
|
UNEXPECTED-EOF-ERROR = if QUIT throw then
|
||||||
?dup if
|
|
||||||
\ Found the word
|
dup word-buffer strcpy \ save input
|
||||||
nip
|
dup find \ lookup dictionary
|
||||||
state @ if
|
?dup if
|
||||||
\ compile mode
|
\ Found the word
|
||||||
dup cell+ c@ immediate-bit and if
|
nip
|
||||||
\ execute immediate word
|
state @ if
|
||||||
>cfa execute
|
\ compile mode
|
||||||
|
dup cell+ c@ immediate-bit and if
|
||||||
|
\ execute immediate word
|
||||||
|
>cfa execute
|
||||||
|
else
|
||||||
|
\ compile the word
|
||||||
|
>cfa ,
|
||||||
|
then
|
||||||
else
|
else
|
||||||
\ compile the word
|
\ immediate mode
|
||||||
>cfa ,
|
>cfa execute
|
||||||
then
|
then
|
||||||
else
|
else
|
||||||
\ immediate mode
|
>number unless
|
||||||
>cfa execute
|
UNDEFINED-WORD-ERROR throw
|
||||||
|
then
|
||||||
|
\ Not found
|
||||||
|
state @ if
|
||||||
|
\ compile mode
|
||||||
|
[compile] literal
|
||||||
|
then
|
||||||
then
|
then
|
||||||
else
|
again
|
||||||
>number unless
|
|
||||||
UNDEFINED-WORD-ERROR throw
|
|
||||||
then
|
|
||||||
\ Not found
|
|
||||||
state @ if
|
|
||||||
\ compile mode
|
|
||||||
[compile] literal
|
|
||||||
then
|
|
||||||
then
|
|
||||||
;
|
;
|
||||||
|
|
||||||
: interpret-loop
|
: interpret-outer
|
||||||
begin
|
begin
|
||||||
['] interpret catch
|
['] interpret-inner catch
|
||||||
?dup if
|
?dup if
|
||||||
\ lookup error code
|
\ lookup error code
|
||||||
dup QUIT = if throw then
|
dup QUIT = if throw then
|
||||||
|
@ -1902,7 +1907,7 @@ stdin_ push-inputstream
|
||||||
:noname
|
:noname
|
||||||
rp0 rp! \ drop 3rd stage
|
rp0 rp! \ drop 3rd stage
|
||||||
|
|
||||||
['] interpret-loop catch bye
|
['] interpret-outer catch bye
|
||||||
; execute
|
; execute
|
||||||
|
|
||||||
( === [if]..[else]..[then] === )
|
( === [if]..[else]..[then] === )
|
||||||
|
@ -2293,7 +2298,7 @@ need-defined (read)
|
||||||
: included ( c-addr -- )
|
: included ( c-addr -- )
|
||||||
R/O open-file throw
|
R/O open-file throw
|
||||||
push-inputstream
|
push-inputstream
|
||||||
['] interpret-loop catch drop
|
['] interpret-outer catch drop
|
||||||
pop-inputstream close-file throw
|
pop-inputstream close-file throw
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue