Index: user/crc/eval.rx =================================================================== --- user/crc/eval.rx +++ user/crc/eval.rx @@ -5,32 +5,30 @@ ( Evaluate A String ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) {{ variable count variable buffer : restore ( - ) - &emit :devector - &key :devector ok ; + &putc :devector + &getc :devector ok ; : get ( -c ) @buffer @ ; : next ( -c ) - @count 0 =if 32 restore ;then - count -- get buffer ++ ; + @count 0 = [ 32 restore ] [ count -- get buffer ++ ] if ; : replace ( - ) - &drop &emit :is - &next &key :is ; + &drop &putc :is + &next &getc :is ; ---reveal--- - : eval ( an- ) !count !buffer replace ; + : eval ( $- ) withLength !count !buffer replace ; }} ( Conditional Execution ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) {{ - : defined ( "-f ) 32 accept tib find nip ; - : evalTib ( - ) tib withLength eval ; + : defined ( "-f ) getToken find nip ; + : evalTib ( - ) tib eval ; : error ( - ) "Invalid Syntax\n" puts ; : read ( - ) '} accept ; - : block ( "- ) '{ key over =if emit read else drop error then ; + : block ( "- ) '{ getc dup emit space = [ getc read ] [ error ] if ; : evalBlock ( "- ) block evalTib ; - : ifBlock ( f"- ) if evalBlock ;then block ; + : ifBlock ( f"- ) &evalBlock &block if ; ---reveal--- : ifDefined ( "- ) defined ifBlock ; : ifNotDefined ( "- ) defined not ifBlock ; }} - Index: user/crc/marker.rx =================================================================== --- user/crc/marker.rx +++ user/crc/marker.rx @@ -5,7 +5,7 @@ {{ : restore ( a- ) @+ !heap @ !last ; : name ( -a ) "---marker---" ; ---reveal--- : marker ( - ) @last here name header &restore reclass , , ; - : empty ( - ) name find if @d->xt restore else drop then marker ; + : empty ( - ) name find [ @d->xt restore ] &drop if marker ; }} Index: user/crc/patengi.retro =================================================================== --- user/crc/patengi.retro +++ user/crc/patengi.retro @@ -1,22 +1,21 @@ -chain: db::core +chain: db::core' ( --- tools for dealing with lists --- ) - : deep ( an-a) 0; for @ next ; + : deep ( an-a) 0; &@ times ; : deepest ( a-a ) repeat dup @ 0; nip again ; : link, ( a- ) here 0 , swap deepest ! ; : prop ( a"-a) @last swap !last ' swap !last ; - : after ( a-a ) last repeat 2over @ =if nip ;then @ 0; again ; ( --- tables: fields/offsets, rows/links, etc. --- ) 2 elements table row : save ( "- ) @table constant ; : load ( a- ) @dup !row !table ; : link @table ; ( least recent row added ) - : size link 1+ ; ( number of fields ) - : head size 1+ ; ( header for last field ) + : size link 1+ ; ( number of fields ) + : head size 1+ ; ( header for last field ) : fields - @last swap dup for ' create r , , next + @last swap dup [ ' create swap , , ] iter here !table 0 , , @last , !last ; : f:num @ ; : f:xt f:num @row + @ ; : f:fun 1+ @ ; : f:pair dup f:xt swap f:fun ; @@ -23,32 +22,32 @@ : num:f @head swap 1- deep @d->xt ; : name:f @head prop ; : row, ( a- ) here !row link link, @size allot ; : insert ( n"- ) name:f f:num @row + ! ; : nwhere ( n- ) @link swap deep !row ; - : 3dup dup push push 2dup pop -rot pop ; + : 3dup dup [ 2over &-rot dip ] dip ; : match? ( ana- ) 3dup + @ compare ; : where ( a"- ) name:f f:num @link - repeat match? if !row drop ;then @ again ; + repeat match? [ !row drop 0 ] ifTrue 0; @ again ; : select ( "- ) name:f f:xt ; - : select-list ( n"- ) for name:f f:pair cr with-class next ; - : select-all ( - ) @size for r num:f f:pair cr with-class next ; + : select-list ( n"- ) [ name:f f:pair cr withClass ] times ; + : select-all ( - ) @size [ num:f f:pair cr withClass ] iter ; ;chain -with db::core +with db::core' -chain: db::io +chain: db::io' ( --- output types --- ) - : chars for @+ emit next ; - : string: .data ` type ; immediate - : num: .data ` . ; immediate + : chars [ @+ putc ] times ; + : string: .data ` puts ; immediate + : num: .data ` putn ; immediate ( --- input methods --- ) - : keep: here repeat key dup '~ =if drop 0 , ;then dup emit , again ; + : keep: here repeat getc dup '~ = [ drop 0 , 0 ] ifTrue 0; dup putc , again ; : number: here swap , ; ;chain -with db::io +with db::io' ( --- example table --- ) 5 fields string: title string: author string: genre string: series num: year save books