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

Defined functions

getcvar defined in line 108; used 4 times
yylex defined in line 31; never used

Defined variables

Cflag defined in line 16; never used
Keyent defined in line 17; never used
Keyword defined in line 10; never used
Lastok defined in line 11; used 6 times
Lcase defined in line 13; used 5 times
Newline defined in line 15; never used
Opcode defined in line 12; never used
Optab defined in line 9; never used
Pars defined in line 14; used 1 times
  • in line 70
Sbuf defined in line 19; never used
Tokens defined in line 8; used 4 times
Last modified: 1986-04-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1202
Valid CSS Valid XHTML 1.0 Strict