Changeset 141 for trunk/thune/make.c

Show
Ignore:
Timestamp:
05/06/06 04:54:25 (3 years ago)
Author:
krobillard
Message:

Thune - Implemented selector!

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/thune/make.c

    r129 r141  
    2525#include "os.h" 
    2626#include "internal.h" 
     27 
     28 
     29extern int ur_stringToInt( const char*, const char*, const char** ); 
     30extern double ur_stringToDec( const char*, const char*, const char** ); 
    2731 
    2832 
     
    472476 
    473477 
     478int ur_makeSelector( UCell* res, const char* spA, const char* end ) 
     479{ 
     480    const char* cp; 
     481    const char* sep = spA; 
     482    while( sep != end ) 
     483    { 
     484        if( *sep == '/' ) 
     485            break; 
     486        ++sep; 
     487    } 
     488    if( sep == end ) 
     489        return 0; 
     490 
     491    ur_setType( res, UT_SELECTOR ); 
     492 
     493    cp = sep + 1; 
     494    if( *cp >= '0' && *cp <= '9' ) 
     495    { 
     496        ur_selector(res) = ur_stringToInt( cp, end, 0 ); 
     497    } 
     498    else 
     499    { 
     500        res->id.flags |= UR_FLAG_SEL_ATOM; 
     501        ur_selector(res) = ur_intern( cp, end - cp ); 
     502    } 
     503 
     504    res->word.valBlk = GLOBAL_VAL_BLKN; 
     505    res->word.atom   = ur_intern( spA, sep - spA ); 
     506    res->word.index  = ur_internWord( &ur_global, res->word.atom ); 
     507 
     508    return 1; 
     509} 
     510 
     511 
     512/*--------------------------------------------------------------------------*/ 
     513 
     514 
    474515static void _makeContextProto( UContext* ctx, const UCell* proto ) 
    475516{ 
     
    580621 
    581622/*--------------------------------------------------------------------------*/ 
    582  
    583  
    584 extern int ur_stringToInt( const char*, const char*, const char** ); 
    585 extern double ur_stringToDec( const char*, const char*, const char** ); 
    586623 
    587624 
     
    649686                res->word.atom   = ur_intern( spA, spB - spA ); 
    650687                res->word.index  = ur_internWord( &ur_global, res->word.atom ); 
     688            } 
     689            break; 
     690 
     691        case UT_SELECTOR: 
     692            if( ur_stringSlice(tos, &spA, &spB) && spA ) 
     693            { 
     694                if( ! ur_makeSelector( res, spA, spB ) ) 
     695                    goto error; 
    651696            } 
    652697            break;