Inform - Support - Source

Back to List

Inventory
Complete

Backward
Forward

Plain
Coloured
Gaudy

This code
in plain text

Browsing infix.h

InfixRvalueTerm (lines 123-264)

0123  [ InfixRvalueTerm n w i initial_wn wa wl sign base digit dcount;
0124   
0125    initial_wn = wn;
0126   
0127    infix_parsed_lvalue = -1;
0128    infix_term_type = INFIXTT_NUMBER;
0129   
0130    w = NextWordStopped();
0131    if (w == -1) return -1;
0132   
0133    wa = WordAddress(wn-1);
0134    wl = WordLength(wn-1);
0135    if (wa->0 == '-' or '$' or '0' or '1' or '2' or '3' or '4'
0136                 or '5' or '6' or '7' or '8' or '9')
0137    {   ! Parse decimal, hex or binary number
0138   
0139        sign = 1; base = 10; dcount = 0;
0140        if (wa->0 == '-') { sign = -1; wl--; wa++; }
0141        else
0142        {   if (wa->0 == '$') { base = 16; wl--; wa++; }
0143            if (wa->0 == '$') { base = 2; wl--; wa++; }
0144        }
0145        if (wl == 0) return -1;
0146        n = 0;
0147        while (wl > 0)
0148        {   if (wa->0 >= 'a') digit = wa->0 - 'a' + 10;
0149            else digit = wa->0 - '0';
0150            dcount++;
0151            switch(base)
0152            {   2: if (dcount == 17) return -1;
0153               10: if (dcount == 6) return -1;
0154                   if (dcount == 5)
0155                   {   if (n > 3276) return -1;
0156                       if (n == 3276)
0157                       {   if (sign == 1 && digit > 7) return -1;
0158                           if (sign == -1 && digit > 8) return -1;
0159                       }
0160                   }
0161               16: if (dcount == 5) return -1;
0162            }
0163            if (digit >= 0 && digit < base) n = base*n + digit;
0164            else return -1;
0165            wl--; wa++;
0166        }
0167        parsed_number = n*sign; return 1;
0168    }
0169   
0170  ! Parse character constant 'a'
0171   
0172    if (wl == 3 && wa->0==''' && wa->2==''')
0173    {   parsed_number = wa->1; return 1;
0174    }
0175   
0176  ! ##Action, 'dword'
0177   
0178    switch(w)
0179    {   '##': infix_term_type = INFIXTT_ACTION;
0180              w = NextWordStopped(); if (w == -1) return -1;
0181              wn--;
0182              if (InfixActionToken() == 0) return 1;
0183              return -1;
0184        '^^': infix_term_type = INFIXTT_DWORD;
0185              w = NextWordStopped(); if (w == -1) return -1;
0186              parsed_number = w; return 1;
0187    }
0188   
0189  ! Test for attribute, property, class name, variable name, array name, routine
0190  ! name, constant name
0191   
0192    wn--;
0193    if ((wa->0 >= 'a' && wa->0 <= 'z')
0194        || (wa->0 >= 'A' && wa->0 <= 'Z')
0195        || wa->0 == '_')
0196    {
0197                 
0198    infix_term_type = INFIXTT_ATTRIBUTE;
0199    if (InfixMatchPrule(InfixPrintAttribute,
0200        #lowest_attribute_number, #highest_attribute_number, wa, wl))
0201    {   wn++; return 1; }
0202   
0203    infix_term_type = INFIXTT_PROPERTY;
0204    if (InfixMatchPrule(InfixPrintProperty,
0205        #lowest_property_number, #highest_property_number, wa, wl))
0206    {   wn++; return 1; }
0207   
0208    infix_term_type = INFIXTT_GLOBAL;
0209    if (InfixMatchPrule(InfixPrintGlobal,
0210        #lowest_global_number, #highest_global_number, wa, wl))
0211    {   infix_parsed_lvalue = parsed_number-16;
0212        parsed_number = #globals_array-->infix_parsed_lvalue;
0213        wn++; return 1;
0214    }
0215   
0216    infix_term_type = INFIXTT_ARRAY;
0217    if (InfixMatchPrule(InfixPrintArray,
0218        #lowest_array_number, #highest_array_number, wa, wl))
0219    {   infix_parsed_lvalue = parsed_number;
0220        parsed_number = Symb__Tab(INFIXTT_ARRAY,parsed_number);
0221        infix_data1 = temp__global3;
0222        infix_data2 = temp__global2;
0223        wn++; return 1;
0224    }
0225   
0226    infix_term_type = INFIXTT_ROUTINE;
0227    if (InfixMatchPrule(InfixPrintRoutine,
0228        #lowest_routine_number, #highest_routine_number, wa, wl))
0229    {   infix_parsed_lvalue = parsed_number;
0230        parsed_number = Symb__Tab(INFIXTT_ROUTINE,parsed_number);
0231        infix_data1 = temp__global3;
0232        infix_data2 = temp__global2;
0233        wn++; return 1;
0234    }
0235   
0236    infix_term_type = INFIXTT_CONSTANT;
0237    if (InfixMatchPrule(InfixPrintConstant,
0238        #lowest_constant_number, #highest_constant_number, wa, wl))
0239    {   infix_parsed_lvalue = parsed_number;
0240        parsed_number = Symb__Tab(INFIXTT_CONSTANT,parsed_number);
0241        infix_data1 = temp__global3;
0242        infix_data2 = temp__global2;
0243        wn++; return 1;
0244    }
0245   
0246    switch(w)
0247    {   'parent', 'child', 'children',
0248        'random', 'metaclass', 'sibling': parsed_number = w;
0249            infix_parsed_lvalue = INFIXTT_SYSFUN;
0250            wn++; return 1;
0251    }
0252    }
0253   
0254    infix_term_type = INFIXTT_NAMEDOBJECT;
0255   
0256    wn = initial_wn; i = ParseToken(SCOPE_TT, InfixBigScope);
0257   
0258    if (i == GPR_REPARSE) return i;
0259    if (i > GPR_MULTIPLE)
0260    {   print "(", (name) i, " (", i, "))^";
0261        parsed_number = i; return 1;
0262    }
0263    return -1;
0264  ];


Last updated 27 February 2004. This site is no longer supported; information may be out of date.
Maintained as a historical archive by the Interactive Fiction Technology Foundation. Copyright 1993-2018 IFTF, CC-BY-SA unless otherwise noted.
This page was originally managed by Graham Nelson (graham@gnelson.demon.co.uk) assisted by C Knight.