|
|
1.1 root 1:
2: # line 2 "m4y.y"
3: extern long evalval;
4: #define YYSTYPE long
5: # define DIGITS 257
6: # define OROR 258
7: # define ANDAND 259
8: # define GT 260
9: # define GE 261
10: # define LT 262
11: # define LE 263
12: # define NE 264
13: # define EQ 265
14: # define POWER 266
15: # define UMINUS 267
16: #define yyclearin yychar = -1
17: #define yyerrok yyerrflag = 0
18: extern int yychar;
19: extern short yyerrflag;
20: #ifndef YYMAXDEPTH
21: #define YYMAXDEPTH 150
22: #endif
23: #ifndef YYSTYPE
24: #define YYSTYPE int
25: #endif
26: YYSTYPE yylval, yyval;
27: # define YYERRCODE 256
28:
29: # line 48 "m4y.y"
30:
31:
32: extern char *pe;
33:
34: yylex() {
35:
36: while (*pe==' ' || *pe=='\t' || *pe=='\n')
37: pe++;
38: switch(*pe) {
39: case '\0':
40: case '+':
41: case '-':
42: case '/':
43: case '%':
44: case '^':
45: case '~':
46: case '(':
47: case ')':
48: return(*pe++);
49: case '*':
50: return(peek('*', POWER, '*'));
51: case '>':
52: return(peek('=', GE, GT));
53: case '<':
54: return(peek('=', LE, LT));
55: case '=':
56: return(peek('=', EQ, EQ));
57: case '|':
58: return(peek('|', OROR, '|'));
59: case '&':
60: return(peek('&', ANDAND, '&'));
61: case '!':
62: return(peek('=', NE, '!'));
63: default: {
64: register base;
65:
66: evalval = 0;
67:
68: if (*pe == '0') {
69: if (*++pe=='x' || *pe=='X') {
70: base = 16;
71: ++pe;
72: } else
73: base = 8;
74: } else
75: base = 10;
76:
77: for (;;) {
78: register c, dig;
79:
80: c = *pe;
81:
82: if (c>='0' && c<='9')
83: dig = c - '0';
84: else if (c>='a' && c<='f')
85: dig = c - 'a' + 10;
86: else if (c>='A' && c<='F')
87: dig = c - 'A' + 10;
88: else
89: break;
90:
91: evalval = evalval*base + dig;
92: ++pe;
93: }
94:
95: return(DIGITS);
96: }
97: }
98: }
99:
100: peek(c, r1, r2)
101: {
102: if (*++pe != c)
103: return(r2);
104: ++pe;
105: return(r1);
106: }
107:
108: yyerror() {;}
109: short yyexca[] ={
110: -1, 1,
111: 0, -1,
112: -2, 0,
113: -1, 33,
114: 260, 0,
115: 261, 0,
116: 262, 0,
117: 263, 0,
118: 264, 0,
119: 265, 0,
120: -2, 7,
121: -1, 34,
122: 260, 0,
123: 261, 0,
124: 262, 0,
125: 263, 0,
126: 264, 0,
127: 265, 0,
128: -2, 8,
129: -1, 35,
130: 260, 0,
131: 261, 0,
132: 262, 0,
133: 263, 0,
134: 264, 0,
135: 265, 0,
136: -2, 9,
137: -1, 36,
138: 260, 0,
139: 261, 0,
140: 262, 0,
141: 263, 0,
142: 264, 0,
143: 265, 0,
144: -2, 10,
145: -1, 37,
146: 260, 0,
147: 261, 0,
148: 262, 0,
149: 263, 0,
150: 264, 0,
151: 265, 0,
152: -2, 11,
153: -1, 38,
154: 260, 0,
155: 261, 0,
156: 262, 0,
157: 263, 0,
158: 264, 0,
159: 265, 0,
160: -2, 12,
161: };
162: # define YYNPROD 26
163: # define YYLAST 294
164: short yyact[]={
165:
166: 24, 18, 25, 1, 48, 22, 20, 0, 21, 0,
167: 23, 24, 18, 0, 0, 0, 22, 20, 0, 21,
168: 0, 23, 24, 18, 0, 0, 24, 22, 20, 0,
169: 21, 22, 23, 24, 18, 0, 23, 0, 22, 20,
170: 0, 21, 0, 23, 24, 18, 0, 0, 0, 22,
171: 20, 0, 21, 24, 23, 0, 0, 19, 22, 20,
172: 0, 21, 0, 23, 24, 0, 3, 0, 19, 22,
173: 20, 0, 21, 5, 23, 0, 7, 0, 6, 19,
174: 0, 0, 0, 0, 0, 0, 0, 17, 0, 0,
175: 19, 0, 0, 0, 0, 0, 0, 0, 17, 0,
176: 0, 0, 0, 0, 0, 0, 0, 0, 0, 17,
177: 0, 2, 0, 0, 0, 26, 27, 28, 29, 30,
178: 17, 31, 32, 33, 34, 35, 36, 37, 38, 39,
179: 40, 41, 42, 43, 44, 45, 46, 47, 0, 0,
180: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
181: 0, 0, 0, 0, 0, 0, 0, 0, 0, 4,
182: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
183: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
184: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
185: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
186: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
187: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
188: 0, 9, 10, 13, 14, 15, 16, 12, 11, 25,
189: 0, 0, 9, 10, 13, 14, 15, 16, 12, 11,
190: 25, 0, 0, 0, 10, 13, 14, 15, 16, 12,
191: 11, 25, 0, 0, 0, 25, 13, 14, 15, 16,
192: 12, 11, 25, 0, 0, 0, 0, 13, 14, 15,
193: 16, 12, 11, 25, 0, 0, 13, 14, 15, 16,
194: 12, 11, 25, 0, 0, 0, 0, 0, 0, 0,
195: 8, 0, 0, 25 };
196: short yypact[]={
197:
198: 33,-1000, -26, 33, 33, 33, 33, 33,-1000, 33,
199: 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
200: 33, 33, 33, 33, 33, 33, 16, 16, -37,-1000,
201: -1000, -15, -4, 27, 27, 27, 27, 27, 27, 7,
202: 16, 7, -11, -11,-264,-264,-264,-264,-1000 };
203: short yypgo[]={
204:
205: 0, 3, 111 };
206: short yyr1[]={
207:
208: 0, 1, 1, 2, 2, 2, 2, 2, 2, 2,
209: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
210: 2, 2, 2, 2, 2, 2 };
211: short yyr2[]={
212:
213: 0, 1, 0, 3, 3, 2, 2, 3, 3, 3,
214: 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
215: 3, 3, 3, 2, 2, 1 };
216: short yychk[]={
217:
218: -1000, -1, -2, 33, 126, 40, 45, 43, 257, 258,
219: 259, 265, 264, 260, 261, 262, 263, 124, 38, 94,
220: 43, 45, 42, 47, 37, 266, -2, -2, -2, -2,
221: -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
222: -2, -2, -2, -2, -2, -2, -2, -2, 41 };
223: short yydef[]={
224:
225: 2, -2, 1, 0, 0, 0, 0, 0, 25, 0,
226: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
227: 0, 0, 0, 0, 0, 0, 5, 6, 0, 23,
228: 24, 3, 4, -2, -2, -2, -2, -2, -2, 13,
229: 14, 15, 16, 17, 18, 19, 20, 22, 21 };
230: # ifdef YYDEBUG
231: # include "y.debug"
232: # endif
233:
234: # define YYFLAG -1000
235: # define YYERROR goto yyerrlab
236: # define YYACCEPT return(0)
237: # define YYABORT return(1)
238:
239: /* parser for yacc output */
240:
241: #ifdef YYDEBUG
242: int yydebug = 0; /* 1 for debugging */
243: #endif
244: YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
245: int yychar = -1; /* current input token number */
246: int yynerrs = 0; /* number of errors */
247: short yyerrflag = 0; /* error recovery flag */
248:
249: yyparse()
250: { short yys[YYMAXDEPTH];
251: int yyj, yym;
252: register YYSTYPE *yypvt;
253: register int yystate, yyn;
254: register short *yyps;
255: register YYSTYPE *yypv;
256: register short *yyxi;
257:
258: yystate = 0;
259: yychar = -1;
260: yynerrs = 0;
261: yyerrflag = 0;
262: yyps= &yys[-1];
263: yypv= &yyv[-1];
264:
265: yystack: /* put a state and value onto the stack */
266: #ifdef YYDEBUG
267: if(yydebug >= 3)
268: if(yychar < 0 || yytoknames[yychar] == 0)
269: printf("char %d in %s", yychar, yystates[yystate]);
270: else
271: printf("%s in %s", yytoknames[yychar], yystates[yystate]);
272: #endif
273: if( ++yyps >= &yys[YYMAXDEPTH] ) {
274: yyerror( "yacc stack overflow" );
275: return(1);
276: }
277: *yyps = yystate;
278: ++yypv;
279: *yypv = yyval;
280: yynewstate:
281: yyn = yypact[yystate];
282: if(yyn <= YYFLAG) goto yydefault; /* simple state */
283: if(yychar<0) {
284: yychar = yylex();
285: #ifdef YYDEBUG
286: if(yydebug >= 2) {
287: if(yychar <= 0)
288: printf("lex EOF\n");
289: else if(yytoknames[yychar])
290: printf("lex %s\n", yytoknames[yychar]);
291: else
292: printf("lex (%c)\n", yychar);
293: }
294: #endif
295: if(yychar < 0)
296: yychar = 0;
297: }
298: if((yyn += yychar) < 0 || yyn >= YYLAST)
299: goto yydefault;
300: if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
301: yychar = -1;
302: yyval = yylval;
303: yystate = yyn;
304: if( yyerrflag > 0 ) --yyerrflag;
305: goto yystack;
306: }
307: yydefault:
308: /* default state action */
309: if( (yyn=yydef[yystate]) == -2 ) {
310: if(yychar < 0) {
311: yychar = yylex();
312: #ifdef YYDEBUG
313: if(yydebug >= 2)
314: if(yychar < 0)
315: printf("lex EOF\n");
316: else
317: printf("lex %s\n", yytoknames[yychar]);
318: #endif
319: if(yychar < 0)
320: yychar = 0;
321: }
322: /* look through exception table */
323: for(yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate);
324: yyxi += 2 ) ; /* VOID */
325: while( *(yyxi+=2) >= 0 ){
326: if( *yyxi == yychar ) break;
327: }
328: if( (yyn = yyxi[1]) < 0 ) return(0); /* accept */
329: }
330: if( yyn == 0 ){ /* error */
331: /* error ... attempt to resume parsing */
332: switch( yyerrflag ){
333: case 0: /* brand new error */
334: #ifdef YYDEBUG
335: yyerror("syntax error\n%s", yystates[yystate]);
336: if(yytoknames[yychar])
337: yyerror("saw %s\n", yytoknames[yychar]);
338: else if(yychar >= ' ' && yychar < '\177')
339: yyerror("saw `%c'\n", yychar);
340: else if(yychar == 0)
341: yyerror("saw EOF\n");
342: else
343: yyerror("saw char 0%o\n", yychar);
344: #else
345: yyerror( "syntax error" );
346: #endif
347: yyerrlab:
348: ++yynerrs;
349: case 1:
350: case 2: /* incompletely recovered error ... try again */
351: yyerrflag = 3;
352: /* find a state where "error" is a legal shift action */
353: while ( yyps >= yys ) {
354: yyn = yypact[*yyps] + YYERRCODE;
355: if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
356: yystate = yyact[yyn]; /* simulate a shift of "error" */
357: goto yystack;
358: }
359: yyn = yypact[*yyps];
360: /* the current yyps has no shift onn "error", pop stack */
361: #ifdef YYDEBUG
362: if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
363: #endif
364: --yyps;
365: --yypv;
366: }
367: /* there is no state on the stack with an error shift ... abort */
368: yyabort:
369: return(1);
370: case 3: /* no shift yet; clobber input char */
371: #ifdef YYDEBUG
372: if( yydebug ) {
373: printf("error recovery discards ");
374: if(yytoknames[yychar])
375: printf("%s\n", yytoknames[yychar]);
376: else if(yychar >= ' ' && yychar < '\177')
377: printf("`%c'\n", yychar);
378: else if(yychar == 0)
379: printf("EOF\n");
380: else
381: printf("char 0%o\n", yychar);
382: }
383: #endif
384: if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
385: yychar = -1;
386: goto yynewstate; /* try again in the same state */
387: }
388: }
389: /* reduction by production yyn */
390: #ifdef YYDEBUG
391: if(yydebug) { char *s;
392: printf("reduce %d in:\n\t", yyn);
393: for(s = yystates[yystate]; *s; s++) {
394: putchar(*s);
395: if(*s == '\n' && *(s+1))
396: putchar('\t');
397: }
398: }
399: #endif
400: yyps -= yyr2[yyn];
401: yypvt = yypv;
402: yypv -= yyr2[yyn];
403: yyval = yypv[1];
404: yym=yyn;
405: /* consult goto table to find next state */
406: yyn = yyr1[yyn];
407: yyj = yypgo[yyn] + *yyps + 1;
408: if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
409: switch(yym){
410:
411: case 1:
412: # line 19 "m4y.y"
413: { evalval = yypvt[-0]; } break;
414: case 2:
415: # line 20 "m4y.y"
416: { evalval = 0; } break;
417: case 3:
418: # line 23 "m4y.y"
419: { yyval = (yypvt[-2]!=0 || yypvt[-0]!=0) ? 1 : 0; } break;
420: case 4:
421: # line 24 "m4y.y"
422: { yyval = (yypvt[-2]!=0 && yypvt[-0]!=0) ? 1 : 0; } break;
423: case 5:
424: # line 25 "m4y.y"
425: { yyval = yypvt[-0] == 0; } break;
426: case 6:
427: # line 26 "m4y.y"
428: { yyval = ~yypvt[-0]; } break;
429: case 7:
430: # line 27 "m4y.y"
431: { yyval = yypvt[-2] == yypvt[-0]; } break;
432: case 8:
433: # line 28 "m4y.y"
434: { yyval = yypvt[-2] != yypvt[-0]; } break;
435: case 9:
436: # line 29 "m4y.y"
437: { yyval = yypvt[-2] > yypvt[-0]; } break;
438: case 10:
439: # line 30 "m4y.y"
440: { yyval = yypvt[-2] >= yypvt[-0]; } break;
441: case 11:
442: # line 31 "m4y.y"
443: { yyval = yypvt[-2] < yypvt[-0]; } break;
444: case 12:
445: # line 32 "m4y.y"
446: { yyval = yypvt[-2] <= yypvt[-0]; } break;
447: case 13:
448: # line 33 "m4y.y"
449: { yyval = (yypvt[-2]|yypvt[-0]); } break;
450: case 14:
451: # line 34 "m4y.y"
452: { yyval = (yypvt[-2]&yypvt[-0]); } break;
453: case 15:
454: # line 35 "m4y.y"
455: { yyval = (yypvt[-2]^yypvt[-0]); } break;
456: case 16:
457: # line 36 "m4y.y"
458: { yyval = (yypvt[-2]+yypvt[-0]); } break;
459: case 17:
460: # line 37 "m4y.y"
461: { yyval = (yypvt[-2]-yypvt[-0]); } break;
462: case 18:
463: # line 38 "m4y.y"
464: { yyval = (yypvt[-2]*yypvt[-0]); } break;
465: case 19:
466: # line 39 "m4y.y"
467: { yyval = (yypvt[-2]/yypvt[-0]); } break;
468: case 20:
469: # line 40 "m4y.y"
470: { yyval = (yypvt[-2]%yypvt[-0]); } break;
471: case 21:
472: # line 41 "m4y.y"
473: { yyval = (yypvt[-1]); } break;
474: case 22:
475: # line 42 "m4y.y"
476: { for (yyval=1; yypvt[-0]-->0; yyval *= yypvt[-2]); } break;
477: case 23:
478: # line 43 "m4y.y"
479: { yyval = yypvt[-0]-1; yyval = -yypvt[-0]; } break;
480: case 24:
481: # line 44 "m4y.y"
482: { yyval = yypvt[-0]-1; yyval = yypvt[-0]; } break;
483: case 25:
484: # line 45 "m4y.y"
485: { yyval = evalval; } break;
486: }
487: goto yystack; /* stack new state and value */
488: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.