Changeset 503
- Timestamp:
- 01/21/08 16:21:29 (8 months ago)
- Location:
- trunk/thune
- Files:
-
- 11 modified
-
boot.c (modified) (1 diff)
-
doc/UserManual (modified) (2 diffs)
-
mkboot.t (modified) (1 diff)
-
tests/working/compare.t (modified) (3 diffs)
-
tests/working/control.good (modified) (1 diff)
-
tests/working/control.t (modified) (2 diffs)
-
tests/working/iter.good (modified) (1 diff)
-
tests/working/iter.t (modified) (1 diff)
-
tests/working/parse2.good (modified) (1 diff)
-
tests/working/parse2.t (modified) (1 diff)
-
thune.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/thune/boot.c
r502 r503 76 76 " forever drop\n" 77 77 "] 'loop func :loop.to\n" 78 "[ser words block! body block!]\n" 79 "[\n" 80 " ser [words set body do] words length? iter\n" 81 "]\n" 82 "'loop func :each.set ;(ser words body -- )\n" 78 83 "[ser accu op] [\n" 79 84 " ser [first accu op do :accu] iter\n" -
trunk/thune/doc/UserManual
r499 r503 365 365 iter (ser body -- ) Iterate over series. 366 366 iter/N (ser body -- ) Iterate over series with skip. 367 each (ser body -- ) Iterate over series elements. 368 each/N (ser body -- ) Iterate over series elements with skip. 367 369 proc (body -- proc) Create procedure. 368 370 func (sig body -- func) Create function with local values. … … 388 390 Word Stack Usage Function 389 391 ======== ========================= ============================ 390 each (ser body -- ) Iterate over series and take first element.391 392 each.set (ser words body -- ) Iterate over series and assign elements. 392 393 while (body cond -- ) Evaluate body while cond is true. -
trunk/thune/mkboot.t
r502 r503 86 86 ] 'loop func :loop.to 87 87 88 [ser words block! body block!] 89 [ 90 ser [words set body do] words length? iter 91 ] 92 'loop func :each.set ;(ser words body -- ) 93 88 94 [ser accu op] [ 89 95 ser [first accu op do :accu] iter -
trunk/thune/tests/working/compare.t
r502 r503 21 21 first :cmp 22 22 23 ;data [a b] [ 24 ; [a b dup2 cmp do] print 25 ;] each.set 26 27 data [ 28 [a b] set 23 data [a b] [ 29 24 [a b dup2 cmp do] print 30 ] iter/225 ] each.set 31 26 ] proc :test 32 27 … … 41 36 42 37 "--- if ---" print 43 data 44 ;[a b] 38 data [a b] 45 39 [ 46 [a b] set47 40 [a b ' ' 48 41 a b if/eq '= … … 54 47 ] print 55 48 ] 56 ;each.set 57 iter/2 49 each.set -
trunk/thune/tests/working/control.good
r502 r503 45 45 each "two" 46 46 each "tree" 47 --- each.set 0 --- 48 --- each.set 1 --- 49 1 50 2 51 a 52 b 53 one 54 two 55 tree 56 --- each.set 2 --- 57 1 2 58 a b 59 one two 60 tree none 61 --- each.set 3 --- 62 1 2 a 63 b one two 64 tree none none 65 --- each.set 8 --- 66 1 2 a b one two tree none 47 67 --- either --- 48 68 'T' -
trunk/thune/tests/working/control.t
r502 r503 27 27 28 28 29 /*30 29 "--- each.set 0 ---" print 31 30 data tail [a] [[a] print] each.set … … 42 41 "--- each.set 8 ---" print 43 42 data [a b c d e f g h] [[a b c d e f g h] print] each.set 44 */45 43 46 44 -
trunk/thune/tests/working/iter.good
r498 r503 19 19 [x] 20 20 --- Reverse empty --- 21 --- Skip on stack --- 22 "A-message" -
trunk/thune/tests/working/iter.t
r498 r503 25 25 [] [.] iter/-1 26 26 27 "--- Skip on stack ---" print 28 {} {A - m e s s a g e} [append] 2 each head . -
trunk/thune/tests/working/parse2.good
r502 r503 16 16 17 17 18 [words string! file string! rev logic! | rules a b ab--]18 [words string! file string! rev logic! | rules a b --] 19 19 [ 20 20 [] copy :rules 21 21 words parse.white 22 22 23 [[b a] [a b]] rev pick :ab23 [[b a] [a b]] rev pick 24 24 [ 25 ab set26 25 rules [a (b prin) |] copy 'a infuse append.cat tail prev mark.eol drop 27 26 ] 28 iter/227 each.set 29 28 30 29 file read -
trunk/thune/tests/working/parse2.t
r502 r503 16 16 17 17 18 [words string! file string! rev logic! | rules a b ab--]18 [words string! file string! rev logic! | rules a b --] 19 19 [ 20 20 [] copy :rules 21 21 words parse.white 22 22 23 [[b a] [a b]] rev pick :ab23 [[b a] [a b]] rev pick 24 24 [ 25 ab set26 25 rules [a (b prin) |] copy 'a infuse append.cat tail prev mark.eol drop 27 26 ] 28 iter/227 each.set 29 28 30 29 file read -
trunk/thune/thune.c
r502 r503 601 601 break; 602 602 603 case OP_ITER: // (series blk -- )603 case OP_ITER: // (series blk [skip] -- ) 604 604 case OP_EACH: 605 if( ur_is(UR_TOS, UT_BLOCK) && 606 (ur_itLen( ut, ur_s_prev(UR_TOS) ) > 0) ) 607 { 608 int itype = (ur_opcode(val) == OP_ITER) ? 605 { 606 int itype; 607 int skip; 608 609 if( ur_is(UR_TOS, UT_INT) ) 610 { 611 skip = ur_int(UR_TOS); 612 UR_S_DROP; 613 } 614 else 615 { 616 skip = ur_sel(val); 617 } 618 619 if( ! ur_is(UR_TOS, UT_BLOCK) ) 620 { 621 ur_throwErr( UR_ERR_DATATYPE, 622 "iter/each expected block! for body" ); 623 goto throw_cc; 624 } 625 626 if( ur_itLen( ut, ur_s_prev(UR_TOS) ) > 0 ) 627 { 628 itype = (ur_opcode(val) == OP_ITER) ? 609 629 CC_ITER : CC_EACH; 610 int skip = ur_sel(val);611 if( skip == 0 )612 skip = 1;613 630 614 631 PUSHC_EVAL( blkN, start, pc ); … … 620 637 //ur_copyCell( ut->toc, UR_TOS ); 621 638 UR_TOC->iter.code = itype; 622 UR_TOC->iter.skip = skip ;639 UR_TOC->iter.skip = skip ? skip : 1; 623 640 ut->toc->series.n = UR_TOS->series.n; 624 641 ut->toc->series.it = UR_TOS->series.it; … … 634 651 UR_S_DROPN(2); 635 652 } 653 } 636 654 break; 637 655
