etherforth_logo

Node 409

This node receives words from command line as a stream of symbols, ended with a negative flag (eow). Based on first symbol in a word we process the stream as a number or a command.

Source code

editor node 509 node 410 node 309 node 408 node 409
409 parse
ok 00 12028 ok !b ;
?com 02 up a! 1001D com ! r--u ;
err 07 1202C err !b ?com ;
com 0A ok ?com ;
num 0C c down a! 1001C num! ! begin ! @b -until
@ .. -if 12022 sink !b err ; then 15555 ; !b ;
word 18 c left a! begin ! @b -until ! 12022 sink !b --l- ;
/str 1E c -10 over . + -if drop num ; then drop word ;
num@ 23 -n down a! 12027 num@ ! @ ;
ex0 27 i ok up a! ! r--u ;
ex1 2B ni up ok a! ! @p . @p !p .. ! ! .. r--u ;
interp 31 12024 cmds !b down a!
parse 35 @b -if com ; then /str parse ;
par 39 num@ par' 3A i @p !b !b ; @p ..
gate 3C ii !b !b r--u ; 3E

init down a! right b! r--u ; 43

1 r 1 d 0 ether

Definitions

ok
Call ok in 408.
?com
It is a common factor of com and err. Set A to UP, execute com in 209, and jump to RIGHT and UP.
err
Call err in 408 and jump to com?.
com
Call ok and jump to com?.
num
Process numbers. Start with the first character c in T. Set A to DOWN, call num! and send characters to 509 until eow, which is sent to 509. Then wait for reply from 509; negative flag is error, call sink in 408 and jump to err. Else send return instruction to 408 and return to parse.
word
Process commands. Start with the first character c in T. Set A to LEFT and pass all characters to 410 until eow, which is sent to 410, then call sink because only the first command encountered is processed. This allows to flag unknown command with red tag and leave it in command line buffer. Finally, jump to LEFT.
/str
If c is a digit jump to num, else to word.
num@
Set A to DOWN, call num@ and read top item from stack in 509.
ex0
Call ok, set A to UP, pass instruction word from T to 209 and jump to RIGHT and UP.
ex1
Call ok, set A to UP, pass instruction word from T to 209, then send an argument n to 209, and jump to RIGHT and UP.
interp
Call cmds in 408, set A to DOWN and fall through to
parse
Read one symbol from 408 and if eol (negative flag) jump to com. Else call /str and jump back to parse if ever returned form /str.
par
Call num@ to get top stack item from 509 and push this value to stack in 408.
par'
Push value i on your stack to stack in 408.
gate
This word is used to execute commands in 508. Expects two instruction words on stack, send them to 408 (thus, the first word set starts with @p) and jump to RIGHT and UP.
init
Set registers A and B, and jump to RIGHT and UP.

Description