Inform - Support - Source

Back to List

Inventory
Complete

Backward
Forward

Plain
Coloured
Gaudy

This code
in plain text

Browsing infix.h

InfixRvalue (lines 364-634)

0364  Array InfixRV_rvals --> 32;
0365  Array InfixRV_lvals --> 32;
0366  Array InfixRV_op --> 32;
0367  Array InfixRV_lop --> 32;
0368  Array InfixRV_rop --> 32;
0369  Array InfixRV_types --> 32;
0370  Array InfixRV_commas --> 32;
0371   
0372  [ InfixRvalue acc w i n flag base expecting_term max maxi lop rop lvalside
0373                a b sysfun_f;
0374   
0375    if (InfixCheckLineSpaced()) return GPR_REPARSE;
0376   
0377  !  w = wn; for (i=0: i<10: i++) { wn = w; InfixRvalueTerm(); print i, "^"; }
0378  !  wn = w;
0379   
0380    expecting_term = true; base = 0;
0381    do
0382    {   w = NextWordStopped();
0383        if (expecting_term)
0384        {   switch(w)
0385            {   '-//':
0386                    InfixRV_rvals-->n = 'unary-'; InfixRV_types-->n = base + 8;
0387                '[//':
0388                    InfixRV_rvals-->n = w; InfixRV_types-->n = base + 6;
0389                '[[':
0390                    InfixRV_rvals-->n = w; InfixRV_types-->n = base + 2;
0391                '++':
0392                    InfixRV_rvals-->n = 'pre++'; InfixRV_types-->n = base + 9;
0393                '--':
0394                    InfixRV_rvals-->n = 'pre--'; InfixRV_types-->n = base + 9;
0395                '(//':
0396                    InfixRV_rvals-->n = w; InfixRV_types-->n = -3; base=base+100;
0397                ')//':
0398                    InfixRV_rvals-->n = w; InfixRV_types-->n = -3; base=base-100;
0399                    if (base < 0) { wn--; flag = true; }
0400                -1: flag = true;
0401                default:
0402                    wn--;
0403                    if (InfixRValueTerm() == 1)
0404                    {   InfixRV_rvals-->n = parsed_number;
0405                        InfixRV_lvals-->n = infix_parsed_lvalue;
0406                        InfixRV_types-->n = -1;
0407                        expecting_term = false;
0408                    }
0409                    else flag = true;
0410            }
0411        }
0412        else
0413        {   expecting_term = true;
0414            switch(w)
0415            {   ',//':
0416                    InfixRV_rvals-->n = w; InfixRV_types-->n = base;
0417                '=//':
0418                    InfixRV_rvals-->n = w; InfixRV_types-->n = base + 1;
0419                '&&', '||':
0420                    InfixRV_rvals-->n = w; InfixRV_types-->n = base + 2;
0421                '==', '[=', '>//', '>=', ', '<=', 'has', 'hasnt',
0422                'in', 'notin', 'ofclass', 'provides':
0423                    InfixRV_rvals-->n = w; InfixRV_types-->n = base + 3;
0424                'or':
0425                    InfixRV_rvals-->n = w; InfixRV_types-->n = base + 4;
0426                '+//', '-//':
0427                    InfixRV_rvals-->n = w; InfixRV_types-->n = base + 5;
0428                '*//', '@{2f}//', '%//', '&//', '|//':
0429                    InfixRV_rvals-->n = w; InfixRV_types-->n = base + 6;
0430                '->', '-->':
0431                    InfixRV_rvals-->n = w; InfixRV_types-->n = base + 7;
0432                ']&', ']#':
0433                    InfixRV_rvals-->n = w; InfixRV_types-->n = base + 10;
0434                './/':
0435                    InfixRV_rvals-->n = w; InfixRV_types-->n = base + 12;
0436                '::':
0437                    InfixRV_rvals-->n = w; InfixRV_types-->n = base + 13;
0438                '(//':
0439                    InfixRV_rvals-->n = '(rcall';
0440                    InfixRV_types-->n = base + 11; base = base + 100;
0441                ')//':
0442                    InfixRV_rvals-->n = w; InfixRV_types-->n = -3;
0443                    base = base - 100;
0444                    if (base < 0) { wn--; flag = true; }
0445                    expecting_term = false;
0446                '++':
0447                    InfixRV_rvals-->n = 'post++'; InfixRV_types-->n = base + 9;
0448                    expecting_term = false;
0449                '--':
0450                    InfixRV_rvals-->n = 'post--'; InfixRV_types-->n = base + 9;
0451                    expecting_term = false;
0452                default:
0453                    flag = true;
0454            }
0455        }
0456        n++;
0457    } until (flag || n==32);
0458    if (base > 0) return -1;
0459    n--; if (n == 0) return -1;
0460    wn--;
0461   
0462    for (i=0: i<n: i++)
0463    {   acc = 0; if (InfixRV_types-->i ~= -3) acc = InfixRV_rvals-->i;
0464        InfixRV_op-->i = acc;
0465    }
0466   
0467    for (::)
0468    {   
0469  !      for (i=0: i
0470  !      {   if (InfixRV_types-->i == -1) print InfixRV_rvals-->i, " ";
0471  !          else if (InfixRV_types-->i == -3) print " # ";
0472  !          else if (InfixRV_types-->i == -2) print " ## ";
0473  !          else print (address) InfixRV_rvals-->i, "_", InfixRV_types-->i, " ";
0474  !      }
0475  !      new_line;
0476   
0477        max = -2;
0478        for (i=0:i<n:i++) if (InfixRV_types-->i > max)
0479                          { max = InfixRV_types-->i; maxi = i; }
0480        if (max == -1) { parsed_number = InfixRV_rvals-->maxi; return 1; }
0481   
0482        lop = maxi-1; rop = maxi+1;
0483        while (lop>=0 && InfixRV_types-->lop < -1) lop--;
0484        while (rop<n && InfixRV_types-->rop < -1) rop++;
0485        if (lop>=0) InfixRV_lop-->maxi = InfixRV_rvals-->lop;
0486        if (rop<n) InfixRV_rop-->maxi = InfixRV_rvals-->rop;
0487        flag = false;
0488      infix_term_type = INFIXTT_NUMBER;
0489      switch(InfixRV_rvals-->maxi)
0490      { ',//':     acc = (InfixRV_rvals-->rop);
0491        '=//', 'pre++', 'post++', 'pre--', 'post--':
0492                   lvalside = lop;
0493                   switch(InfixRV_rvals-->maxi)
0494                   {   '=//': acc = (InfixRV_rvals-->rop);
0495                       'pre++': acc = (InfixRV_rvals-->rop) + 1; lvalside = rop;
0496                       'pre--': acc = (InfixRV_rvals-->rop) - 1; lvalside = rop;
0497                       'post++': acc = (InfixRV_rvals-->lop) + 1;
0498                       'post--': acc = (InfixRV_rvals-->lop) - 1;
0499                   }
0500                   switch (InfixRV_op-->lvalside)
0501                   {   './/':
0502                         (InfixRV_lop-->lvalside).(InfixRV_rop-->lvalside) = acc;
0503                       '->':
0504                         (InfixRV_lop-->lvalside)->(InfixRV_rop-->lvalside) = acc;
0505                       '-->':
0506                         (InfixRV_lop-->lvalside)-->(InfixRV_rop-->lvalside) = acc;
0507                       default:
0508                           w = InfixRV_lvals-->lvalside; if (w == -1) return -1;
0509                           @storew #globals_array w acc;
0510                   }
0511                   switch(InfixRV_rvals-->maxi)
0512                   {   'post++': acc--;
0513                       'post--': acc++;
0514                   }
0515        '(rcall':  sysfun_f = false;
0516                   switch (InfixRV_op-->lop)
0517                   {   './/': a = InfixRV_lop-->lop; b = InfixRV_rop-->lop;
0518                       default:
0519                           a = InfixRV_rvals-->lop; b = call;
0520                           if (InfixRV_lvals-->lop == INFIXTT_SYSFUN)
0521                               sysfun_f = true;
0522                   }
0523                   w = 0;
0524                   i = maxi + 1; base = 100;
0525                   if (InfixRV_types-->i == -1 && InfixRV_rvals-->i == ')//')
0526                   {   if (sysfun_f) return -1;
0527                       acc = a.b();
0528                   }
0529                   else
0530                   {   while (base > 0)
0531                       {   if (InfixRV_types-->i == -3 && InfixRV_rvals-->i == ')//')
0532                               base = base - 100;
0533                           if (InfixRV_types-->i == -3 && InfixRV_rvals-->i == '(//')
0534                               base = base + 100;
0535                           if (InfixRV_op-->i=='(rcall') base = base + 100;
0536                           if (base == 100 && InfixRV_op-->i == ',//')
0537                           {   InfixRV_commas-->(w++) = i;
0538  !                             print "Comma found at ", i, "^";
0539                           }
0540                           i++;
0541                       }
0542  !                     print "Num args = ", w + 1, "^";
0543  !                     for (i = 0 : i < w : i++)
0544  !                         print "arg: ", InfixRV_lop-->(InfixRV_commas-->i), "^";
0545  !                     print "arg: ", InfixRV_rvals-->rop, "^";
0546                       switch(w+1)
0547                       {   1: if (sysfun_f)
0548                              {   b = InfixRV_rvals-->rop;
0549                                  infix_term_type = INFIXTT_NAMEDOBJECT;
0550                                  switch(a)
0551                                  {   'metaclass': acc = metaclass(b);
0552                                      'parent': acc = parent(b);
0553                                      'child': acc = child(b);
0554                                      'children': acc = children(b);
0555                                           infix_term_type = INFIXTT_NUMBER;
0556                                      'random': acc = random(b);
0557                                           infix_term_type = INFIXTT_NUMBER;
0558                                      'sibling': acc = sibling(b);
0559                                  }
0560                              }
0561                              else
0562                                  acc = a.b(InfixRV_rvals-->rop);
0563                           2: if (sysfun_f) return -1;
0564                              acc = a.b(InfixRV_lop-->(InfixRV_commas-->0),
0565                                        InfixRV_rvals-->rop);
0566                           3: if (sysfun_f) return -1;
0567                              acc = a.b(InfixRV_lop-->(InfixRV_commas-->0),
0568                                        InfixRV_lop-->(InfixRV_commas-->1),
0569                                        InfixRV_rvals-->rop);
0570                           4: if (sysfun_f) return -1;
0571                              acc = a.b(InfixRV_lop-->(InfixRV_commas-->0),
0572                                        InfixRV_lop-->(InfixRV_commas-->1),
0573                                        InfixRV_lop-->(InfixRV_commas-->2),
0574                                        InfixRV_rvals-->rop);
0575                           5: if (sysfun_f) return -1;
0576                              acc = a.b(InfixRV_lop-->(InfixRV_commas-->0),
0577                                        InfixRV_lop-->(InfixRV_commas-->1),
0578                                        InfixRV_lop-->(InfixRV_commas-->2),
0579                                        InfixRV_lop-->(InfixRV_commas-->3),
0580                                        InfixRV_rvals-->rop);
0581                           default: return -1;
0582                       }                     
0583                   }
0584        '+//':     acc = (InfixRV_rvals-->lop) + (InfixRV_rvals-->rop);
0585        '-//':     acc = (InfixRV_rvals-->lop) - (InfixRV_rvals-->rop);
0586        '*//':     acc = (InfixRV_rvals-->lop) * (InfixRV_rvals-->rop);
0587        '@{2f}//': acc = (InfixRV_rvals-->lop) / (InfixRV_rvals-->rop);
0588        '%//':     acc = (InfixRV_rvals-->lop) % (InfixRV_rvals-->rop);
0589        './/':     acc = (InfixRV_rvals-->lop) . (InfixRV_rvals-->rop);
0590        '->':      acc = (InfixRV_rvals-->lop) -> (InfixRV_rvals-->rop);
0591        '-->':     acc = (InfixRV_rvals-->lop) --> (InfixRV_rvals-->rop);
0592        ']&':      acc = (InfixRV_rvals-->lop) .& (InfixRV_rvals-->rop);
0593        ']#':      acc = (InfixRV_rvals-->lop) .# (InfixRV_rvals-->rop);
0594        '::':      acc = (InfixRV_rvals-->lop) :: (InfixRV_rvals-->rop);
0595        '&//':     acc = (InfixRV_rvals-->lop) & (InfixRV_rvals-->rop);
0596        '|//':     acc = (InfixRV_rvals-->lop) | (InfixRV_rvals-->rop);
0597        '&&':      acc = (InfixRV_rvals-->lop) && (InfixRV_rvals-->rop);
0598                   infix_term_type = INFIXTT_LOGICAL;
0599        '||':      acc = (InfixRV_rvals-->lop) || (InfixRV_rvals-->rop);
0600                   infix_term_type = INFIXTT_LOGICAL;
0601        ':     acc = (InfixRV_rvals-->lop) < (InfixRV_rvals-->rop);
0602                   infix_term_type = INFIXTT_LOGICAL;
0603        '<=':      acc = (InfixRV_rvals-->lop) <= (InfixRV_rvals-->rop);
0604                   infix_term_type = INFIXTT_LOGICAL;
0605        '>//':     acc = (InfixRV_rvals-->lop) > (InfixRV_rvals-->rop);
0606                   infix_term_type = INFIXTT_LOGICAL;
0607        '>=':      acc = (InfixRV_rvals-->lop) >= (InfixRV_rvals-->rop);
0608                   infix_term_type = INFIXTT_LOGICAL;
0609        '==':      acc = (InfixRV_rvals-->lop) == (InfixRV_rvals-->rop);
0610                   infix_term_type = INFIXTT_LOGICAL;
0611        '[=':  acc = (InfixRV_rvals-->lop) ~= (InfixRV_rvals-->rop);
0612                   infix_term_type = INFIXTT_LOGICAL;
0613        'has':     acc = (InfixRV_rvals-->lop) has (InfixRV_rvals-->rop);
0614                   infix_term_type = INFIXTT_LOGICAL;
0615        'hasnt':   acc = (InfixRV_rvals-->lop) hasnt (InfixRV_rvals-->rop);
0616                   infix_term_type = INFIXTT_LOGICAL;
0617        'in':      acc = (InfixRV_rvals-->lop) in (InfixRV_rvals-->rop);
0618                   infix_term_type = INFIXTT_LOGICAL;
0619        'notin':   acc = (InfixRV_rvals-->lop) notin (InfixRV_rvals-->rop);
0620                   infix_term_type = INFIXTT_LOGICAL;
0621        'provides': acc = (InfixRV_rvals-->lop) provides (InfixRV_rvals-->rop);
0622                   infix_term_type = INFIXTT_LOGICAL;
0623        'ofclass': acc = (InfixRV_rvals-->lop) ofclass (InfixRV_rvals-->rop);
0624                   infix_term_type = INFIXTT_LOGICAL;
0625        '[[':      acc = ~~ (InfixRV_rvals-->rop); flag = true;
0626        '[//':     acc = ~ (InfixRV_rvals-->rop); flag = true;
0627        'unary-':  acc = - (InfixRV_rvals-->rop); flag = true;
0628      }
0629        InfixRV_rvals-->maxi = acc;
0630        InfixRV_types-->maxi = -1;
0631        if (rop < n) InfixRV_types-->rop = -2;
0632        if (flag==false && lop >= 0) InfixRV_types-->lop = -2;
0633    }
0634  ];


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.