748cbcfd72
FossilOrigin-Name: 4709c022b1cd034c0d12c01fe1ebce0185a6d14a53a2768fe9f134a6013d0f79
23 lines
509 B
Forth
23 lines
509 B
Forth
~~~
|
|
{{
|
|
:eol? (c-f)
|
|
[ ASCII:CR eq? ] [ ASCII:LF eq? ] [ ASCII:SPACE eq? ] tri or or ;
|
|
|
|
:valid? (s-sf)
|
|
dup s:length n:-zero? ;
|
|
|
|
:check-bs (c-c)
|
|
dup [ #8 eq? ] [ #127 eq? ] bi or [ buffer:get buffer:get drop-pair ] if ;
|
|
|
|
:c:get (-c) `1001 ;
|
|
|
|
:s:get (-s) [ #1025 buffer:set
|
|
[ c:get dup buffer:add check-bs eol? ] until
|
|
buffer:start s:chop ] buffer:preserve ;
|
|
|
|
:listen (-)
|
|
repeat s:get valid? &interpret &drop choose again ;
|
|
|
|
&listen #1 store
|
|
}}
|
|
~~~
|