Add input stream stack

This commit is contained in:
Koichi Nakamura 2021-01-04 16:14:14 +09:00
parent 81f07797dc
commit 9be13d26ce

View file

@ -1429,3 +1429,29 @@ W/O stdout_ file>fam c!
\ do nothing \ do nothing
:noname drop success ; stdout_ file>flush ! :noname drop success ; stdout_ file>flush !
( === Input Stream === )
\ input stream stack
struct
cell% field input>next
cell% field input>file
cell% field input>lineno
end-struct input%
variable input-streams
0 input-streams !
: push-input-stream ( file -- )
input% %allot \ addr
swap over input>file !
0 over input>lineno !
input-streams @ over input>next !
input-streams !
;
: pop-input-stream ( -- )
input-streams @ input-streams !
;
stdin_ push-input-stream