mirror of
https://github.com/nineties/planckforth
synced 2024-12-26 21:58:42 +01:00
rewrite existing parsers
This commit is contained in:
parent
ea1a3eeba2
commit
b2c60e43f2
1 changed files with 66 additions and 0 deletions
66
bootstrap.fs
66
bootstrap.fs
|
@ -1492,4 +1492,70 @@ variable inputstreams
|
|||
|
||||
stdin_ push-inputstream
|
||||
|
||||
\ Rewrite existing functions that reads input using inputstream.
|
||||
|
||||
: key ( -- c )
|
||||
inputstreams @ input>file @ key-file
|
||||
;
|
||||
|
||||
: word ( -- c-addr )
|
||||
inputstreams @ input>file @
|
||||
\ skip leading spaces
|
||||
0
|
||||
begin
|
||||
drop
|
||||
dup key-file \ ( file c )
|
||||
dup bl <> over '\n' <> and
|
||||
until
|
||||
word-buffer tuck c!
|
||||
1+
|
||||
begin
|
||||
\ ( file p )
|
||||
over key-file
|
||||
dup bl = over '\n' = or if
|
||||
drop
|
||||
0 swap c! \ store \0
|
||||
drop
|
||||
word-buffer exit
|
||||
then
|
||||
over c!
|
||||
1+
|
||||
again
|
||||
;
|
||||
|
||||
: ' ( "name" -- xt ) word find >cfa ;
|
||||
|
||||
: : ( "name -- )
|
||||
align
|
||||
here latest , &latest !
|
||||
word dup strlen
|
||||
smudge-bit or c,
|
||||
strcpy,
|
||||
align
|
||||
docol ,
|
||||
]
|
||||
;
|
||||
|
||||
: ; ( -- )
|
||||
align
|
||||
compile exit
|
||||
latest cell + dup c@
|
||||
smudge-bit invert and swap c!
|
||||
[compile] [
|
||||
; immediate
|
||||
|
||||
: create ( "name" -- )
|
||||
align
|
||||
here latest , &latest !
|
||||
word dup strlen c, strcpy,
|
||||
align
|
||||
docol ,
|
||||
compile lit
|
||||
here 3 cells + ,
|
||||
compile nop
|
||||
compile exit
|
||||
;
|
||||
|
||||
: char ( "ccc" -- c ) word c@ ;
|
||||
|
||||
." Ready" cr
|
||||
|
|
Loading…
Reference in a new issue