Changeset 391
- Timestamp:
- 05/19/07 05:57:36 (18 months ago)
- Location:
- trunk/thune
- Files:
-
- 2 modified
-
parse.c (modified) (8 diffs)
-
tests/working/parse_block.t (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/thune/parse.c
r329 r391 608 608 609 609 610 #define CHECK_WORD(cell) \ 611 if( ! cell ) { \ 612 pe->error = PARSE_EX_ERROR; \ 613 return 0; } 614 610 615 /* 611 616 Returns zero if matching rule not found or exception occured. … … 718 723 { 719 724 tval = ur_wordCell( pe->thread, rit ); 725 CHECK_WORD( tval ) 720 726 } 721 727 } … … 760 766 break; 761 767 768 case UR_ATOM_SET: 769 ++rit; 770 if( rit == rend ) 771 goto unexpected_end; 772 if( ! ur_is(rit, UT_WORD) ) 773 { 774 ur_throwErr( PARSE_EX, "parse set expected word" ); 775 pe->error = PARSE_EX_ERROR; 776 return 0; 777 } 778 { 779 UCell* cell = ur_wordCell( pe->thread, rit ); 780 CHECK_WORD( cell ) 781 ur_copyCell( cell, iblk->ptr.cells[ pos ] ); 782 } 783 ++rit; 784 break; 785 762 786 //case UR_ATOM_COPY: 763 787 … … 765 789 { 766 790 tval = ur_wordCell( pe->thread, rit ); 791 CHECK_WORD( tval ) 767 792 768 793 if( ur_is(tval, UT_BLOCK) ) … … 785 810 UCell* cell; 786 811 cell = ur_wordCell( pe->thread, rit ); 812 CHECK_WORD( cell ) 787 813 ++rit; 788 814 … … 798 824 UCell* cell; 799 825 cell = ur_wordCell( pe->thread, rit ); 826 CHECK_WORD( cell ) 800 827 ++rit; 801 828 … … 902 929 if( rit == rend ) 903 930 { 931 unexpected_end: 904 932 ur_throwErr( PARSE_EX, "Enexpected end of parse rule" ); 905 933 pe->error = PARSE_EX_ERROR; … … 913 941 { 914 942 tval = ur_wordCell( pe->thread, rit ); 943 CHECK_WORD( tval ) 915 944 } 916 945 else -
trunk/thune/tests/working/parse_block.t
r178 r391 10 10 prog [some[ 11 11 'min :a int! (["Minimum:" a/1] print) 12 | 'max :a [int! | decimal!] (["Maximum:" a/1] print)12 | 'max set a [int! | decimal!] (["Maximum:" a] print) 13 13 | 'fire :a word! (["Fired:" a/1] print) 14 14 | 'range :a int! int! (["Range:" a/1 "-" a/2] print)
