( It is pitch black. ) |10 @Console/vector $2 &read $5 &type $1 &write $1 &error $1 |c0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 |000 @line/buf $80 @rewrite $1 |100 @on-reset ( -> ) ;line/on-console .Console/vector DEO2 random/ BRK ( @|Compiler ) @line/on-console ( -> ) [ LIT2 0a -Console/read ] DEI ( | handlers ) NEQk ?{ /parse POP2 BRK } DUP ?{ POP2 BRK } / POP BRK @line/parse ( -- ) /find-spacer INCk ?/ POP JMP2r @line/is-spacer ( buf -- buf t ) LDZ2k LIT2 ":: NEQ2 ?{ INCk INC LDZ LIT "= NEQ ?{ #01 JMP2r } } #00 JMP2r @line/find-spacer ( -- index ) ,&ptr LDR .&buf &>l /is-spacer ?{ INC GTHk ?&>l POP #ff } NIP JMP2r @line/ ( -- ) [ LIT2 -&buf _&ptr ] STR [ LIT2 00 -&buf ] STZ JMP2r @line/ ( c -- ) [ LIT2 00 &ptr -&buf ] INCk ,&ptr STR STZ2 JMP2r @line/ ( spacer -- ) DUP ?{ POP ;acc/on-console .Console/vector DEO2 !/ } rules/ !/ ( @|Accumulator ) @acc/on-console ( -> ) .Console/read DEI DUP ?{ POP / BRK } /append BRK @acc/append ( c -- ) #00 [ LIT2 &dst =&buf-1 ] INC2k ,&dst STR2 STA2 JMP2r @acc/get-src ( -- src* ) [ LIT2 &src $2 ] JMP2r @acc/ ( str* -- str* ) &>wf LDAk DUP ?{ POP #00 /append !/ } /append INC2 !&>wf @acc/ ( -- ) ;&buf-1 ;&buf-2 [ LIT2 01 &flip $1 ] INCk ,&flip STR AND [ JMP SWP2 ] ,&src STR2 ,&dst STR2 /get-src !err/ @acc/ ( -- ) / &>we [ LIT2 00 -rewrite ] STZ / .rewrite LDZ ?&>we JMP2r @acc/ ( src* -- src* ) /get-src &>ws LDAk ?{ POP2 JMP2r } /match INC2 !&>ws @acc/match ( src* -- src* ) rules/find INC2k ORA ?{ POP2 LDAk !/append } ( | walk src ) LDA2k str/len ROT2 ADD2 SWP2 ( | replace ) [ LIT2 01 -rewrite ] STZ INC2 INC2 LDA2 ( | print ) LDAk [ LIT "~ ] NEQ ?{ INC2 str/ !/ } &>wa LDAk DUP ?{ POP POP2 !/ } /append INC2 !&>wa ( @|Rules ) @rules/find ( src* -- src* rule* ) STH2k shuffle/ ;&ptr LDA2 ;&buf &>lf LDA2k STH2kr /compare ?{ DUP2 shuffle/ } #0004 ADD2 GTH2k ?&>lf POP2 POP2 POP2r !shuffle/pull @rules/compare ( rule* src* -- t ) STH2 &>wc LDAk LDAkr STHr NEQ ?{ INC2 INC2r LDAk ?&>wc } POP2r LDA #00 NEQ JMP2r @rules/ ( spacer -- ) #00 OVR STZ ( rhs ) INC INC INC dict/alloc ( lhs ) .line/buf dict/alloc [ LIT2 &ptr =&buf ] STH2k STA2 INC2r INC2r STH2kr STA2 INC2r INC2r [ LITr _&ptr ] STR2r JMP2r @shuffle/ ( -- ) ;&buf ,&ptr STR2 JMP2r @shuffle/ ( rule* -- ) [ LIT2 &ptr =&buf ] INC2k INC2 ,&ptr STR2 STA2 JMP2r @shuffle/pull ( -- rule* ) ,&ptr LDR2 ;&buf EQU2k ?{ ( grab count ) SUB2 #01 SFT2 ( find random ) random/generate SWP2 DIV2k MUL2 SUB2 ( pull rule ) DUP2 ADD2 ;&buf ADD2 LDA2 JMP2r } POP2 POP2 #ffff JMP2r ( @|Dict ) @dict/alloc ( str -- addr* ) ,&ptr LDR2 ROT &>w LDZk DUP ?{ POP2 #00 !/ } / INC !&>w @dict/ ( c -- ) #00 [ LIT2 &ptr =&buf ] INC2k ,&ptr STR2 STA2 JMP2r ( @|Random ) @random/ ( -- ) ( ) [ LIT2 00 -DateTime/second ] DEI ( ) [ LIT2 00 -DateTime/minute ] DEI #60 SFT2 EOR2 ( ) [ LIT2 00 -DateTime/hour ] DEI #c0 SFT2 EOR2 ,&x STR2 ( ) [ LIT2 00 -DateTime/hour ] DEI #04 SFT2 ( ) [ LIT2 00 -DateTime/day ] DEI DUP2 ADD2 EOR2 ( ) [ LIT2 00 -DateTime/month ] DEI #60 SFT2 EOR2 ( ) .DateTime/year DEI2 #a0 SFT2 EOR2 ,&y STR2 JMP2r @random/generate ( -- number* ) ( ) [ LIT2 &x $2 ] DUP2 #50 SFT2 EOR2 DUP2 #03 SFT2 EOR2 ( ) [ LIT2 &y $2 ] DUP2 ,&x STR2 DUP2 #01 SFT2 EOR2 EOR2 ,&y STR2k POP JMP2r ( @|Utils ) @str/ ( str* -- ) &>wp LDAk DUP ?{ POP POP2 JMP2r } DUP [ LIT "\ ] NEQ ?{ POP INC2 LDAk chr/escape } .Console/write DEO INC2 !&>wp @str/len ( str* -- length* ) DUP2 /cap SWP2 INC2 SUB2 JMP2r @str/cap ( str* -- end* ) LDAk ?{ INC2 JMP2r } INC2 !/cap @err/ ( str* -- ) &>wp LDAk DUP ?{ POP POP2 JMP2r } .Console/error DEO INC2 !&>wp @chr/escape ( byte -- byte ) DUP [ LIT "t ] NEQ ?{ POP #09 JMP2r } [ LIT "n ] NEQ ?{ #0a JMP2r } #20 JMP2r @dict/buf $1000 @rules/buf $200 @shuffle/buf $100 @acc/buf-1 $6000 &buf-2