forked from jkotlinski/durexforth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make forth source compatible with both C64 and 128
immedif.fs contains implementations of immediate `[IF]` `[ELSE]` and `[THEN]` words that can be used for conditional compilation. This allows us to handle differences between C64 and C128 machines at compile time instead of runtime.
- Loading branch information
Showing
5 changed files
with
65 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
\ Immediate versions of if/else/then to | ||
\ allow conditional compilation. | ||
\ Supports nesting. | ||
|
||
header [if] ( -- ) immediate | ||
|
||
: [then] ( -- ) ; immediate | ||
|
||
: [else] ( -- ) | ||
\ consume and discard following words | ||
\ until a matching [else] or [then] is | ||
\ encountered | ||
1 begin | ||
begin parse-name dup while | ||
find-name case | ||
[ parse-name [if] find-name ] | ||
literal of | ||
1+ | ||
endof | ||
[ latest ] literal of | ||
1- | ||
dup if 1+ then | ||
endof | ||
[ parse-name [then] find-name ] | ||
literal of | ||
1- | ||
endof | ||
endcase | ||
?dup 0= if exit then | ||
repeat | ||
source nip drop 0= if refill then | ||
source nip drop 0= until | ||
drop | ||
; immediate | ||
|
||
define [if] ( flag -- ) | ||
0= if postpone [else] then | ||
; \ immediate flag set in header |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters