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

Defined functions

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