1 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;; and now
for something completely different
...
3 ;; UrForth
/C Forth Engine
!
4 ;; Copyright
(C
) 2023 Ketmar Dark
// Invisible Vector
6 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 \ VOCABULARY
($CC
-EVAL
)
10 ALSO
($CC
-EVAL
) DEFINITIONS
13 : PARSE
-NEXT
-WORD
( -- )
15 PARSE
-SKIP
-COMMENTS BL PARSE
17 REFILL
" unexpected end of file" ?NOT
-ERROR
19 TO CURR
-WORD
-LEN
TO CURR
-WORD
-ADDR
20 \
." |" CURR
-WORD XTYPE
." |\n"
23 : $SKIP
-CONDS
-FORTH
( toelse
-- )
24 0 >R
( toelse | level
)
27 FALSE
( toelse done? | level
)
28 CURR
-WORD
" [IF]" STRING
:=CI
IF DROP R
> 1+ >R FALSE
ENDIF
29 CURR
-WORD
" [ENDIF]" STRING
:=CI
30 CURR
-WORD
" [THEN]" STRING
:=CI OR
32 ;; in nested ifs
, look only
for $
ENDIF
35 ;; it doesn
't matter which part we're skipping
, it ends here anyway
39 CURR
-WORD
" [ELSE]" STRING
:=CI
IF DROP
40 ;; if we
're skipping "true" part, go on
42 $IF-COUNT 1+ TO $IF-COUNT
45 ;; we're skipping
"false" part
, there should be no
else
46 " unexpected [ELSE]" ERROR
51 R
> 0<> " oops?" ?ERROR
54 : $PROCESS
-COND
-FORTH
( cond
-- )
55 IF $
IF-COUNT
1+ TO $
IF-COUNT
56 ELSE TRUE $SKIP
-CONDS
-FORTH
64 ($CC
-EVAL
):$PROCESS
-COND
-FORTH
68 ($CC
-EVAL
):$
IF-COUNT
" unexpected [ELSE]" ?NOT
-ERROR
69 FALSE
($CC
-EVAL
):$SKIP
-CONDS
-FORTH
73 ($CC
-EVAL
):$
IF-COUNT
" unexpected [ENDIF]" ?NOT
-ERROR
74 ($CC
-EVAL
):$
IF-COUNT
1- TO ($CC
-EVAL
):$
IF-COUNT
78 ($CC
-EVAL
):$
IF-COUNT
" unexpected [THEN]" ?NOT
-ERROR
79 ($CC
-EVAL
):$
IF-COUNT
1- TO ($CC
-EVAL
):$
IF-COUNT