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