]> git.saurik.com Git - wxWidgets.git/blob - src/common/dosyacc.c
Distrib corrections,
[wxWidgets.git] / src / common / dosyacc.c
1 #ifndef lint
2 static char yysccsid[] = "@(#)yaccpar 1.7 (Berkeley) 09/09/90";
3 #endif
4 #define YYBYACC 1
5 #line 2 "parser.y"
6 #include "string.h"
7 #if defined(_MSC_VER) || defined(__VISAGECPP__)
8 #include <io.h>
9 #endif
10 #include "wx/expr.h"
11
12 #ifndef __EXTERN_C__
13 #define __EXTERN_C__ 1
14 #endif
15
16 #if defined(__cplusplus) || defined(__STDC__)
17 #if defined(__cplusplus) && defined(__EXTERN_C__)
18 extern "C" {
19 #endif
20 #endif
21 int yylex(void);
22 int yylook(void);
23 int yywrap(void);
24 int yyback(int *, int);
25
26 /* You may need to put /DLEX_SCANNER in your makefile
27 * if you're using LEX!
28 */
29 #ifdef LEX_SCANNER
30 /* int yyoutput(int); */
31 void yyoutput(int);
32 #else
33 void yyoutput(int);
34 #endif
35
36 #if defined(__cplusplus) || defined(__STDC__)
37 #if defined(__cplusplus) && defined(__EXTERN_C__)
38 }
39 #endif
40 #endif
41 #line 36 "parser.y"
42 typedef union {
43 char *s;
44 /* struct pexpr *expr; */
45 } YYSTYPE;
46 #line 44 "y_tab.c"
47 #define INTEGER 1
48 #define WORD 2
49 #define STRING 3
50 #define PERIOD 13
51 #define OPEN 4
52 #define CLOSE 5
53 #define COMMA 6
54 #define NEWLINE 7
55 #define ERROR 8
56 #define OPEN_SQUARE 9
57 #define CLOSE_SQUARE 10
58 #define EQUALS 11
59 #define EXP 14
60 #define YYERRCODE 256
61 short yylhs[] = { -1,
62 0, 0, 1, 1, 1, 2, 2, 2, 3, 3,
63 3, 4, 4, 5, 5, 5, 5, 5, 5, 5,
64 };
65 short yylen[] = { 2,
66 0, 2, 2, 2, 2, 4, 2, 3, 0, 1,
67 3, 3, 1, 1, 1, 1, 3, 3, 5, 1,
68 };
69 short yydefred[] = { 1,
70 0, 0, 0, 0, 2, 0, 5, 3, 0, 0,
71 0, 15, 7, 20, 0, 0, 13, 4, 0, 0,
72 0, 0, 8, 0, 6, 0, 18, 0, 12, 11,
73 0, 19,
74 };
75 short yydgoto[] = { 1,
76 5, 14, 15, 16, 17,
77 };
78 short yysindex[] = { 0,
79 -2, 9, 2, 1, 0, 10, 0, 0, 11, -5,
80 17, 0, 0, 0, 14, -1, 0, 0, 33, 38,
81 41, 16, 0, 11, 0, 29, 0, 40, 0, 0,
82 44, 0,
83 };
84 short yyrindex[] = { 0,
85 0, 0, 0, 0, 0, 0, 0, 0, 42, 21,
86 24, 0, 0, 0, 0, 30, 0, 0, 0, 0,
87 0, 0, 0, 31, 0, 27, 0, 24, 0, 0,
88 0, 0,
89 };
90 short yygindex[] = { 0,
91 0, 45, -8, 0, 26,
92 };
93 #define YYTABLESIZE 254
94 short yytable[] = { 3,
95 19, 10, 11, 12, 24, 9, 4, 20, 21, 4,
96 13, 10, 11, 12, 8, 30, 10, 28, 12, 4,
97 9, 7, 18, 23, 4, 16, 16, 22, 14, 14,
98 16, 17, 17, 14, 10, 9, 17, 25, 26, 10,
99 9, 27, 31, 9, 32, 6, 9, 29, 0, 0,
100 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
101 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
102 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
103 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
104 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
105 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
106 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
107 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
108 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
109 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
110 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
111 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
112 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
113 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
114 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
117 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
118 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
119 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
120 0, 0, 0, 2,
121 };
122 short yycheck[] = { 2,
123 9, 1, 2, 3, 6, 4, 9, 13, 14, 9,
124 10, 1, 2, 3, 13, 24, 1, 2, 3, 9,
125 4, 13, 13, 10, 9, 5, 6, 11, 5, 6,
126 10, 5, 6, 10, 5, 5, 10, 5, 1, 10,
127 10, 1, 14, 4, 1, 1, 5, 22, -1, -1,
128 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
129 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
130 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
131 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
132 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
133 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
134 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
135 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
136 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
137 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
138 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
139 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
140 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
141 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
142 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
143 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
144 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
145 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
146 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
147 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
148 -1, -1, -1, 256,
149 };
150 #define YYFINAL 1
151 #ifndef YYDEBUG
152 #define YYDEBUG 0
153 #endif
154 #define YYMAXTOKEN 14
155 #if YYDEBUG
156 char *yyname[] = {
157 "end-of-file","INTEGER","WORD","STRING","OPEN","CLOSE","COMMA","NEWLINE",
158 "ERROR","OPEN_SQUARE","CLOSE_SQUARE","EQUALS",0,"PERIOD","EXP",
159 };
160 char *yyrule[] = {
161 "$accept : commands",
162 "commands :",
163 "commands : commands command",
164 "command : WORD PERIOD",
165 "command : expr PERIOD",
166 "command : error PERIOD",
167 "expr : WORD OPEN arglist CLOSE",
168 "expr : OPEN_SQUARE CLOSE_SQUARE",
169 "expr : OPEN_SQUARE arglist CLOSE_SQUARE",
170 "arglist :",
171 "arglist : arg",
172 "arglist : arg COMMA arglist",
173 "arg : WORD EQUALS arg1",
174 "arg : arg1",
175 "arg1 : WORD",
176 "arg1 : STRING",
177 "arg1 : INTEGER",
178 "arg1 : INTEGER PERIOD INTEGER",
179 "arg1 : INTEGER EXP INTEGER",
180 "arg1 : INTEGER PERIOD INTEGER EXP INTEGER",
181 "arg1 : expr",
182 };
183 #endif
184 #define yyclearin (yychar=(-1))
185 #define yyerrok (yyerrflag=0)
186 #ifdef YYSTACKSIZE
187 #ifndef YYMAXDEPTH
188 #define YYMAXDEPTH YYSTACKSIZE
189 #endif
190 #else
191 #ifdef YYMAXDEPTH
192 #define YYSTACKSIZE YYMAXDEPTH
193 #else
194 #define YYSTACKSIZE 600
195 #define YYMAXDEPTH 600
196 #endif
197 #endif
198 int yydebug;
199 int yynerrs;
200 int yyerrflag;
201 int yychar;
202 short *yyssp;
203 YYSTYPE *yyvsp;
204 YYSTYPE yyval;
205 YYSTYPE yylval;
206 short yyss[YYSTACKSIZE];
207 YYSTYPE yyvs[YYSTACKSIZE];
208 #define yystacksize YYSTACKSIZE
209 #line 118 "parser.y"
210
211 #ifdef IDE_INVOKED
212 #include "../common/doslex.c"
213 #else
214 #include "../common/lex_yy.c"
215 #endif
216
217 /*
218 void yyerror(s)
219 char *s;
220 {
221 syntax_error(s);
222 }
223 */
224
225 /* Ansi prototype. If this doesn't work for you... uncomment
226 the above instead.
227 */
228
229 void yyerror(char *s)
230 {
231 syntax_error(s);
232 }
233
234 /*
235 * Unfortunately, my DOS version of FLEX
236 * requires yywrap to be #def'ed, whereas
237 * the UNIX flex expects a proper function.
238 */
239
240 /* Not sure if __SC__ is the appropriate thing
241 * to test
242 */
243
244 #ifndef __SC__
245 #ifdef USE_DEFINE
246 #ifndef yywrap
247 #define yywrap() 1
248 #endif
249 #else
250 int yywrap() { return 1; }
251 #endif
252 #endif
253 #line 247 "y_tab.c"
254 #define YYABORT goto yyabort
255 #define YYACCEPT goto yyaccept
256 #define YYERROR goto yyerrlab
257 int
258 yyparse()
259 {
260 register int yym, yyn, yystate;
261 #if YYDEBUG
262 register char *yys;
263 extern char *getenv();
264
265 yys = getenv("YYDEBUG");
266 if (yys)
267 {
268 yyn = *yys;
269 if (yyn >= '0' && yyn <= '9')
270 yydebug = yyn - '0';
271 }
272 #endif
273
274 yynerrs = 0;
275 yyerrflag = 0;
276 yychar = (-1);
277
278 yyssp = yyss;
279 yyvsp = yyvs;
280 *yyssp = yystate = 0;
281
282 yyloop:
283 yyn = yydefred[yystate];
284 if (yyn != 0) goto yyreduce;
285 if (yychar < 0)
286 {
287 if ((yychar = yylex()) < 0) yychar = 0;
288 #if YYDEBUG
289 if (yydebug)
290 {
291 yys = 0;
292 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
293 if (!yys) yys = "illegal-symbol";
294 printf("yydebug: state %d, reading %d (%s)\n", yystate,
295 yychar, yys);
296 }
297 #endif
298 }
299 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
300 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
301 {
302 #if YYDEBUG
303 if (yydebug)
304 printf("yydebug: state %d, shifting to state %d\n",
305 yystate, yytable[yyn]);
306 #endif
307 if (yyssp >= yyss + yystacksize - 1)
308 {
309 goto yyoverflow;
310 }
311 *++yyssp = yystate = yytable[yyn];
312 *++yyvsp = yylval;
313 yychar = (-1);
314 if (yyerrflag > 0) --yyerrflag;
315 goto yyloop;
316 }
317 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
318 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
319 {
320 yyn = yytable[yyn];
321 goto yyreduce;
322 }
323 if (yyerrflag) goto yyinrecovery;
324 #ifdef lint
325 goto yynewerror;
326 #endif
327 yynewerror:
328 yyerror("syntax error");
329 #ifdef lint
330 goto yyerrlab;
331 #endif
332 yyerrlab:
333 ++yynerrs;
334 yyinrecovery:
335 if (yyerrflag < 3)
336 {
337 yyerrflag = 3;
338 for (;;)
339 {
340 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
341 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
342 {
343 #if YYDEBUG
344 if (yydebug)
345 printf("yydebug: state %d, error recovery shifting\
346 to state %d\n", *yyssp, yytable[yyn]);
347 #endif
348 if (yyssp >= yyss + yystacksize - 1)
349 {
350 goto yyoverflow;
351 }
352 *++yyssp = yystate = yytable[yyn];
353 *++yyvsp = yylval;
354 goto yyloop;
355 }
356 else
357 {
358 #if YYDEBUG
359 if (yydebug)
360 printf("yydebug: error recovery discarding state %d\n",
361 *yyssp);
362 #endif
363 if (yyssp <= yyss) goto yyabort;
364 --yyssp;
365 --yyvsp;
366 }
367 }
368 }
369 else
370 {
371 if (yychar == 0) goto yyabort;
372 #if YYDEBUG
373 if (yydebug)
374 {
375 yys = 0;
376 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
377 if (!yys) yys = "illegal-symbol";
378 printf("yydebug: state %d, error recovery discards token %d (%s)\n",
379 yystate, yychar, yys);
380 }
381 #endif
382 yychar = (-1);
383 goto yyloop;
384 }
385 yyreduce:
386 #if YYDEBUG
387 if (yydebug)
388 printf("yydebug: state %d, reducing by rule %d (%s)\n",
389 yystate, yyn, yyrule[yyn]);
390 #endif
391 yym = yylen[yyn];
392 yyval = yyvsp[1-yym];
393 switch (yyn)
394 {
395 case 3:
396 #line 68 "parser.y"
397 {process_command(proio_cons(wxmake_word(yyvsp[-1].s), NULL)); free(yyvsp[-1].s);}
398 break;
399 case 4:
400 #line 70 "parser.y"
401 {process_command(yyvsp[-1].s);}
402 break;
403 case 5:
404 #line 72 "parser.y"
405 {syntax_error("Unrecognized command.");}
406 break;
407 case 6:
408 #line 76 "parser.y"
409 {yyval.s = proio_cons(wxmake_word(yyvsp[-3].s), yyvsp[-1].s); free(yyvsp[-3].s);}
410 break;
411 case 7:
412 #line 78 "parser.y"
413 {yyval.s = proio_cons(NULL, NULL);}
414 break;
415 case 8:
416 #line 80 "parser.y"
417 {yyval.s = yyvsp[-1].s; }
418 break;
419 case 9:
420 #line 84 "parser.y"
421 {yyval.s = NULL;}
422 break;
423 case 10:
424 #line 86 "parser.y"
425 {yyval.s = proio_cons(yyvsp[0].s, NULL);}
426 break;
427 case 11:
428 #line 89 "parser.y"
429 {yyval.s = proio_cons(yyvsp[-2].s, yyvsp[0].s);}
430 break;
431 case 12:
432 #line 93 "parser.y"
433 {yyval.s = proio_cons(wxmake_word("="), proio_cons(wxmake_word(yyvsp[-2].s), proio_cons(yyvsp[0].s, NULL)));
434 free(yyvsp[-2].s); }
435 break;
436 case 13:
437 #line 96 "parser.y"
438 {yyval.s = yyvsp[0].s; }
439 break;
440 case 14:
441 #line 99 "parser.y"
442 {yyval.s = wxmake_word(yyvsp[0].s); free(yyvsp[0].s);}
443 break;
444 case 15:
445 #line 101 "parser.y"
446 {yyval.s = wxmake_string(yyvsp[0].s); free(yyvsp[0].s);}
447 break;
448 case 16:
449 #line 103 "parser.y"
450 {yyval.s = wxmake_integer(yyvsp[0].s); free(yyvsp[0].s);}
451 break;
452 case 17:
453 #line 105 "parser.y"
454 {yyval.s = wxmake_real(yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-2].s); free(yyvsp[0].s); }
455 break;
456 case 18:
457 #line 107 "parser.y"
458 {yyval.s = wxmake_exp(yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-2].s); free(yyvsp[0].s); }
459 break;
460 case 19:
461 #line 110 "parser.y"
462 {yyval.s = wxmake_exp2(yyvsp[-4].s, yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-4].s); free(yyvsp[-2].s);
463 free(yyvsp[0].s); }
464 break;
465 case 20:
466 #line 114 "parser.y"
467 {yyval.s = yyvsp[0].s;}
468 break;
469 #line 461 "y_tab.c"
470 }
471 yyssp -= yym;
472 yystate = *yyssp;
473 yyvsp -= yym;
474 yym = yylhs[yyn];
475 if (yystate == 0 && yym == 0)
476 {
477 #if YYDEBUG
478 if (yydebug)
479 printf("yydebug: after reduction, shifting from state 0 to\
480 state %d\n", YYFINAL);
481 #endif
482 yystate = YYFINAL;
483 *++yyssp = YYFINAL;
484 *++yyvsp = yyval;
485 if (yychar < 0)
486 {
487 if ((yychar = yylex()) < 0) yychar = 0;
488 #if YYDEBUG
489 if (yydebug)
490 {
491 yys = 0;
492 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
493 if (!yys) yys = "illegal-symbol";
494 printf("yydebug: state %d, reading %d (%s)\n",
495 YYFINAL, yychar, yys);
496 }
497 #endif
498 }
499 if (yychar == 0) goto yyaccept;
500 goto yyloop;
501 }
502 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
503 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
504 yystate = yytable[yyn];
505 else
506 yystate = yydgoto[yym];
507 #if YYDEBUG
508 if (yydebug)
509 printf("yydebug: after reduction, shifting from state %d \
510 to state %d\n", *yyssp, yystate);
511 #endif
512 if (yyssp >= yyss + yystacksize - 1)
513 {
514 goto yyoverflow;
515 }
516 *++yyssp = yystate;
517 *++yyvsp = yyval;
518 goto yyloop;
519 yyoverflow:
520 yyerror("yacc stack overflow");
521 yyabort:
522 return (1);
523 yyaccept:
524 return (0);
525 }