|
|
1.1 root 1: # include "stdio.h"
2: # define U(x) x
3: # define NLSTATE yyprevious=YYNEWLINE
4: # define BEGIN yybgin = yysvec + 1 +
5: # define INITIAL 0
6: # define YYLERR yysvec
7: # define YYSTATE (yyestate-yysvec-1)
8: # define YYOPTIM 1
9: # define YYLMAX 200
10: # define output(c) putc(c,yyout)
11: # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
12: # define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
13: # define yymore() (yymorfg=1)
14: # define ECHO fprintf(yyout, "%s",yytext)
15: # define REJECT { nstr = yyreject(); goto yyfussy;}
16: int yyleng; extern char yytext[];
17: int yymorfg;
18: extern char *yysptr, yysbuf[];
19: int yytchar;
20: FILE *yyin = {stdin}, *yyout = {stdout};
21: extern int yylineno;
22: struct yysvf {
23: struct yywork *yystoff;
24: struct yysvf *yyother;
25: int *yystops;};
26: struct yysvf *yyestate;
27: extern struct yysvf yysvec[], *yybgin;
28: /* config.l 1.8 81/05/18 */
29:
30: #include <ctype.h>
31: #include "y.tab.h"
32: #include "config.h"
33:
34: #define tprintf if (do_trace) printf
35:
36: YYSTYPE yylval;
37:
38: /*
39: * Key word table
40: */
41:
42: struct kt {
43: char *kt_name;
44: int kt_val;
45: } key_words[] = {
46: "cpu", CPU, "ident", IDENT, "config", CONFIG, "options", OPTIONS,
47: "device", DEVICE, "controller", CONTROLLER, "uba", UBA, "mba", MBA,
48: "csr", CSR, "nexus", NEXUS, "drive", DRIVE, "vector", VECTOR,
49: "pseudo-device", PSEUDO_DEVICE, "flags", FLAGS, "trace", TRACE,
50: "disk", DISK, "tape", DEVICE, "slave", SLAVE, "at", AT,
51: "hz", HZ, "timezone", TIMEZONE, "dst", DST, "maxusers", MAXUSERS,
52: "master", MASTER, "mkfile", MAKEFILE,
53: 0,0,
54: };
55: # define YYNEWLINE 10
56: yylex(){
57: int nstr; extern int yyprevious;
58: while((nstr = yylook()) >= 0)
59: yyfussy: switch(nstr){
60: case 0:
61: if(yywrap()) return(0); break;
62: case 1:
63: {
64: int i;
65:
66: if ((i = kw_lookup(yytext)) == -1)
67: {
68: yylval.cp = yytext;
69: tprintf("id(%s) ", yytext);
70: return ID;
71: }
72: tprintf("(%s) ", yytext);
73: return i;
74: }
75: break;
76: case 2:
77: {
78: yytext[strlen(yytext)-1] = '\0';
79: yylval.cp = yytext + 1;
80: return ID;
81: }
82: break;
83: case 3:
84: {
85: yylval.i = octal(yytext);
86: tprintf("#O:%o ", yylval.i);
87: return NUMBER;
88: }
89: break;
90: case 4:
91: {
92: yylval.i = hex(yytext);
93: tprintf("#X:%x ", yylval.i);
94: return NUMBER;
95: }
96: break;
97: case 5:
98: {
99: yylval.i = atoi(yytext);
100: tprintf("#D:%d ", yylval.i);
101: return NUMBER;
102: }
103: break;
104: case 6:
105: {
106: double atof();
107: yylval.i = (int) (60 * atof(yytext) + 0.5);
108: return FPNUMBER;
109: }
110: break;
111: case 7:
112: {
113: return MINUS;
114: }
115: break;
116: case 8:
117: {
118: yylval.i = QUES;
119: tprintf("? ");
120: return NUMBER;
121: }
122: break;
123: case 9:
124: {
125: yyline++;
126: tprintf("\n... ");
127: }
128: break;
129: case 10:
130: {
131: yyline++;
132: tprintf("\n");
133: return SEMICOLON;
134: }
135: break;
136: case 11:
137: { /* Ignored (comment) */; }
138: break;
139: case 12:
140: { /* Ignored (white space) */; }
141: break;
142: case 13:
143: { return SEMICOLON; }
144: break;
145: case 14:
146: { return COMMA; }
147: break;
148: case -1:
149: break;
150: default:
151: fprintf(yyout,"bad switch yylook %d",nstr);
152: } return(0); }
153: /* end of yylex */
154: /*
155: * kw_lookup
156: * Look up a string in the keyword table. Returns a -1 if the
157: * string is not a keyword otherwise it returns the keyword number
158: */
159:
160: kw_lookup(word)
161: register char *word;
162: {
163: register struct kt *kp;
164:
165: for (kp = key_words; kp->kt_name != 0; kp++)
166: if (eq(word, kp->kt_name))
167: return kp->kt_val;
168: return -1;
169: }
170:
171: /*
172: * Number conversion routines
173: */
174:
175: octal(str)
176: char *str;
177: {
178: int num;
179:
180: sscanf(str, "%o", &num);
181: return num;
182: }
183:
184: hex(str)
185: char *str;
186: {
187: int num;
188:
189: sscanf(str+2, "%x", &num);
190: return num;
191: }
192: int yyvstop[] = {
193: 0,
194:
195: 12,
196: 0,
197:
198: 12,
199: 0,
200:
201: 12,
202: 0,
203:
204: 10,
205: -9,
206: 0,
207:
208: 14,
209: 0,
210:
211: 7,
212: 0,
213:
214: 3,
215: 0,
216:
217: 5,
218: 0,
219:
220: 13,
221: 0,
222:
223: 8,
224: 0,
225:
226: 1,
227: 0,
228:
229: 11,
230: 0,
231:
232: 9,
233: 0,
234:
235: 6,
236: 0,
237:
238: 3,
239: 0,
240:
241: 5,
242: 0,
243:
244: 2,
245: 0,
246:
247: 4,
248: 0,
249: 0};
250: # define YYTYPE char
251: struct yywork { YYTYPE verify, advance; } yycrank[] = {
252: 0,0, 0,0, 1,0, 1,0,
253: 1,0, 1,0, 1,0, 1,0,
254: 1,0, 1,0, 1,3, 1,4,
255: 1,0, 1,0, 1,0, 1,0,
256: 1,0, 1,0, 1,0, 1,0,
257: 1,0, 1,0, 1,0, 1,0,
258: 1,0, 1,0, 1,0, 1,0,
259: 1,0, 1,0, 1,0, 1,0,
260: 1,0, 3,3, 1,0, 1,5,
261: 1,0, 1,0, 1,0, 1,0,
262: 1,0, 1,0, 1,0, 1,0,
263: 1,0, 1,6, 1,7, 1,0,
264: 1,0, 1,8, 1,9, 4,14,
265: 15,20, 0,0, 0,0, 0,0,
266: 3,3, 1,9, 0,0, 1,0,
267: 1,10, 1,0, 1,0, 1,0,
268: 1,11, 1,0, 1,12, 0,0,
269: 0,0, 0,0, 0,0, 0,0,
270: 0,0, 9,16, 4,14, 9,19,
271: 9,19, 9,19, 9,19, 9,19,
272: 9,19, 9,19, 9,19, 9,19,
273: 9,19, 0,0, 0,0, 0,0,
274: 0,0, 0,0, 0,0, 0,0,
275: 1,0, 1,0, 1,0, 1,0,
276: 0,0, 1,0, 1,12, 8,16,
277: 0,0, 8,17, 8,17, 8,17,
278: 8,17, 8,17, 8,17, 8,17,
279: 8,17, 16,16, 16,16, 16,16,
280: 16,16, 16,16, 16,16, 16,16,
281: 16,16, 16,16, 16,16, 0,0,
282: 0,0, 0,0, 0,0, 0,0,
283: 1,0, 1,0, 1,0, 1,0,
284: 1,0, 2,0, 2,0, 2,0,
285: 2,0, 2,0, 2,0, 2,0,
286: 2,0, 0,0, 0,0, 2,0,
287: 2,0, 2,0, 2,0, 2,0,
288: 2,0, 2,0, 2,0, 2,0,
289: 2,0, 2,0, 2,0, 2,0,
290: 2,0, 2,0, 2,0, 2,0,
291: 2,0, 2,0, 2,0, 2,0,
292: 0,0, 2,0, 0,0, 2,13,
293: 2,0, 2,0, 2,0, 2,0,
294: 2,0, 2,0, 2,0, 2,0,
295: 2,6, 8,18, 2,0, 2,0,
296: 17,17, 17,17, 17,17, 17,17,
297: 17,17, 17,17, 17,17, 17,17,
298: 0,0, 5,15, 2,0, 2,10,
299: 2,0, 2,0, 2,0, 2,11,
300: 2,0, 5,15, 5,15, 19,19,
301: 19,19, 19,19, 19,19, 19,19,
302: 19,19, 19,19, 19,19, 19,19,
303: 19,19, 0,0, 0,0, 18,21,
304: 18,21, 18,21, 18,21, 18,21,
305: 18,21, 18,21, 18,21, 18,21,
306: 18,21, 0,0, 5,0, 2,0,
307: 2,0, 2,0, 2,0, 0,0,
308: 2,0, 0,0, 0,0, 0,0,
309: 0,0, 5,15, 0,0, 0,0,
310: 5,15, 5,15, 0,0, 0,0,
311: 0,0, 0,0, 0,0, 0,0,
312: 5,15, 0,0, 0,0, 0,0,
313: 0,0, 0,0, 0,0, 0,0,
314: 0,0, 5,15, 0,0, 2,0,
315: 2,0, 2,0, 2,0, 2,0,
316: 18,21, 18,21, 18,21, 18,21,
317: 18,21, 18,21, 12,12, 0,0,
318: 0,0, 0,0, 0,0, 0,0,
319: 0,0, 0,0, 0,0, 0,0,
320: 0,0, 0,0, 0,0, 0,0,
321: 0,0, 0,0, 0,0, 0,0,
322: 0,0, 5,15, 12,12, 12,12,
323: 12,12, 12,12, 12,12, 12,12,
324: 12,12, 12,12, 12,12, 12,12,
325: 12,12, 12,12, 12,12, 12,12,
326: 12,12, 12,12, 12,12, 12,12,
327: 12,12, 12,12, 12,12, 12,12,
328: 12,12, 12,12, 12,12, 12,12,
329: 0,0, 0,0, 0,0, 0,0,
330: 12,12, 0,0, 12,12, 12,12,
331: 12,12, 12,12, 12,12, 12,12,
332: 12,12, 12,12, 12,12, 12,12,
333: 12,12, 12,12, 12,12, 12,12,
334: 12,12, 12,12, 12,12, 12,12,
335: 12,12, 12,12, 12,12, 12,12,
336: 12,12, 12,12, 12,12, 12,12,
337: 13,13, 0,0, 0,0, 0,0,
338: 0,0, 0,0, 0,0, 0,0,
339: 13,13, 13,0, 0,0, 0,0,
340: 0,0, 0,0, 0,0, 0,0,
341: 0,0, 0,0, 0,0, 0,0,
342: 0,0, 0,0, 0,0, 0,0,
343: 0,0, 0,0, 0,0, 0,0,
344: 0,0, 0,0, 0,0, 0,0,
345: 0,0, 13,13, 0,0, 0,0,
346: 0,0, 0,0, 0,0, 0,0,
347: 0,0, 0,0, 0,0, 0,0,
348: 13,13, 0,0, 0,0, 13,13,
349: 13,13, 0,0, 0,0, 0,0,
350: 0,0, 0,0, 0,0, 13,13,
351: 0,0, 0,0, 0,0, 0,0,
352: 0,0, 0,0, 0,0, 0,0,
353: 13,13, 0,0, 0,0, 0,0,
354: 0,0, 0,0, 0,0, 0,0,
355: 0,0, 0,0, 0,0, 0,0,
356: 0,0, 0,0, 0,0, 0,0,
357: 0,0, 0,0, 0,0, 0,0,
358: 0,0, 0,0, 0,0, 0,0,
359: 0,0, 0,0, 0,0, 0,0,
360: 0,0, 0,0, 0,0, 0,0,
361: 13,13, 0,0, 0,0, 0,0,
362: 0,0};
363: struct yysvf yysvec[] = {
364: 0, 0, 0,
365: yycrank+-1, 0, yyvstop+1,
366: yycrank+-128, yysvec+1, yyvstop+3,
367: yycrank+24, 0, yyvstop+5,
368: yycrank+42, 0, yyvstop+7,
369: yycrank+-184, 0, 0,
370: yycrank+0, 0, yyvstop+10,
371: yycrank+0, 0, yyvstop+12,
372: yycrank+53, 0, yyvstop+14,
373: yycrank+27, 0, yyvstop+16,
374: yycrank+0, 0, yyvstop+18,
375: yycrank+0, 0, yyvstop+20,
376: yycrank+217, 0, yyvstop+22,
377: yycrank+-339, 0, yyvstop+24,
378: yycrank+0, 0, yyvstop+26,
379: yycrank+-18, yysvec+5, 0,
380: yycrank+61, 0, yyvstop+28,
381: yycrank+128, 0, yyvstop+30,
382: yycrank+159, 0, 0,
383: yycrank+147, 0, yyvstop+32,
384: yycrank+0, 0, yyvstop+34,
385: yycrank+0, yysvec+18, yyvstop+36,
386: 0, 0, 0};
387: struct yywork *yytop = yycrank+436;
388: struct yysvf *yybgin = yysvec+1;
389: char yymatch[] = {
390: 00 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
391: 01 ,011 ,012 ,01 ,01 ,01 ,01 ,01 ,
392: 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
393: 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
394: 011 ,01 ,'"' ,01 ,01 ,01 ,01 ,01 ,
395: 01 ,01 ,01 ,01 ,01 ,'-' ,01 ,01 ,
396: '0' ,'1' ,'1' ,'1' ,'1' ,'1' ,'1' ,'1' ,
397: '8' ,'8' ,01 ,01 ,01 ,01 ,01 ,01 ,
398: 01 ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
399: 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
400: 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
401: 'A' ,'A' ,'A' ,01 ,01 ,01 ,01 ,'A' ,
402: 01 ,'a' ,'a' ,'a' ,'a' ,'a' ,'a' ,'A' ,
403: 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
404: 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
405: 'A' ,'A' ,'A' ,01 ,01 ,01 ,01 ,01 ,
406: 0};
407: char yyextra[] = {
408: 0,0,0,0,0,0,0,0,
409: 0,1,0,0,0,0,0,0,
410: 0};
411: int yylineno =1;
412: # define YYU(x) x
413: # define NLSTATE yyprevious=YYNEWLINE
414: char yytext[YYLMAX];
415: struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
416: char yysbuf[YYLMAX];
417: char *yysptr = yysbuf;
418: int *yyfnd;
419: extern struct yysvf *yyestate;
420: int yyprevious = YYNEWLINE;
421: yylook(){
422: register struct yysvf *yystate, **lsp;
423: register struct yywork *yyt;
424: struct yysvf *yyz;
425: int yych;
426: struct yywork *yyr;
427: # ifdef LEXDEBUG
428: int debug;
429: # endif
430: char *yylastch;
431: /* start off machines */
432: # ifdef LEXDEBUG
433: debug = 0;
434: # endif
435: if (!yymorfg)
436: yylastch = yytext;
437: else {
438: yymorfg=0;
439: yylastch = yytext+yyleng;
440: }
441: for(;;){
442: lsp = yylstate;
443: yyestate = yystate = yybgin;
444: if (yyprevious==YYNEWLINE) yystate++;
445: for (;;){
446: # ifdef LEXDEBUG
447: if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
448: # endif
449: yyt = yystate->yystoff;
450: if(yyt == yycrank){ /* may not be any transitions */
451: yyz = yystate->yyother;
452: if(yyz == 0)break;
453: if(yyz->yystoff == yycrank)break;
454: }
455: *yylastch++ = yych = input();
456: tryagain:
457: # ifdef LEXDEBUG
458: if(debug){
459: fprintf(yyout,"char ");
460: allprint(yych);
461: putchar('\n');
462: }
463: # endif
464: yyr = yyt;
465: if ( (int)yyt > (int)yycrank){
466: yyt = yyr + yych;
467: if (yyt <= yytop && yyt->verify+yysvec == yystate){
468: if(yyt->advance+yysvec == YYLERR) /* error transitions */
469: {unput(*--yylastch);break;}
470: *lsp++ = yystate = yyt->advance+yysvec;
471: goto contin;
472: }
473: }
474: # ifdef YYOPTIM
475: else if((int)yyt < (int)yycrank) { /* r < yycrank */
476: yyt = yyr = yycrank+(yycrank-yyt);
477: # ifdef LEXDEBUG
478: if(debug)fprintf(yyout,"compressed state\n");
479: # endif
480: yyt = yyt + yych;
481: if(yyt <= yytop && yyt->verify+yysvec == yystate){
482: if(yyt->advance+yysvec == YYLERR) /* error transitions */
483: {unput(*--yylastch);break;}
484: *lsp++ = yystate = yyt->advance+yysvec;
485: goto contin;
486: }
487: yyt = yyr + YYU(yymatch[yych]);
488: # ifdef LEXDEBUG
489: if(debug){
490: fprintf(yyout,"try fall back character ");
491: allprint(YYU(yymatch[yych]));
492: putchar('\n');
493: }
494: # endif
495: if(yyt <= yytop && yyt->verify+yysvec == yystate){
496: if(yyt->advance+yysvec == YYLERR) /* error transition */
497: {unput(*--yylastch);break;}
498: *lsp++ = yystate = yyt->advance+yysvec;
499: goto contin;
500: }
501: }
502: if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
503: # ifdef LEXDEBUG
504: if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
505: # endif
506: goto tryagain;
507: }
508: # endif
509: else
510: {unput(*--yylastch);break;}
511: contin:
512: # ifdef LEXDEBUG
513: if(debug){
514: fprintf(yyout,"state %d char ",yystate-yysvec-1);
515: allprint(yych);
516: putchar('\n');
517: }
518: # endif
519: ;
520: }
521: # ifdef LEXDEBUG
522: if(debug){
523: fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
524: allprint(yych);
525: putchar('\n');
526: }
527: # endif
528: while (lsp-- > yylstate){
529: *yylastch-- = 0;
530: if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
531: yyolsp = lsp;
532: if(yyextra[*yyfnd]){ /* must backup */
533: while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
534: lsp--;
535: unput(*yylastch--);
536: }
537: }
538: yyprevious = YYU(*yylastch);
539: yylsp = lsp;
540: yyleng = yylastch-yytext+1;
541: yytext[yyleng] = 0;
542: # ifdef LEXDEBUG
543: if(debug){
544: fprintf(yyout,"\nmatch ");
545: sprint(yytext);
546: fprintf(yyout," action %d\n",*yyfnd);
547: }
548: # endif
549: return(*yyfnd++);
550: }
551: unput(*yylastch);
552: }
553: if (yytext[0] == 0 /* && feof(yyin) */)
554: {
555: yysptr=yysbuf;
556: return(0);
557: }
558: yyprevious = yytext[0] = input();
559: if (yyprevious>0)
560: output(yyprevious);
561: yylastch=yytext;
562: # ifdef LEXDEBUG
563: if(debug)putchar('\n');
564: # endif
565: }
566: }
567: yyback(p, m)
568: int *p;
569: {
570: if (p==0) return(0);
571: while (*p)
572: {
573: if (*p++ == m)
574: return(1);
575: }
576: return(0);
577: }
578: /* the following are only used in the lex library */
579: yyinput(){
580: return(input());
581: }
582: yyoutput(c)
583: int c; {
584: output(c);
585: }
586: yyunput(c)
587: int c; {
588: unput(c);
589: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.