Show
Ignore:
Timestamp:
08/19/07 18:31:07 (15 months ago)
Author:
krobillard
Message:

Tokenizer handles special char!.
ur_toStrT() now thread-safe for char! values.
Fixed Vim char! syntax.

Files:
1 modified

Legend:

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

    r451 r452  
    3131 
    3232extern void ur_bindDefault( UThread*, UIndex blkN ); 
     33extern int  ur_escapedCharacter( const char** cp, const char* end ); 
    3334 
    3435 
     
    546547quote: 
    547548 
    548     if( ((end - it) > 1) && it[1] == '\'' ) 
    549     { 
    550         cell = ur_appendCell( BLOCK, UT_CHAR ); 
    551         ur_int(cell) = token[1]; 
    552         it += 2; 
    553         goto set_eol; 
    554     } 
    555  
    556549    mode = UT_LITWORD; 
    557550 
    558551    SCAN_LOOP 
    559         if( ch == '/' ) 
     552        if( ch == '\'' ) 
     553        { 
     554            mode = UT_CHAR; 
     555            break; 
     556        } 
     557        else if( ch == '/' ) 
    560558        { 
    561559            mode = UT_LITSELECT; 
     
    563561        else if( ur_bitIsSet( charset_delimiters, ch ) )   // '[' 'word[] 
    564562        { 
     563            if( it == (token + 1) ) 
     564            { 
     565                ++it; 
     566                if( (it != end) && (*it == '\'') ) 
     567                    goto make_char; 
     568                goto quote_err; 
     569            } 
    565570            break; 
    566571        } 
     
    572577        if( it == token ) 
    573578            goto quote_err; 
    574         if( mode == UT_LITWORD ) 
     579 
     580        if( mode == UT_CHAR ) 
     581        { 
     582            ch = *token; 
     583            if( ch == '^' ) 
     584            { 
     585                ++token; 
     586                ch = ur_escapedCharacter( &token, it ); 
     587                if( ch < 0 ) 
     588                { 
     589                    syntaxError( "Invalid char" ); 
     590                } 
     591            } 
     592make_char: 
     593            ++it; 
     594            cell = ur_appendCell( BLOCK, UT_CHAR ); 
     595            ur_int(cell) = ch; 
     596        } 
     597        else if( mode == UT_LITWORD ) 
    575598        { 
    576599            cell = ur_appendWord( BLOCK, UT_LITWORD, token, it - token ); 
     
    632655        { 
    633656            mode = WORD_COLON; 
    634             break; 
    635         } 
    636         if( ch == '\'' ) 
    637         { 
    638             mode = UT_CHAR; 
    639657            break; 
    640658        }