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