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