|
|
1.1 root 1: %{
2: /* config.l 1.8 81/05/18 */
3:
4: #include <ctype.h>
5: #include "y.tab.h"
6: #include "config.h"
7:
8: #define tprintf if (do_trace) printf
9:
10: YYSTYPE yylval;
11:
12: /*
13: * Key word table
14: */
15:
16: struct kt {
17: char *kt_name;
18: int kt_val;
19: } key_words[] = {
20: "cpu", CPU, "ident", IDENT, "config", CONFIG, "options", OPTIONS,
21: "device", DEVICE, "controller", CONTROLLER, "uba", UBA, "mba", MBA,
22: "csr", CSR, "nexus", NEXUS, "drive", DRIVE, "vector", VECTOR,
23: "pseudo-device", PSEUDO_DEVICE, "flags", FLAGS, "trace", TRACE,
24: "disk", DISK, "tape", DEVICE, "slave", SLAVE, "at", AT,
25: "hz", HZ, "timezone", TIMEZONE, "dst", DST, "maxusers", MAXUSERS,
26: "master", MASTER, "mkfile", MAKEFILE,
27: "machine", MACHINE, "priority", PRIORITY,
28: 0,0,
29: };
30: %}
31: WORD [A-Za-z_][-A-Za-z_]*
32: %%
33: {WORD} {
34: int i;
35:
36: if ((i = kw_lookup(yytext)) == -1)
37: {
38: yylval.cp = yytext;
39: tprintf("id(%s) ", yytext);
40: return ID;
41: }
42: tprintf("(%s) ", yytext);
43: return i;
44: }
45: \"[^"]+\" {
46: yytext[strlen(yytext)-1] = '\0';
47: yylval.cp = yytext + 1;
48: return ID;
49: }
50: 0[0-7]* {
51: yylval.i = octal(yytext);
52: tprintf("#O:%o ", yylval.i);
53: return NUMBER;
54: }
55: 0x[0-9a-f]+ {
56: yylval.i = hex(yytext);
57: tprintf("#X:%x ", yylval.i);
58: return NUMBER;
59: }
60: [1-9][0-9]* {
61: yylval.i = atoi(yytext);
62: tprintf("#D:%d ", yylval.i);
63: return NUMBER;
64: }
65: [0-9]"."[0-9]* {
66: double atof();
67: yylval.i = (int) (60 * atof(yytext) + 0.5);
68: return FPNUMBER;
69: }
70: "-" {
71: return MINUS;
72: }
73: "?" {
74: yylval.i = QUES;
75: tprintf("? ");
76: return NUMBER;
77: }
78: \n/[ \t] {
79: yyline++;
80: tprintf("\n... ");
81: }
82: \n {
83: yyline++;
84: tprintf("\n");
85: return SEMICOLON;
86: }
87: #.* { /* Ignored (comment) */; }
88: [ \t]* { /* Ignored (white space) */; }
89: ";" { return SEMICOLON; }
90: "," { return COMMA; }
91: vme16 { return VME16D16; }
92: vme24 { return VME24D16; }
93: vme32 { return VME32D32; }
94: vme16d16 { return VME16D16; }
95: vme24d16 { return VME24D16; }
96: vme32d16 { return VME32D16; }
97: vme16d32 { return VME16D32; }
98: vme24d32 { return VME24D32; }
99: vme32d32 { return VME32D32; }
100: %%
101: /*
102: * kw_lookup
103: * Look up a string in the keyword table. Returns a -1 if the
104: * string is not a keyword otherwise it returns the keyword number
105: */
106:
107: kw_lookup(word)
108: register char *word;
109: {
110: register struct kt *kp;
111:
112: for (kp = key_words; kp->kt_name != 0; kp++)
113: if (eq(word, kp->kt_name))
114: return kp->kt_val;
115: return -1;
116: }
117:
118: /*
119: * Number conversion routines
120: */
121:
122: octal(str)
123: char *str;
124: {
125: int num;
126:
127: sscanf(str, "%o", &num);
128: return num;
129: }
130:
131: hex(str)
132: char *str;
133: {
134: int num;
135:
136: sscanf(str+2, "%x", &num);
137: return num;
138: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.