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

unix.superglobalmegacorp.com

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