1: # include   "../ingres.h"
   2: # include   "../scanner.h"
   3: /*
   4: ** YYLEX
   5: ** This is the control program for the scanner (lexical analyzer).
   6: ** Each call to yylex() returns a token for the next syntactic unit.
   7: ** If the object is of type I2CONST, I4CONST, F8CONST, SCONST or NAME, that
   8: ** object will also be entered in the symbol table, indexed by 'yylval'.
   9: ** If the object is not one of these types, yylval is the opcode field of
  10: ** the operator or keyword tables.
  11: ** The end-of-file token is zero.
  12: */
  13: yylex()
  14: {
  15:     register char   chr;
  16:     register int    rtval;
  17:     extern char Cmap[];
  18: 
  19:     rtval = -1;
  20:     Lastok.tokop = 0;
  21:     /* GET NEXT TOKEN */
  22:     do
  23:     {
  24:         if((chr = gtchar()) <= 0)
  25:         {
  26: #			ifdef   xSTR2
  27:             tTfp(72, 8, "end-of-file\n");
  28: #			endif
  29:             rtval = 0;
  30:             break;
  31:         }
  32:         switch(Cmap[chr])
  33:         {
  34:           case ALPHA:
  35:             rtval = name(chr);
  36:             break;
  37: 
  38:           case NUMBR:
  39:             rtval = number(chr);
  40:             break;
  41: 
  42:           case OPATR:
  43:             if ((rtval = operator(chr)) == 0)
  44:                 rtval = -1;
  45:             break;
  46: 
  47:           case PUNCT:
  48:             continue;
  49: 
  50:           case CNTRL:
  51:             /* already converted number ? */
  52:             if (Pars)
  53:                 switch (chr)
  54:                 {
  55:                   case CVAR_I2:
  56:                     rtval = getcvar(Tokens.i2const, 2);
  57:                     break;
  58: 
  59:                   case CVAR_I4:
  60:                     rtval = getcvar(Tokens.i4const, 4);
  61:                     break;
  62: 
  63:                   case CVAR_F8:
  64:                     rtval = getcvar(Tokens.f8const, 8);
  65:                     break;
  66: 
  67:                   case CVAR_S:
  68:                     rtval = getcvar(Tokens.sconst, 0);
  69:                     break;
  70: 
  71:                   default:
  72:                     printf("funny character 0%o ingnored\n", chr);
  73:                     continue;
  74:                 }
  75:             break;
  76:           default:
  77:             syserr("invalid type in yylex()");
  78:         }
  79:     }  while (rtval == -1);
  80:     if (rtval == 0)
  81:     {
  82:         Lastok.tokop = GOVAL;
  83:         Lastok.tok = 0;
  84:         Lastok.toktyp = 0;
  85:     }
  86:     return (rtval);
  87: }
  88: 
  89: 
  90: getcvar(type, len)
  91: int type;
  92: int len;
  93: {
  94:     extern char *yylval;
  95:     extern char Cmap[];
  96:     register int    save;
  97:     char        buf[MAXSTRING + 1];
  98:     char        *syment();
  99: 
 100:     save = Lcase;
 101:     Lcase = 0;
 102:     yylval = buf;
 103:     if (len)
 104:         while ((yylval - buf) < len)
 105:             *yylval++ = gtchar();
 106:     else
 107:     {
 108:         do
 109:         {
 110:             *yylval = gtchar();
 111:             if ((yylval - buf) > MAXSTRING)
 112:             {
 113:                 Lcase = save;
 114:                 yyerror(STRLONG, 0);
 115:             }
 116:             if (Cmap[*yylval] == CNTRL && *yylval != '\0')
 117:             {
 118:                 Lcase = save;
 119:                 /* control char in string from equel */
 120:                 yyerror(CNTRLCHR, 0);
 121:             }
 122:         } while (*yylval++);
 123:         len = yylval - buf;
 124:     }
 125:     Lcase = save;
 126:     yylval = syment(buf, len);
 127:     Lastok.tok = yylval;
 128:     Lastok.toktyp = type;
 129:     return (type);
 130: }

Defined functions

getcvar defined in line 90; used 4 times
yylex defined in line 13; used 1 times
Last modified: 1995-02-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2695
Valid CSS Valid XHTML 1.0 Strict