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