Changeset 46 for trunk/orca

Show
Ignore:
Timestamp:
02/13/06 17:46:20 (3 years ago)
Author:
krobillard
Message:

Cleaned up parse code a bit.

Location:
trunk/orca
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/orca/ovalue.h

    r44 r46  
    485485 
    486486#define orType(val)     (val)->type 
    487 #define orInteger(val)  (val)->integer 
     487#define orAtom(val)     (val)->word.atom 
     488#define orInt(val)      (val)->integer 
    488489#define orLogic(val)    (val)->integer 
    489490#define orDecimal(val)  (val)->num.decimal 
  • trunk/orca/parse.c

    r42 r46  
    2424 
    2525 
     26#define OR_ATOM_OPT     orEnv->atom_opt 
     27#define OR_ATOM_SOME    orEnv->atom_some 
     28#define OR_ATOM_ANY     orEnv->atom_any 
     29#define OR_ATOM_BREAK   orEnv->atom_break 
     30#define OR_ATOM_SKIP    orEnv->atom_skip 
     31#define OR_ATOM_SET     orEnv->atom_set 
     32#define OR_ATOM_COPY    orEnv->atom_copy 
     33#define OR_ATOM_BAR     orEnv->atom_bar 
     34#define OR_ATOM_TO      orEnv->atom_to 
     35#define OR_ATOM_THRU    orEnv->atom_thru 
     36 
     37 
    2638extern int orMatchString( const OString* strA, int iA, 
    2739                          const OString* strB, int iB ); 
     
    3749    while( it != end ) 
    3850    { 
    39         if( (it->type == OT_WORD) && 
    40             (it->word.atom == orEnv->atom_bar) ) 
     51        if( orIs(it, OT_WORD) && (orAtom(it) == OR_ATOM_BAR) ) 
    4152        { 
    4253            return it + 1; 
     
    8596        { 
    8697            case OT_WORD: 
    87                 if( rit->word.atom == orEnv->atom_opt ) 
     98                if( orAtom(rit) == OR_ATOM_OPT ) 
    8899                { 
    89100                    const OValue* r2 = rit + 1; 
     
    97108                    rit += 2; 
    98109                } 
    99                 else if( rit->word.atom == orEnv->atom_any ) 
     110                else if( orAtom(rit) == OR_ATOM_ANY ) 
    100111                { 
    101112                    //until [not eval-pstr second it] 
     
    107118                        return 0; 
    108119 
    109                     if( r2->type == OT_WORD ) 
     120                    if( orIs(r2, OT_WORD) ) 
    110121                    { 
    111122                        OBlock* ctxBlk; 
     
    113124                    } 
    114125 
    115                     if( r2->type == OT_BITSET ) 
     126                    if( orIs(r2, OT_BITSET) ) 
    116127                    { 
    117128                        const uint8_t* it  = str->byteArray + pos; 
     
    129140                    } 
    130141                } 
    131                 else if( rit->word.atom == orEnv->atom_some ) 
     142                else if( orAtom(rit) == OR_ATOM_SOME ) 
    132143                { 
    133144                    const OValue* found; 
     
    138149                        return 0; 
    139150 
    140                     if( r2->type == OT_WORD ) 
     151                    if( orIs(r2, OT_WORD) ) 
    141152                    { 
    142153                        OBlock* ctxBlk; 
     
    144155                    } 
    145156 
    146                     if( r2->type == OT_BLOCK ) 
     157                    if( orIs(r2, OT_BLOCK) ) 
    147158                    { 
    148159                        OBlock* blk2; 
     
    169180                        } 
    170181                    } 
    171                     else if( r2->type == OT_BITSET ) 
     182                    else if( orIs(r2, OT_BITSET) ) 
    172183                    { 
    173184                        const uint8_t* it  = str->byteArray + pos; 
     
    193204                    } 
    194205                } 
    195                 else if( rit->word.atom == orEnv->atom_break ) 
     206                else if( orAtom(rit) == OR_ATOM_BREAK ) 
    196207                { 
    197208                    return rit; 
    198209                } 
    199                 else if( rit->word.atom == orEnv->atom_bar ) 
     210                else if( orAtom(rit) == OR_ATOM_BAR ) 
    200211                { 
    201212                    goto complete; 
    202213                } 
    203                 else if( rit->word.atom == orEnv->atom_to ) 
     214                else if( orAtom(rit) == OR_ATOM_TO ) 
    204215                { 
    205216                    int si; 
     
    224235                } 
    225236                /* 
    226                 else if( rit->word.atom == orEnv->atom_thru ) 
    227                 { 
    228                 } 
    229                 else if( rit->word.atom == orEnv->atom_skip ) 
    230                 { 
    231                 } 
    232                 else if( rit->word.atom == orEnv->atom_set ) 
    233                 { 
    234                 } 
    235                 else if( rit->word.atom == orEnv->atom_copy ) 
     237                else if( orAtom(rit) == OR_ATOM_THRU ) 
     238                { 
     239                } 
     240                else if( orAtom(rit) == OR_ATOM_SKIP ) 
     241                { 
     242                } 
     243                else if( orAtom(rit) == OR_ATOM_SET ) 
     244                { 
     245                } 
     246                else if( orAtom(rit) == OR_ATOM_COPY ) 
    236247                { 
    237248                } 
     
    244255                    orWordVal( rit, cblk, wval ); 
    245256 
    246                     if( wval->type == OT_BLOCK ) 
     257                    if( orIs(wval, OT_BLOCK) ) 
    247258                    { 
    248259                        cblk = orBLOCK( wval ); 
     
    255266                            goto failed_eval; 
    256267                    } 
    257                     else if( wval->type == OT_BITSET ) 
     268                    else if( orIs(wval, OT_BITSET) ) 
    258269                    { 
    259270                        OString* bin = orSTRING( wval ); 
     
    296307                    return 0; 
    297308 
    298                 if( r2->type == OT_INTEGER ) 
     309                if( orIs(r2, OT_INTEGER) ) 
    299310                { 
    300311                    int count = 0; 
    301                     int maxCount = r2->integer; 
     312                    int maxCount = orInt(r2); 
    302313 
    303314                    ++r2; 
     
    314325                    if( orErrorThrown ) 
    315326                        return 0; 
    316                     if( (count >= rit->integer) && (count <= maxCount) ) 
     327                    if( (count >= orInt(rit)) && (count <= maxCount) ) 
    317328                        rit += 3; 
    318329                    else 
     
    323334 
    324335            case OT_CHAR: 
    325                 if( str->charArray[ pos ] == rit->integer ) 
     336                if( str->charArray[ pos ] == orInt(rit) ) 
    326337                { 
    327338                    ++rit; 
     
    443454    (void) useCase; 
    444455 
     456    orRefAvailErr( 2 ); 
    445457    orRefPush( OT_STRING, ser->index ); 
    446458 
     
    450462    orRefPush( OT_BLOCK, rblkN ); 
    451463 
    452     if( rules->type == OT_STRING ) 
     464    if( orIs(rules, OT_STRING) ) 
    453465    { 
    454466        custom = orMakeCharset( orSTRING(rules), rules->series.it ); 
     
    533545{ 
    534546    OValue* rules = a1 + 1; 
    535     if( a1->type == OT_STRING ) 
     547    if( orIs(a1, OT_STRING) ) 
    536548    { 
    537549        int all     = orRefineSet(REF_PARSE_ALL) ? 1 : 0; 
    538550        int useCase = orRefineSet(REF_PARSE_CASE) ? 1 : 0; 
    539551 
    540         if( rules->type == OT_BLOCK ) 
     552        if( orIs(rules, OT_BLOCK) ) 
    541553            parseStringRules( a1, rules, all, useCase ); 
    542554        else 
    543555            parseString( a1, rules, all, useCase ); 
    544556    } 
    545     else if( a1->type == OT_BLOCK ) 
     557    else if( orIs(a1, OT_BLOCK) ) 
    546558    { 
    547559        parseBlock( a1, rules ); 
  • trunk/orca/tests/run_test

    r44 r46  
    44REBOL=rebol 
    55#REBOL=./rebol 
     6#REBOL=./rebol_view_1.2.47 
    67 
    78#DIFF='diff -w --ignore-blank-lines'