Inform - Support - Source

Back to List

Inventory
Complete

Backward
Forward

Plain
Coloured
Gaudy

This code
in plain text

Browsing infix.h

InfixRvalue (lines 403-681)

0403  [ InfixRvalue acc w i n flag base expecting_term max maxi lop rop lvalside
0404                a b sysfun_f;
0405   
0406      if (InfixCheckLineSpaced()) return GPR_REPARSE;
0407   
0408  !   w = wn; for (i=0 : i<10 : i++) { wn = w; InfixRvalueTerm(); print i, "^"; }
0409  !   wn = w;
0410   
0411      expecting_term = true; base = 0;
0412      do {
0413          w = NextWordStopped();
0414          if (expecting_term) {
0415              switch (w) {
0416                '-//':
0417                  InfixRV_rvals-->n = 'unary-'; InfixRV_types-->n = base + 8;
0418                '[//':
0419                  InfixRV_rvals-->n = w; InfixRV_types-->n = base + 6;
0420                '[[':
0421                  InfixRV_rvals-->n = w; InfixRV_types-->n = base + 2;
0422                '++':
0423                  InfixRV_rvals-->n = 'pre++'; InfixRV_types-->n = base + 9;
0424                '--':
0425                  InfixRV_rvals-->n = 'pre--'; InfixRV_types-->n = base + 9;
0426                '(//':
0427                  InfixRV_rvals-->n = w; InfixRV_types-->n = -3; base=base+100;
0428                ')//':
0429                  InfixRV_rvals-->n = w; InfixRV_types-->n = -3; base=base-100;
0430                  if (base < 0) { wn--; flag = true; }
0431                -1:
0432                  flag = true;
0433                default:
0434                  wn--;
0435                  if (InfixRValueTerm() == 1) {
0436                      InfixRV_rvals-->n = parsed_number;
0437                      InfixRV_lvals-->n = infix_parsed_lvalue;
0438                      InfixRV_types-->n = -1;
0439                      expecting_term = false;
0440                  }
0441                  else flag = true;
0442              }
0443          }
0444          else {
0445              expecting_term = true;
0446              switch (w) {
0447                comma_word:
0448                  InfixRV_rvals-->n = w; InfixRV_types-->n = base;
0449                '=//':
0450                  InfixRV_rvals-->n = w; InfixRV_types-->n = base + 1;
0451                '&&', '||':
0452                  InfixRV_rvals-->n = w; InfixRV_types-->n = base + 2;
0453                '==', '[=', '>//', '>=', ', '<=', 'has', 'hasnt',
0454                'in', 'notin', 'ofclass', 'provides':
0455                  InfixRV_rvals-->n = w; InfixRV_types-->n = base + 3;
0456                'or':
0457                  InfixRV_rvals-->n = w; InfixRV_types-->n = base + 4;
0458                '+//', '-//':
0459                  InfixRV_rvals-->n = w; InfixRV_types-->n = base + 5;
0460                '*//', '@{2f}//', '%//', '&//', '|//':
0461                  InfixRV_rvals-->n = w; InfixRV_types-->n = base + 6;
0462                '->', '-->':
0463                  InfixRV_rvals-->n = w; InfixRV_types-->n = base + 7;
0464                ']&', ']#':
0465                  InfixRV_rvals-->n = w; InfixRV_types-->n = base + 10;
0466                THEN1__WD:
0467                  InfixRV_rvals-->n = w; InfixRV_types-->n = base + 12;
0468                '::':
0469                  InfixRV_rvals-->n = w; InfixRV_types-->n = base + 13;
0470                '(//':
0471                  InfixRV_rvals-->n = '(rcall';
0472                  InfixRV_types-->n = base + 11; base = base + 100;
0473                ')//':
0474                  InfixRV_rvals-->n = w; InfixRV_types-->n = -3;
0475                  base = base - 100;
0476                  if (base < 0) { wn--; flag = true; }
0477                  expecting_term = false;
0478                '++':
0479                  InfixRV_rvals-->n = 'post++'; InfixRV_types-->n = base + 9;
0480                  expecting_term = false;
0481                '--':
0482                  InfixRV_rvals-->n = 'post--'; InfixRV_types-->n = base + 9;
0483                  expecting_term = false;
0484                default:
0485                  flag = true;
0486              }
0487          }
0488          n++;
0489      } until (flag || n == 32);
0490      if (base > 0) return -1;
0491      n--; if (n == 0) return -1;
0492      wn--;
0493   
0494      for (i=0 : i<n : i++) {
0495          acc = 0; if (InfixRV_types-->i ~= -3) acc = InfixRV_rvals-->i;
0496          InfixRV_op-->i = acc;
0497      }
0498   
0499      for (::) {
0500   
0501  !       for (i=0 : i
0502  !           if (InfixRV_types-->i == -1) print InfixRV_rvals-->i, " ";
0503  !           else if (InfixRV_types-->i == -3) print " # ";
0504  !           else if (InfixRV_types-->i == -2) print " ## ";
0505  !           else print (address) InfixRV_rvals-->i, "_", InfixRV_types-->i, " ";
0506  !       }
0507  !       new_line;
0508   
0509          max = -2;
0510          for (i=0 : i<n : i++) if (InfixRV_types-->i > max) {
0511                              max = InfixRV_types-->i; maxi = i; }
0512          if (max == -1) { parsed_number = InfixRV_rvals-->maxi; return 1; }
0513   
0514          lop = maxi-1; rop = maxi+1;
0515          while (lop >= 0 && InfixRV_types-->lop < -1) lop--;
0516          while (rop < n && InfixRV_types-->rop < -1) rop++;
0517          if (lop >= 0) InfixRV_lop-->maxi = InfixRV_rvals-->lop;
0518          if (rop < n) InfixRV_rop-->maxi = InfixRV_rvals-->rop;
0519          flag = false;
0520          infix_term_type = INFIXTT_NUMBER;
0521          switch (InfixRV_rvals-->maxi) {
0522            comma_word:
0523              acc = (InfixRV_rvals-->rop);
0524            '=//', 'pre++', 'post++', 'pre--', 'post--':
0525              lvalside = lop;
0526              switch (InfixRV_rvals-->maxi) {
0527                '=//':        acc = (InfixRV_rvals-->rop);
0528                'pre++':      acc = (InfixRV_rvals-->rop) + 1; lvalside = rop;
0529                'pre--':      acc = (InfixRV_rvals-->rop) - 1; lvalside = rop;
0530                'post++':     acc = (InfixRV_rvals-->lop) + 1;
0531                'post--':     acc = (InfixRV_rvals-->lop) - 1;
0532              }
0533              switch (InfixRV_op-->lvalside) {
0534                THEN1__WD:
0535                  (InfixRV_lop-->lvalside).(InfixRV_rop-->lvalside) = acc;
0536                '->':
0537                  if (InfixInBounds(InfixRV_lop-->lvalside, InfixRV_rop-->lvalside))
0538                      (InfixRV_lop-->lvalside)->(InfixRV_rop-->lvalside) = acc;
0539                '-->':
0540                  if (InfixInBounds(InfixRV_lop-->lvalside, WORDSIZE * InfixRV_rop-->lvalside))
0541                      (InfixRV_lop-->lvalside)-->(InfixRV_rop-->lvalside) = acc;
0542                default:
0543                  w = InfixRV_lvals-->lvalside; if (w == -1) return -1;
0544                  @storew #globals_array w acc;
0545              }
0546              switch(InfixRV_rvals-->maxi) {
0547                'post++': acc--;
0548                'post--': acc++;
0549              }
0550            '(rcall':
0551              sysfun_f = false;
0552              switch (InfixRV_op-->lop) {
0553                THEN1__WD:
0554                  a = InfixRV_lop-->lop; b = InfixRV_rop-->lop;
0555                default:
0556                  a = InfixRV_rvals-->lop; b = call;
0557                  if (InfixRV_lvals-->lop == INFIXTT_SYSFUN)
0558                      sysfun_f = true;
0559              }
0560              w = 0;
0561              i = maxi + 1; base = 100;
0562              if (InfixRV_types-->i == -1 && InfixRV_rvals-->i == ')//') {
0563                  if (sysfun_f) return -1;
0564                  acc = a.b();
0565              }
0566              else {
0567                  while (base > 0) {
0568                      if (InfixRV_types-->i == -3 && InfixRV_rvals-->i == ')//') base = base - 100;
0569                      if (InfixRV_types-->i == -3 && InfixRV_rvals-->i == '(//') base = base + 100;
0570                      if (InfixRV_op-->i == '(rcall') base = base + 100;
0571                      if (base == 100 && InfixRV_op-->i == comma_word) {
0572                          InfixRV_commas-->(w++) = i;
0573  !                       print "Comma found at ", i, "^";
0574                      }
0575                      i++;
0576                  }
0577  !               print "Num args = ", w + 1, "^";
0578  !               for (i=0 : i
0579  !                   print "arg: ", InfixRV_lop-->(InfixRV_commas-->i), "^";
0580  !               print "arg: ", InfixRV_rvals-->rop, "^";
0581                  switch (w+1) {
0582                    1:
0583                      if (sysfun_f) {
0584                          b = InfixRV_rvals-->rop;
0585                          infix_term_type = INFIXTT_NAMEDOBJECT;
0586                          switch(a) {
0587                            'metaclass':
0588                              acc = metaclass(b);
0589                            'parent':
0590                              acc = parent(b);
0591                            'child':
0592                              acc = child(b);
0593                            'children':
0594                              acc = children(b);
0595                              infix_term_type = INFIXTT_NUMBER;
0596                            'random':
0597                              acc = random(b);
0598                              infix_term_type = INFIXTT_NUMBER;
0599                            'sibling':
0600                              acc = sibling(b);
0601                          }
0602                      }
0603                      else
0604                          acc = a.b(InfixRV_rvals-->rop);
0605                    2:
0606                      if (sysfun_f) return -1;
0607                      acc = a.b(InfixRV_lop-->(InfixRV_commas-->0),
0608                                InfixRV_rvals-->rop);
0609                    3:
0610                      if (sysfun_f) return -1;
0611                      acc = a.b(InfixRV_lop-->(InfixRV_commas-->0),
0612                                InfixRV_lop-->(InfixRV_commas-->1),
0613                                InfixRV_rvals-->rop);
0614                    4:
0615                      if (sysfun_f) return -1;
0616                      acc = a.b(InfixRV_lop-->(InfixRV_commas-->0),
0617                                InfixRV_lop-->(InfixRV_commas-->1),
0618                                InfixRV_lop-->(InfixRV_commas-->2),
0619                                InfixRV_rvals-->rop);
0620                    5:
0621                      if (sysfun_f) return -1;
0622                      acc = a.b(InfixRV_lop-->(InfixRV_commas-->0),
0623                                InfixRV_lop-->(InfixRV_commas-->1),
0624                                InfixRV_lop-->(InfixRV_commas-->2),
0625                                InfixRV_lop-->(InfixRV_commas-->3),
0626                                InfixRV_rvals-->rop);
0627                    default:
0628                      return -1;
0629                  }
0630              }
0631            '+//':        acc = (InfixRV_rvals-->lop) + (InfixRV_rvals-->rop);
0632            '-//':        acc = (InfixRV_rvals-->lop) - (InfixRV_rvals-->rop);
0633            '*//':        acc = (InfixRV_rvals-->lop) * (InfixRV_rvals-->rop);
0634            '@{2f}//':    acc = (InfixRV_rvals-->lop) / (InfixRV_rvals-->rop);
0635            '%//':        acc = (InfixRV_rvals-->lop) % (InfixRV_rvals-->rop);
0636            THEN1__WD:    acc = (InfixRV_rvals-->lop) . (InfixRV_rvals-->rop);
0637            '->':         acc = (InfixRV_rvals-->lop) -> (InfixRV_rvals-->rop);
0638            '-->':        acc = (InfixRV_rvals-->lop) --> (InfixRV_rvals-->rop);
0639            ']&':         acc = (InfixRV_rvals-->lop) .& (InfixRV_rvals-->rop);
0640            ']#':         acc = (InfixRV_rvals-->lop) .# (InfixRV_rvals-->rop);
0641            '::':         acc = (InfixRV_rvals-->lop) :: (InfixRV_rvals-->rop);
0642            '&//':        acc = (InfixRV_rvals-->lop) & (InfixRV_rvals-->rop);
0643            '|//':        acc = (InfixRV_rvals-->lop) | (InfixRV_rvals-->rop);
0644            '&&':         acc = (InfixRV_rvals-->lop) && (InfixRV_rvals-->rop);
0645                          infix_term_type = INFIXTT_LOGICAL;
0646            '||':         acc = (InfixRV_rvals-->lop) || (InfixRV_rvals-->rop);
0647                          infix_term_type = INFIXTT_LOGICAL;
0648            ':        acc = (InfixRV_rvals-->lop) < (InfixRV_rvals-->rop);
0649                          infix_term_type = INFIXTT_LOGICAL;
0650            '<=':         acc = (InfixRV_rvals-->lop) <= (InfixRV_rvals-->rop);
0651                          infix_term_type = INFIXTT_LOGICAL;
0652            '>//':        acc = (InfixRV_rvals-->lop) > (InfixRV_rvals-->rop);
0653                          infix_term_type = INFIXTT_LOGICAL;
0654            '>=':         acc = (InfixRV_rvals-->lop) >= (InfixRV_rvals-->rop);
0655                          infix_term_type = INFIXTT_LOGICAL;
0656            '==':         acc = (InfixRV_rvals-->lop) == (InfixRV_rvals-->rop);
0657                          infix_term_type = INFIXTT_LOGICAL;
0658            '[=':         acc = (InfixRV_rvals-->lop) ~= (InfixRV_rvals-->rop);
0659                          infix_term_type = INFIXTT_LOGICAL;
0660            'has':        acc = (InfixRV_rvals-->lop) has (InfixRV_rvals-->rop);
0661                          infix_term_type = INFIXTT_LOGICAL;
0662            'hasnt':      acc = (InfixRV_rvals-->lop) hasnt (InfixRV_rvals-->rop);
0663                          infix_term_type = INFIXTT_LOGICAL;
0664            'in':         acc = (InfixRV_rvals-->lop) in (InfixRV_rvals-->rop);
0665                          infix_term_type = INFIXTT_LOGICAL;
0666            'notin':      acc = (InfixRV_rvals-->lop) notin (InfixRV_rvals-->rop);
0667                          infix_term_type = INFIXTT_LOGICAL;
0668            'provides':   acc = (InfixRV_rvals-->lop) provides (InfixRV_rvals-->rop);
0669                          infix_term_type = INFIXTT_LOGICAL;
0670            'ofclass':    acc = (InfixRV_rvals-->lop) ofclass (InfixRV_rvals-->rop);
0671                          infix_term_type = INFIXTT_LOGICAL;
0672            '[[':         acc = ~~ (InfixRV_rvals-->rop); flag = true;
0673            '[//':        acc = ~ (InfixRV_rvals-->rop); flag = true;
0674            'unary-':     acc = - (InfixRV_rvals-->rop); flag = true;
0675          } ! end of switch(InfixRV_rvals-->maxi)
0676          InfixRV_rvals-->maxi = acc;
0677          InfixRV_types-->maxi = -1;
0678          if (rop < n) InfixRV_types-->rop = -2;
0679          if (flag == false && lop >= 0) InfixRV_types-->lop = -2;
0680      } ! end of for (::)
0681  ]; ! end of InfixRvalue


Last updated 27 February 2004. The librarian in charge of this page is Graham Nelson (graham@gnelson.demon.co.uk) assisted by C Knight. Please email any comments, suggestions or corrections to cedenqs@inform-fiction.org.