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