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