Changeset 392

Show
Ignore:
Timestamp:
05/19/07 05:58:46 (17 months ago)
Author:
krobillard
Message:

Thune - Implemented block parse 'set.

Location:
branches/thune/thread_safe
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/thune/thread_safe/parse.c

    r387 r392  
    606606 
    607607 
     608#define CHECK_WORD(cell) \ 
     609    if( ! cell ) { \ 
     610        pe->error = PARSE_EX_ERROR; \ 
     611        return 0; } 
     612 
    608613/* 
    609614   Returns zero if matching rule not found or exception occured. 
     
    717722                            { 
    718723                                tval = ur_wordCell( ut, rit ); 
     724                                CHECK_WORD( tval ) 
    719725                            } 
    720726                        } 
     
    759765                        break; 
    760766 
     767                    case UR_ATOM_SET: 
     768                        ++rit; 
     769                        if( rit == rend ) 
     770                            goto unexpected_end; 
     771                        if( ! ur_is(rit, UT_WORD) ) 
     772                        { 
     773                            ur_throwErr( PARSE_EX, "parse set expected word" ); 
     774                            pe->error = PARSE_EX_ERROR; 
     775                            return 0; 
     776                        } 
     777                        { 
     778                        UCell* cell = ur_wordCell( ut, rit ); 
     779                        CHECK_WORD( cell ) 
     780                        ur_copyCell( cell, iblk->ptr.cells[ pos ] ); 
     781                        } 
     782                        ++rit; 
     783                        break; 
     784 
    761785                    //case UR_ATOM_COPY: 
    762786 
     
    764788                    { 
    765789                        tval = ur_wordCell( ut, rit ); 
     790                        CHECK_WORD( tval ) 
    766791 
    767792                        if( ur_is(tval, UT_BLOCK) ) 
     
    784809                UCell* cell; 
    785810                cell = ur_wordCell( ut, rit ); 
     811                CHECK_WORD( cell ) 
    786812                ++rit; 
    787813 
     
    797823                UCell* cell; 
    798824                cell = ur_wordCell( ut, rit ); 
     825                CHECK_WORD( cell ) 
    799826                ++rit; 
    800827 
     
    903930    if( rit == rend ) 
    904931    { 
     932unexpected_end: 
    905933        ur_throwErr( PARSE_EX, "Enexpected end of parse rule" ); 
    906934        pe->error = PARSE_EX_ERROR; 
     
    914942        { 
    915943            tval = ur_wordCell( ut, rit ); 
     944            CHECK_WORD( tval ) 
    916945        } 
    917946        else 
  • branches/thune/thread_safe/tests/working/parse_block.t

    r178 r392  
    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)