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