Annotation of 43BSD/ingres/source/parser/s_name.c, revision 1.1.1.1

1.1       root        1: # include <ingres.h>
                      2: # include "scanner.h"
                      3: # include      <sccs.h>
                      4: # include      <errors.h>
                      5: 
                      6: SCCSID(@(#)s_name.c    8.2     2/8/85)
                      7: 
                      8: /*
                      9: ** NAME
                     10: ** A name is defined to be a sequence of MAXNAME or fewer alphanumeric
                     11: ** characters, starting with an alphabetic (underscore "_" is considered
                     12: ** an alphabetic).  If it is not a keyword, each name is entered into
                     13: ** the symbol table, indexed by 'yylval'.  A token is then returned for
                     14: ** that name.
                     15: */
                     16: name(chr)
                     17: char   chr;
                     18: {
                     19:        extern char             *yylval;
                     20:        extern char             Cmap[];
                     21:        char                    namebuf[MAXNAME + 1];
                     22:        register int            hi, lo, curr;
                     23:        extern char             *syment();
                     24: 
                     25:        /* fill in the name */
                     26:        yylval = namebuf;
                     27:        *yylval = chr;
                     28:        do
                     29:        {
                     30:                *++yylval = get_scan(NORMAL);
                     31:                if ((yylval - namebuf) > MAXNAME)
                     32:                {
                     33:                        /* name too long */
                     34:                        *yylval = '\0';
                     35:                        par_error(NAMELONG, WARN, namebuf, 0);
                     36:                }
                     37: 
                     38:        }  while (Cmap[*yylval] == ALPHA || Cmap[*yylval] == NUMBR);
                     39:        backup(*yylval);
                     40:        *yylval = '\0';
                     41: 
                     42:        /* is it a keyword ? */
                     43:        lo = 0;
                     44:        hi = Keyent - 1;
                     45:        while (lo <= hi)
                     46:        {
                     47:                curr = (lo + hi) / 2;
                     48:                switch (scompare(Keyword[curr].term, MAXNAME, namebuf, MAXNAME))
                     49:                {
                     50:                  case 1:
                     51:                        hi = curr - 1;
                     52:                        continue;
                     53: 
                     54:                  case -1:
                     55:                        lo = curr + 1;
                     56:                        continue;
                     57: 
                     58:                  case 0:
                     59:                        Lastok.toktyp = Tokens.sconst;
                     60:                        Lastok.tok = Keyword[curr].term;
                     61:                        Lastok.tokop = Keyword[curr].opcode;
                     62:                        yylval = (char *) Lastok.tokop;
                     63:                        return (Keyword[curr].token);
                     64:                }
                     65:        }
                     66: 
                     67:        /* else, USER DEFINED NAME */
                     68: #      ifdef   xSTR2
                     69:        tTfp(71, 0, "name: %s\n", namebuf);
                     70: #      endif
                     71:        yylval = syment(namebuf, length(namebuf) + 1);
                     72:        Lastok.tok = yylval;
                     73:        Lastok.toktyp = Tokens.sconst;
                     74:        Lastok.tokop = 0;
                     75:        return (Tokens.name);
                     76: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.