1: # include "../ingres.h"
   2: # include "../scanner.h"
   3: 
   4: /*
   5: ** OPERATOR
   6: ** an operator is defined as any 1-3 character sequence of
   7: ** non-alphanumerics.  It looks up each operator in 'Optab'
   8: ** and returns the appropriate token.
   9: */
  10: operator(chr)
  11: char    chr;
  12: {
  13:     extern int      yylval;
  14:     extern char     Cmap[];
  15:     register struct optab   *op;
  16:     register int        save;
  17:     char            buf[4];
  18: 
  19:     /* get lookahead characer */
  20:     save = Lcase;
  21:     Lcase = 0;
  22:     buf[0] = chr;
  23:     buf[1] = gtchar();
  24:     buf[2] = gtchar();
  25:     buf[3] = '\0';
  26: 
  27:     /* is it a floating fraction without leading zero ? */
  28:     if (buf[0] == '.' && Cmap[buf[1]] == NUMBR)
  29:     {
  30:         Lcase = save;
  31:         backup(buf[2]);
  32:         backup(buf[1]);
  33:         return(number(chr));
  34:     }
  35: 
  36:     /* three character operator ? */
  37:     for (op = &Optab[0]; op->term; op++)
  38:         if (sequal(op->term, buf))
  39:             break;
  40:     if (!op->term)
  41:     {
  42:         /* two character operator ? */
  43:         backup(buf[2]);
  44:         buf[2] = '\0';
  45:         for (op = &Optab[0]; op->term; op++)
  46:             if (sequal(op->term, buf))
  47:                 break;
  48:         if (!op->term)
  49:         {
  50:             backup(buf[1]);
  51:             buf[1] = '\0';
  52:             for (op = &Optab[0]; op->term; op++)
  53:                 if (sequal(op->term, buf))
  54:                     break;
  55:             if (!op->term)
  56:             {
  57:                 Lcase = save;
  58:                 /* invalid operator */
  59:                 yyerror (BADOP, 0);
  60:             }
  61:         }
  62:     }
  63:     Lcase = save;
  64:     if(op->token == Tokens.bgncmnt)
  65:         return(comment());
  66:     if(op->token == Tokens.sconst)
  67:         return (string(op));
  68:     Lastok.tok = op->term;
  69:     Lastok.toktyp = Tokens.sconst;
  70:     yylval = op->opcode;
  71:     return (op->token);
  72: }

Defined functions

operator defined in line 10; used 1 times
Last modified: 1980-12-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2450
Valid CSS Valid XHTML 1.0 Strict