mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-29 13:21:01 +00:00
More Forth samples.
This commit is contained in:
42
samples/Forth/block.fth
Normal file
42
samples/Forth/block.fth
Normal file
@@ -0,0 +1,42 @@
|
||||
( Block words. )
|
||||
|
||||
variable blk
|
||||
variable current-block
|
||||
|
||||
: block ( n -- addr )
|
||||
current-block ! 0 ;
|
||||
|
||||
: buffer ( n -- addr )
|
||||
current-block ! 0 ;
|
||||
|
||||
\ evaluate (extended semantics)
|
||||
\ flush ( -- )
|
||||
|
||||
: load ( ... n -- ... )
|
||||
dup current-block !
|
||||
blk !
|
||||
save-input
|
||||
0 >in !
|
||||
blk @ block ''source ! 1024 ''#source !
|
||||
( interpret )
|
||||
restore-input ;
|
||||
|
||||
\ save-buffers ( -- )
|
||||
\ update ( -- )
|
||||
|
||||
( Block extension words. )
|
||||
|
||||
\ empty-buffers ( -- )
|
||||
|
||||
variable scr
|
||||
|
||||
: list ( n -- )
|
||||
dup scr !
|
||||
dup current-block !
|
||||
block 1024 bounds do i @ emit loop ;
|
||||
|
||||
\ refill (extended semantics)
|
||||
|
||||
: thru ( x y -- ) +1 swap do i load loop ;
|
||||
|
||||
\ \ (extended semantics)
|
||||
Reference in New Issue
Block a user