Changeset 391

Show
Ignore:
Timestamp:
05/19/07 05:57:36 (18 months ago)
Author:
krobillard
Message:

Thune - Implemented block parse 'set.

Location:
trunk/thune
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/thune/parse.c

    r329 r391  
    608608 
    609609 
     610#define CHECK_WORD(cell) \ 
     611    if( ! cell ) { \ 
     612        pe->error = PARSE_EX_ERROR; \ 
     613        return 0; } 
     614 
    610615/* 
    611616   Returns zero if matching rule not found or exception occured. 
     
    718723                            { 
    719724                                tval = ur_wordCell( pe->thread, rit ); 
     725                                CHECK_WORD( tval ) 
    720726                            } 
    721727                        } 
     
    760766                        break; 
    761767 
     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 
    762786                    //case UR_ATOM_COPY: 
    763787 
     
    765789                    { 
    766790                        tval = ur_wordCell( pe->thread, rit ); 
     791                        CHECK_WORD( tval ) 
    767792 
    768793                        if( ur_is(tval, UT_BLOCK) ) 
     
    785810                UCell* cell; 
    786811                cell = ur_wordCell( pe->thread, rit ); 
     812                CHECK_WORD( cell ) 
    787813                ++rit; 
    788814 
     
    798824                UCell* cell; 
    799825                cell = ur_wordCell( pe->thread, rit ); 
     826                CHECK_WORD( cell ) 
    800827                ++rit; 
    801828 
     
    902929    if( rit == rend ) 
    903930    { 
     931unexpected_end: 
    904932        ur_throwErr( PARSE_EX, "Enexpected end of parse rule" ); 
    905933        pe->error = PARSE_EX_ERROR; 
     
    913941        { 
    914942            tval = ur_wordCell( pe->thread, rit ); 
     943            CHECK_WORD( tval ) 
    915944        } 
    916945        else 
  • trunk/thune/tests/working/parse_block.t

    r178 r391  
    1010prog [some[ 
    1111      '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) 
    1313    | 'fire :a word!             (["Fired:"   a/1] print) 
    1414    | 'range :a int! int!        (["Range:" a/1 "-" a/2] print)