2 /* A Bison parser, made from parse.y
3 by GNU Bison version 1.25
6 #define YYBISON 1 /* Identify Bison output. */
50 extern char *filename;
54 static GList *class_nodes = NULL;
57 static GList *typestack = NULL;
59 static GList *funcargs = NULL;
60 static GList *checks = NULL;
61 static int has_self = FALSE;
62 static int vararg = FALSE;
64 static GList *gtktypes = NULL;
69 extern int ccode_line;
80 if(strcmp(yytext,"\n")==0) {
81 out=g_strconcat("Error: ",str," before newline",NULL);
82 } else if(yytext[0]=='\0') {
83 out=g_strconcat("Error: ",str," at end of input",NULL);
85 char *tmp = g_strdup(yytext);
86 while((p=strchr(tmp,'\n')))
89 out=g_strconcat("Error: ",str," before '",tmp,"'",NULL);
93 fprintf(stderr,"%s:%d: %s\n",filename,line_no,out);
100 push_variable(char *name, int scope, int line_no)
103 Type *type = typestack->data;
104 typestack = g_list_remove(typestack,typestack->data);
106 var = new_variable(scope,type,name,line_no);
107 class_nodes = g_list_append(class_nodes, var);
111 push_function(int scope, char *oid, char *id, char *onerror,
112 GString *cbuf,int line_no, int ccode_line, int vararg)
117 if(scope!=INIT_METHOD && scope!=CLASS_INIT_METHOD) {
118 type = typestack->data;
119 typestack = g_list_remove(typestack,typestack->data);
121 type = (Type *)new_type(0,g_strdup("void"));
124 node = new_method(scope,type,oid,gtktypes,id,funcargs,
125 onerror,cbuf,line_no,ccode_line,vararg);
129 class_nodes = g_list_append(class_nodes, node);
133 push_funcarg(char *name)
136 Type *type = typestack->data;
137 typestack = g_list_remove(typestack,typestack->data);
139 node = new_funcarg(type,name,checks);
142 funcargs = g_list_append(funcargs, node);
146 push_init_arg(char *name, int is_class)
153 tn = g_strconcat(((Class *)class)->otype,":Class",NULL);
155 tn = g_strdup(((Class *)class)->otype);
157 type = new_type(1,tn);
158 node = new_funcarg((Type *)type,name,NULL);
159 funcargs = g_list_prepend(funcargs, node);
168 type = new_type(1,g_strdup(((Class *)class)->otype));
169 ch = g_list_append(ch,new_check(NULL_CHECK,NULL));
170 ch = g_list_append(ch,new_check(TYPE_CHECK,NULL));
171 node = new_funcarg((Type *)type,id,ch);
172 funcargs = g_list_prepend(funcargs, node);
199 #define YYFLAG -32768
202 #define YYTRANSLATE(x) ((unsigned)(x) <= 285 ? yytranslate[x] : 73)
204 static const char yytranslate[] = { 0,
205 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
206 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
207 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
208 2, 2, 43, 2, 2, 2, 2, 2, 2, 34,
209 35, 37, 2, 38, 44, 2, 2, 2, 40, 2,
210 2, 2, 2, 2, 2, 2, 2, 2, 33, 42,
211 39, 41, 2, 2, 2, 2, 2, 2, 2, 2,
212 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
213 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
214 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
215 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
216 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
217 2, 2, 31, 36, 32, 2, 2, 2, 2, 2,
218 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
219 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
220 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
221 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
222 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
223 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
224 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
225 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
226 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
227 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
228 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
229 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
230 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
231 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
232 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
237 static const short yyprhs[] = { 0,
238 0, 4, 7, 10, 12, 15, 18, 20, 22, 27,
239 32, 35, 38, 41, 43, 45, 47, 52, 57, 69,
240 78, 82, 83, 87, 89, 91, 94, 96, 99, 102,
241 105, 107, 110, 113, 115, 117, 119, 121, 124, 126,
242 128, 131, 133, 136, 138, 140, 142, 144, 146, 149,
243 151, 155, 159, 162, 165, 167, 172, 176, 178, 181,
244 183, 193, 203, 212, 225, 235, 245, 251, 254, 258,
245 261, 262, 264, 266, 270, 272, 276, 278, 282, 284,
246 287, 294, 297, 299, 301, 304, 307, 311, 315, 319,
250 static const short yyrhs[] = { 46,
251 47, 46, 0, 47, 46, 0, 46, 47, 0, 47,
252 0, 46, 23, 0, 46, 24, 0, 23, 0, 24,
253 0, 48, 31, 49, 32, 0, 3, 22, 4, 22,
254 0, 49, 64, 0, 49, 50, 0, 49, 51, 0,
255 64, 0, 50, 0, 51, 0, 25, 54, 20, 33,
256 0, 26, 54, 20, 33, 0, 27, 52, 20, 20,
257 20, 31, 23, 20, 31, 23, 33, 0, 27, 52,
258 20, 20, 20, 31, 23, 33, 0, 34, 53, 35,
259 0, 0, 20, 36, 53, 0, 20, 0, 55, 0,
260 5, 55, 0, 56, 0, 56, 59, 0, 12, 57,
261 0, 11, 57, 0, 57, 0, 12, 18, 0, 11,
262 18, 0, 18, 0, 17, 0, 16, 0, 20, 0,
263 58, 20, 0, 22, 0, 6, 0, 13, 15, 0,
264 13, 0, 14, 15, 0, 14, 0, 15, 0, 9,
265 0, 8, 0, 7, 0, 37, 59, 0, 37, 0,
266 26, 20, 61, 0, 20, 26, 61, 0, 26, 61,
267 0, 20, 61, 0, 61, 0, 20, 34, 62, 35,
268 0, 62, 38, 20, 0, 20, 0, 31, 23, 0,
269 33, 0, 29, 60, 54, 20, 34, 66, 35, 65,
270 63, 0, 28, 26, 54, 20, 34, 66, 35, 65,
271 63, 0, 28, 54, 20, 34, 66, 35, 65, 63,
272 0, 30, 34, 22, 35, 54, 20, 34, 66, 35,
273 65, 31, 23, 0, 25, 54, 20, 34, 66, 35,
274 65, 31, 23, 0, 26, 54, 20, 34, 66, 35,
275 65, 31, 23, 0, 20, 34, 20, 35, 63, 0,
276 19, 72, 0, 19, 31, 23, 0, 39, 40, 0,
277 0, 6, 0, 20, 0, 20, 38, 67, 0, 67,
278 0, 68, 38, 10, 0, 68, 0, 68, 38, 69,
279 0, 69, 0, 54, 20, 0, 54, 20, 34, 20,
280 70, 35, 0, 70, 71, 0, 71, 0, 20, 0,
281 41, 72, 0, 42, 72, 0, 41, 39, 72, 0,
282 42, 39, 72, 0, 39, 39, 72, 0, 43, 39,
283 72, 0, 21, 0, 44, 21, 0, 20, 0
289 static const short yyrline[] = { 0,
290 179, 180, 181, 182, 185, 189, 193, 197, 203, 210,
291 215, 216, 217, 218, 219, 220, 223, 226, 230, 259,
292 285, 286, 289, 292, 298, 299, 307, 311, 318, 321,
293 324, 327, 330, 333, 336, 339, 342, 345, 349, 352,
294 357, 360, 363, 366, 369, 374, 377, 380, 385, 386,
295 389, 401, 413, 416, 428, 433, 438, 441, 446, 447,
296 451, 461, 471, 481, 487, 492, 497, 518, 519, 523,
297 524, 527, 528, 544, 559, 562, 563, 566, 567, 570,
298 573, 583, 584, 587, 600, 604, 608, 612, 616, 620,
304 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
306 static const char * const yytname[] = { "$","error","$undefined.","CLASS",
307 "FROM","CONST","VOID","STRUCT","UNION","ENUM","THREEDOTS","SIGNED","UNSIGNED",
308 "LONG","SHORT","INT","FLOAT","DOUBLE","CHAR","ONERROR","TOKEN","NUMBER","TYPETOKEN",
309 "CCODE","HCODE","PUBLIC","PRIVATE","ARGUMENT","VIRTUAL","SIGNAL","OVERRIDE",
310 "'{'","'}'","';'","'('","')'","'|'","'*'","','","'='","'1'","'>'","'<'","'!'",
311 "'-'","prog","ccodes","class","classdec","classcode","variable","argument","argflags",
312 "flaglist","type","type1","type2","integer","tspecifier","stars","fullsigtype",
313 "sigtype","tokenlist","codenocode","method","onerror","funcargs","arglist","arglist1",
314 "arg","checklist","check","numtok", NULL
318 static const short yyr1[] = { 0,
319 45, 45, 45, 45, 46, 46, 46, 46, 47, 48,
320 49, 49, 49, 49, 49, 49, 50, 50, 51, 51,
321 52, 52, 53, 53, 54, 54, 55, 55, 56, 56,
322 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
323 57, 57, 57, 57, 57, 58, 58, 58, 59, 59,
324 60, 60, 60, 60, 60, 61, 62, 62, 63, 63,
325 64, 64, 64, 64, 64, 64, 64, 65, 65, 65,
326 65, 66, 66, 66, 66, 67, 67, 68, 68, 69,
327 69, 70, 70, 71, 71, 71, 71, 71, 71, 71,
331 static const short yyr2[] = { 0,
332 3, 2, 2, 1, 2, 2, 1, 1, 4, 4,
333 2, 2, 2, 1, 1, 1, 4, 4, 11, 8,
334 3, 0, 3, 1, 1, 2, 1, 2, 2, 2,
335 1, 2, 2, 1, 1, 1, 1, 2, 1, 1,
336 2, 1, 2, 1, 1, 1, 1, 1, 2, 1,
337 3, 3, 2, 2, 1, 4, 3, 1, 2, 1,
338 9, 9, 8, 12, 9, 9, 5, 2, 3, 2,
339 0, 1, 1, 3, 1, 3, 1, 3, 1, 2,
340 6, 2, 1, 1, 2, 2, 3, 3, 3, 3,
344 static const short yydefact[] = { 0,
345 0, 7, 8, 0, 4, 0, 0, 5, 6, 3,
346 2, 0, 0, 1, 0, 0, 0, 22, 0, 0,
347 0, 0, 15, 16, 14, 10, 0, 0, 40, 48,
348 47, 46, 0, 0, 42, 44, 45, 36, 35, 34,
349 37, 39, 0, 25, 27, 31, 0, 0, 0, 0,
350 0, 0, 0, 0, 0, 55, 0, 9, 12, 13,
351 11, 0, 26, 33, 30, 32, 29, 41, 43, 0,
352 50, 28, 38, 0, 24, 0, 0, 0, 0, 0,
353 0, 0, 54, 0, 53, 0, 0, 0, 17, 0,
354 49, 18, 0, 0, 21, 0, 0, 0, 52, 58,
355 0, 51, 0, 0, 0, 60, 67, 40, 37, 0,
356 0, 75, 77, 79, 0, 23, 0, 0, 0, 56,
357 0, 0, 0, 59, 0, 80, 71, 0, 71, 0,
358 0, 71, 57, 0, 0, 74, 0, 0, 0, 0,
359 76, 78, 0, 0, 71, 0, 71, 0, 0, 93,
360 91, 0, 0, 68, 70, 0, 0, 0, 20, 0,
361 63, 0, 0, 84, 0, 0, 0, 0, 0, 83,
362 69, 92, 65, 66, 0, 62, 61, 71, 0, 0,
363 85, 0, 86, 0, 81, 82, 0, 0, 89, 87,
364 88, 90, 19, 0, 64, 0, 0, 0
367 static const short yydefgoto[] = { 196,
368 4, 5, 6, 22, 23, 24, 50, 76, 110, 44,
369 45, 46, 47, 72, 55, 56, 101, 107, 25, 140,
370 111, 112, 113, 114, 169, 170, 154
373 static const short yypact[] = { 21,
374 -18,-32768,-32768, 68, 66, 20, 54,-32768,-32768, 66,
375 155, 171, 0, 155, 48, 116, 116, 52, 61, -14,
376 59, 160,-32768,-32768,-32768,-32768, 29, 151,-32768,-32768,
377 -32768,-32768, 81, 189, 111, 120,-32768,-32768,-32768,-32768,
378 -32768,-32768, 117,-32768, 64,-32768, 124, 133, 135, 152,
379 116, 154, 150, 163, 116,-32768, 186,-32768,-32768,-32768,
380 -32768, 158,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 148,
381 64,-32768,-32768, 161, 173, 175, 191, 192, 179, 180,
382 195, 196,-32768, 28,-32768, 197, 183, 86,-32768, 134,
383 -32768,-32768, 134, 135,-32768, 199, 187, 134,-32768,-32768,
384 -22,-32768, 188, 116, 200,-32768,-32768, 185, 18, 204,
385 190,-32768, 193,-32768, 194,-32768, 201, 134, 198,-32768,
386 206, 134, 207,-32768, 116, 202, 41, 98, 41, 205,
387 203, 41,-32768, 208, 210,-32768, 214, -6, 209, 211,
388 -32768,-32768, 215, 26, 41, 86, 41, 134, 22,-32768,
389 -32768, 212, 216,-32768,-32768, 217, 218, 219,-32768, 86,
390 -32768, 86, 213,-32768, 220, -3, 8, 221, -9,-32768,
391 -32768,-32768,-32768,-32768, 222,-32768,-32768, 41, -1, -1,
392 -32768, -1,-32768, -1,-32768,-32768, 223, 224,-32768,-32768,
393 -32768,-32768,-32768, 228,-32768, 230, 239,-32768
396 static const short yypgoto[] = {-32768,
397 45, 243,-32768,-32768, 231, 232,-32768, 164, -16, 229,
398 -32768, 172,-32768, 181,-32768, -44,-32768, 15, 240, -124,
399 -91, 136,-32768, 137,-32768, 94, -82
406 static const short yytable[] = { 43,
407 48, 115, 52, 7, 143, 53, 119, 146, 83, 85,
408 164, 54, 120, 150, 151, 121, 150, 151, 150, 151,
409 160, 26, 162, 1, 152, 185, 131, 150, 151, 165,
410 134, 166, 167, 168, 78, 180, 99, 153, 86, 102,
411 153, 164, 153, 2, 3, 158, 182, 80, 62, 11,
412 12, 153, -73, 188, 14, 125, 163, 13, 159, 138,
413 165, 82, 166, 167, 168, 28, 29, 30, 31, 32,
414 1, 33, 34, 35, 36, 37, 38, 39, 40, 139,
415 41, 27, 42, 181, 183, 49, 51, 123, 2, 3,
416 8, 9, 57, 35, 36, 37, 189, 190, 64, 191,
417 71, 192, 28, 29, 30, 31, 32, 141, 33, 34,
418 35, 36, 37, 38, 39, 40, 105, 41, 106, 42,
419 28, 29, 30, 31, 32, 68, 33, 34, 35, 36,
420 37, 38, 39, 40, 69, 41, 70, 42, 28, 108,
421 30, 31, 32, 73, 33, 34, 35, 36, 37, 38,
422 39, 40, 74, 109, 75, 42, 29, 30, 31, 32,
423 161, 33, 34, 35, 36, 37, 38, 39, 40, 80,
424 41, 77, 42, 79, 176, 81, 177, 8, 9, 15,
425 89, 90, 84, 82, 16, 17, 18, 19, 20, 21,
426 15, 58, 88, 92, 93, 16, 17, 18, 19, 20,
427 21, 35, 36, 37, 65, 67, 66, 87, 94, 95,
428 96, 97, 98, 82, 80, 100, 103, 104, 117, -72,
429 118, 122, 124, 126, 127, 133, 135, 144, 129, 197,
430 128, 130, 132, 149, 171, 137, 172, 145, 198, 173,
431 174, 156, 147, 148, 187, 157, 10, 178, 155, 175,
432 195, 91, 59, 60, 194, 193, 63, 116, 179, 184,
436 static const short yycheck[] = { 16,
437 17, 93, 19, 22, 129, 20, 98, 132, 53, 54,
438 20, 26, 35, 20, 21, 38, 20, 21, 20, 21,
439 145, 22, 147, 3, 31, 35, 118, 20, 21, 39,
440 122, 41, 42, 43, 51, 39, 81, 44, 55, 84,
441 44, 20, 44, 23, 24, 20, 39, 20, 20, 5,
442 31, 44, 35, 178, 10, 38, 148, 4, 33, 19,
443 39, 34, 41, 42, 43, 5, 6, 7, 8, 9,
444 3, 11, 12, 13, 14, 15, 16, 17, 18, 39,
445 20, 34, 22, 166, 167, 34, 26, 104, 23, 24,
446 23, 24, 34, 13, 14, 15, 179, 180, 18, 182,
447 37, 184, 5, 6, 7, 8, 9, 10, 11, 12,
448 13, 14, 15, 16, 17, 18, 31, 20, 33, 22,
449 5, 6, 7, 8, 9, 15, 11, 12, 13, 14,
450 15, 16, 17, 18, 15, 20, 20, 22, 5, 6,
451 7, 8, 9, 20, 11, 12, 13, 14, 15, 16,
452 17, 18, 20, 20, 20, 22, 6, 7, 8, 9,
453 146, 11, 12, 13, 14, 15, 16, 17, 18, 20,
454 20, 20, 22, 20, 160, 26, 162, 23, 24, 20,
455 33, 34, 20, 34, 25, 26, 27, 28, 29, 30,
456 20, 32, 35, 33, 34, 25, 26, 27, 28, 29,
457 30, 13, 14, 15, 33, 34, 18, 22, 36, 35,
458 20, 20, 34, 34, 20, 20, 20, 35, 20, 35,
459 34, 34, 23, 20, 35, 20, 20, 23, 35, 0,
460 38, 31, 35, 20, 23, 34, 21, 35, 0, 23,
461 23, 31, 35, 34, 23, 31, 4, 35, 40, 31,
462 23, 71, 22, 22, 31, 33, 28, 94, 39, 39,
463 125, 22, 169, -1, 128
465 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
466 #line 3 "/usr/lib/bison.simple"
468 /* Skeleton output parser for bison,
469 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
471 This program is free software; you can redistribute it and/or modify
472 it under the terms of the GNU General Public License as published by
473 the Free Software Foundation; either version 2, or (at your option)
476 This program is distributed in the hope that it will be useful,
477 but WITHOUT ANY WARRANTY; without even the implied warranty of
478 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
479 GNU General Public License for more details.
481 You should have received a copy of the GNU General Public License
482 along with this program; if not, write to the Free Software
483 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
485 /* As a special exception, when this file is copied by Bison into a
486 Bison output file, you may use that output file without restriction.
487 This special exception was added by the Free Software Foundation
488 in version 1.24 of Bison. */
492 #define alloca __builtin_alloca
493 #else /* not GNU C. */
494 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
496 #else /* not sparc */
497 #if defined (MSDOS) && !defined (__TURBOC__)
499 #else /* not MSDOS, or __TURBOC__ */
503 #else /* not MSDOS, __TURBOC__, or _AIX */
507 void *alloca (unsigned int);
509 #else /* not __cplusplus */
511 #endif /* not __cplusplus */
513 #endif /* not _AIX */
514 #endif /* not MSDOS, or __TURBOC__ */
515 #endif /* not sparc. */
516 #endif /* not GNU C. */
517 #endif /* alloca not defined. */
519 /* This is the parser code that is written into each bison parser
520 when the %semantic_parser declaration is not specified in the grammar.
521 It was written by Richard Stallman by simplifying the hairy parser
522 used when %semantic_parser is specified. */
524 /* Note: there must be only one dollar sign in this file.
525 It is replaced by the list of actions, each action
526 as one case of the switch. */
528 #define yyerrok (yyerrstatus = 0)
529 #define yyclearin (yychar = YYEMPTY)
532 #define YYACCEPT return(0)
533 #define YYABORT return(1)
534 #define YYERROR goto yyerrlab1
535 /* Like YYERROR except do call yyerror.
536 This remains here temporarily to ease the
537 transition to the new meaning of YYERROR, for GCC.
538 Once GCC version 2 has supplanted version 1, this can go. */
539 #define YYFAIL goto yyerrlab
540 #define YYRECOVERING() (!!yyerrstatus)
541 #define YYBACKUP(token, value) \
543 if (yychar == YYEMPTY && yylen == 1) \
544 { yychar = (token), yylval = (value); \
545 yychar1 = YYTRANSLATE (yychar); \
550 { yyerror ("syntax error: cannot back up"); YYERROR; } \
554 #define YYERRCODE 256
557 #define YYLEX yylex()
563 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
565 #define YYLEX yylex(&yylval, &yylloc)
567 #else /* not YYLSP_NEEDED */
569 #define YYLEX yylex(&yylval, YYLEX_PARAM)
571 #define YYLEX yylex(&yylval)
573 #endif /* not YYLSP_NEEDED */
576 /* If nonreentrant, generate the variables here */
580 int yychar; /* the lookahead symbol */
581 YYSTYPE yylval; /* the semantic value of the */
582 /* lookahead symbol */
585 YYLTYPE yylloc; /* location data for the lookahead */
589 int yynerrs; /* number of parse errors so far */
590 #endif /* not YYPURE */
593 int yydebug; /* nonzero means print parse trace */
594 /* Since this is uninitialized, it does not stop multiple parsers
598 /* YYINITDEPTH indicates the initial size of the parser's stacks */
601 #define YYINITDEPTH 200
604 /* YYMAXDEPTH is the maximum size the stacks can grow to
605 (effective only if the built-in stack extension method is used). */
612 #define YYMAXDEPTH 10000
615 /* Prevent warning if -Wstrict-prototypes. */
620 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
621 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
622 #else /* not GNU C or C++ */
625 /* This is the most reliable way to avoid incompatibilities
626 in available built-in functions on various systems. */
628 __yy_memcpy (to, from, count)
633 register char *f = from;
634 register char *t = to;
635 register int i = count;
641 #else /* __cplusplus */
643 /* This is the most reliable way to avoid incompatibilities
644 in available built-in functions on various systems. */
646 __yy_memcpy (char *to, char *from, int count)
648 register char *f = from;
649 register char *t = to;
650 register int i = count;
659 #line 196 "/usr/lib/bison.simple"
661 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
662 into yyparse. The argument should have type void *.
663 It should actually point to an object.
664 Grammar actions can access the variable by casting it
665 to the proper pointer type. */
669 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
670 #define YYPARSE_PARAM_DECL
671 #else /* not __cplusplus */
672 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
673 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
674 #endif /* not __cplusplus */
675 #else /* not YYPARSE_PARAM */
676 #define YYPARSE_PARAM_ARG
677 #define YYPARSE_PARAM_DECL
678 #endif /* not YYPARSE_PARAM */
681 yyparse(YYPARSE_PARAM_ARG)
684 register int yystate;
686 register short *yyssp;
687 register YYSTYPE *yyvsp;
688 int yyerrstatus; /* number of tokens to shift before error messages enabled */
689 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
691 short yyssa[YYINITDEPTH]; /* the state stack */
692 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
694 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
695 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
698 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
699 YYLTYPE *yyls = yylsa;
702 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
704 #define YYPOPSTACK (yyvsp--, yyssp--)
707 int yystacksize = YYINITDEPTH;
718 YYSTYPE yyval; /* the variable used to return */
719 /* semantic values from the action */
726 fprintf(stderr, "Starting parse\n");
732 yychar = YYEMPTY; /* Cause a token to be read. */
734 /* Initialize stack pointers.
735 Waste one element of value and location stack
736 so that they stay on the same level as the state stack.
737 The wasted elements are never initialized. */
745 /* Push a new state, which is found in yystate . */
746 /* In all cases, when you get here, the value and location stacks
747 have just been pushed. so pushing a state here evens the stacks. */
752 if (yyssp >= yyss + yystacksize - 1)
754 /* Give user a chance to reallocate the stack */
755 /* Use copies of these so that the &'s don't force the real ones into memory. */
756 YYSTYPE *yyvs1 = yyvs;
759 YYLTYPE *yyls1 = yyls;
762 /* Get the current used size of the three stacks, in elements. */
763 int size = yyssp - yyss + 1;
766 /* Each stack pointer address is followed by the size of
767 the data in use in that stack, in bytes. */
769 /* This used to be a conditional around just the two extra args,
770 but that might be undefined if yyoverflow is a macro. */
771 yyoverflow("parser stack overflow",
772 &yyss1, size * sizeof (*yyssp),
773 &yyvs1, size * sizeof (*yyvsp),
774 &yyls1, size * sizeof (*yylsp),
777 yyoverflow("parser stack overflow",
778 &yyss1, size * sizeof (*yyssp),
779 &yyvs1, size * sizeof (*yyvsp),
783 yyss = yyss1; yyvs = yyvs1;
787 #else /* no yyoverflow */
788 /* Extend the stack our own way. */
789 if (yystacksize >= YYMAXDEPTH)
791 yyerror("parser stack overflow");
795 if (yystacksize > YYMAXDEPTH)
796 yystacksize = YYMAXDEPTH;
797 yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
798 __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
799 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
800 __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
802 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
803 __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
805 #endif /* no yyoverflow */
807 yyssp = yyss + size - 1;
808 yyvsp = yyvs + size - 1;
810 yylsp = yyls + size - 1;
815 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
818 if (yyssp >= yyss + yystacksize - 1)
824 fprintf(stderr, "Entering state %d\n", yystate);
830 /* Do appropriate processing given the current state. */
831 /* Read a lookahead token if we need one and don't already have one. */
834 /* First try to decide what to do without reference to lookahead token. */
836 yyn = yypact[yystate];
840 /* Not known => get a lookahead token if don't already have one. */
842 /* yychar is either YYEMPTY or YYEOF
843 or a valid token in external form. */
845 if (yychar == YYEMPTY)
849 fprintf(stderr, "Reading a token: ");
854 /* Convert token to internal form (in yychar1) for indexing tables with */
856 if (yychar <= 0) /* This means end of input. */
859 yychar = YYEOF; /* Don't call YYLEX any more */
863 fprintf(stderr, "Now at end of input.\n");
868 yychar1 = YYTRANSLATE(yychar);
873 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
874 /* Give the individual parser a way to print the precise meaning
875 of a token, for further debugging info. */
877 YYPRINT (stderr, yychar, yylval);
879 fprintf (stderr, ")\n");
885 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
890 /* yyn is what to do for this token type in this state.
891 Negative => reduce, -yyn is rule number.
892 Positive => shift, yyn is new state.
893 New state is final state => don't bother to shift,
895 0, or most negative number => error. */
910 /* Shift the lookahead token. */
914 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
917 /* Discard the token being shifted unless it is eof. */
926 /* count tokens shifted since error; after three, turn off error status. */
927 if (yyerrstatus) yyerrstatus--;
932 /* Do the default action for the current state. */
935 yyn = yydefact[yystate];
939 /* Do a reduction. yyn is the number of a rule to reduce with. */
943 yyval = yyvsp[1-yylen]; /* implement default value of the action */
950 fprintf (stderr, "Reducing via rule %d (line %d), ",
953 /* Print the symbols being reduced, and their result. */
954 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
955 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
956 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
982 Node *node = new_ccode(FALSE,yyvsp[0].cbuf,ccode_line);
983 nodes = g_list_append(nodes,node);
989 Node *node = new_ccode(TRUE,yyvsp[0].cbuf,ccode_line);
990 nodes = g_list_append(nodes,node);
996 Node *node = new_ccode(FALSE,yyvsp[0].cbuf,ccode_line);
997 nodes = g_list_append(nodes,node);
1003 Node *node = new_ccode(TRUE,yyvsp[0].cbuf,ccode_line);
1004 nodes = g_list_append(nodes,node);
1010 ((Class *)class)->nodes = class_nodes;
1012 nodes = g_list_append(nodes,class);
1018 class = new_class(yyvsp[-2].id,yyvsp[0].id,NULL);
1048 push_variable(yyvsp[-1].id,PUBLIC_SCOPE,yyvsp[-3].line);
1054 push_variable(yyvsp[-1].id,PRIVATE_SCOPE,yyvsp[-3].line);
1060 if(strcmp(yyvsp[-6].id,"get")==0 &&
1061 strcmp(yyvsp[-3].id,"set")==0) {
1063 g_free(yyvsp[-6].id); g_free(yyvsp[-3].id);
1064 node = new_argument(yyvsp[-8].id,yyvsp[-9].list,yyvsp[-7].id,
1065 yyvsp[-4].cbuf,yyvsp[-5].line,
1066 yyvsp[-1].cbuf,yyvsp[-2].line,
1068 class_nodes = g_list_append(class_nodes,node);
1069 } else if(strcmp(yyvsp[-6].id,"set")==0 &&
1070 strcmp(yyvsp[-3].id,"get")==0) {
1072 g_free(yyvsp[-6].id); g_free(yyvsp[-3].id);
1073 node = new_argument(yyvsp[-8].id,yyvsp[-9].list,yyvsp[-7].id,
1074 yyvsp[-1].cbuf,yyvsp[-2].line,
1075 yyvsp[-4].cbuf,yyvsp[-5].line,
1077 class_nodes = g_list_append(class_nodes,node);
1079 g_free(yyvsp[-8].id); g_free(yyvsp[-7].id);
1080 g_free(yyvsp[-6].id); g_free(yyvsp[-3].id);
1081 g_list_foreach(yyvsp[-9].list,(GFunc)g_free,NULL);
1082 g_string_free(yyvsp[-1].cbuf,TRUE);
1083 g_string_free(yyvsp[-4].cbuf,TRUE);
1084 yyerror(_("parse error"));
1092 if(strcmp(yyvsp[-3].id,"get")==0) {
1094 g_free(yyvsp[-3].id);
1095 node = new_argument(yyvsp[-5].id,yyvsp[-6].list,yyvsp[-4].id,
1096 yyvsp[-1].cbuf,yyvsp[-2].line,NULL,0,
1098 class_nodes = g_list_append(class_nodes,node);
1099 } else if(strcmp(yyvsp[-3].id,"set")==0) {
1101 g_free(yyvsp[-3].id);
1102 node = new_argument(yyvsp[-5].id,yyvsp[-6].list,yyvsp[-4].id,
1103 NULL,0,yyvsp[-1].cbuf,yyvsp[-2].line,
1105 class_nodes = g_list_append(class_nodes,node);
1107 g_free(yyvsp[-3].id); g_free(yyvsp[-5].id);
1108 g_free(yyvsp[-4].id);
1109 g_list_foreach(yyvsp[-6].list,(GFunc)g_free,NULL);
1110 g_string_free(yyvsp[-1].cbuf,TRUE);
1111 yyerror(_("parse error"));
1118 { yyval.list = yyvsp[-1].list; ;
1122 { yyval.list = NULL; ;
1127 yyval.list = g_list_append(yyvsp[0].list,yyvsp[-2].id);
1133 yyval.list = g_list_append(NULL,yyvsp[0].id);
1143 Type *type = typestack->data;
1144 char *oldname = type->name;
1145 type->name = g_strconcat("const ",oldname,NULL);
1152 Node *node = new_type(0,yyvsp[0].id);
1153 typestack = g_list_prepend(typestack,node);
1159 Node *node = new_type(stars,yyvsp[-1].id);
1161 typestack = g_list_prepend(typestack,node);
1167 yyval.id = g_strconcat("unsigned ",yyvsp[0].id,NULL);
1173 yyval.id = g_strconcat("signed ",yyvsp[0].id,NULL);
1179 yyval.id = g_strdup(yyvsp[0].id);
1185 yyval.id = g_strdup("unsigned char");
1191 yyval.id = g_strdup("signed char");
1197 yyval.id = g_strdup("char");
1203 yyval.id = g_strdup("double");
1209 yyval.id = g_strdup("float");
1215 yyval.id = yyvsp[0].id;
1221 yyval.id = g_strconcat(yyvsp[-1].id,yyvsp[0].id,NULL);
1222 g_free(yyvsp[0].id);
1228 yyval.id = yyvsp[0].id;
1234 yyval.id = g_strdup("void");
1240 yyval.id = "long int";
1252 yyval.id = "short int";
1276 yyval.id = "union ";
1282 yyval.id = "struct ";
1296 if(strcmp(yyvsp[-1].id,"first")==0)
1297 yyval.sigtype = PRIVATE_SIGNAL_FIRST_METHOD;
1298 else if(strcmp(yyvsp[-1].id,"last")==0)
1299 yyval.sigtype = PRIVATE_SIGNAL_LAST_METHOD;
1301 yyerror(_("signal must be 'first' or 'last'"));
1302 g_free(yyvsp[-1].id);
1305 g_free(yyvsp[-1].id);
1311 if(strcmp(yyvsp[-2].id,"first")==0)
1312 yyval.sigtype = PRIVATE_SIGNAL_FIRST_METHOD;
1313 else if(strcmp(yyvsp[-2].id,"last")==0)
1314 yyval.sigtype = PRIVATE_SIGNAL_LAST_METHOD;
1316 yyerror(_("signal must be 'first' or 'last'"));
1317 g_free(yyvsp[-2].id);
1320 g_free(yyvsp[-2].id);
1326 yyval.sigtype = PRIVATE_SIGNAL_LAST_METHOD;
1332 if(strcmp(yyvsp[-1].id,"first")==0)
1333 yyval.sigtype = SIGNAL_FIRST_METHOD;
1334 else if(strcmp(yyvsp[-1].id,"last")==0)
1335 yyval.sigtype = SIGNAL_LAST_METHOD;
1337 yyerror(_("signal must be 'first' or 'last'"));
1338 g_free(yyvsp[-1].id);
1341 g_free(yyvsp[-1].id);
1347 yyval.sigtype = SIGNAL_LAST_METHOD;
1353 gtktypes = g_list_prepend(gtktypes,yyvsp[-3].id);
1359 gtktypes = g_list_append(gtktypes,yyvsp[0].id);
1365 gtktypes = g_list_append(gtktypes,yyvsp[0].id);
1370 { yyval.cbuf=yyvsp[0].cbuf; ;
1374 { yyval.cbuf = NULL; ;
1380 yyerror(_("signal without 'self' as "
1381 "first parameter"));
1384 push_function(yyvsp[-7].sigtype,NULL,
1385 yyvsp[-5].id, yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-8].line,
1393 yyerror(_("virtual method without 'self' as "
1394 "first parameter"));
1397 push_function(PRIVATE_VIRTUAL_METHOD, NULL, yyvsp[-5].id,
1398 yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-8].line,
1406 yyerror(_("virtual method without 'self' as "
1407 "first parameter"));
1410 push_function(VIRTUAL_METHOD, NULL, yyvsp[-5].id,
1411 yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-7].line,
1418 push_function(OVERRIDE_METHOD, yyvsp[-9].id,
1419 yyvsp[-6].id, yyvsp[-2].id, yyvsp[0].cbuf,
1420 yyvsp[-11].line,yyvsp[-1].line,
1427 push_function(PUBLIC_SCOPE, NULL, yyvsp[-6].id,
1428 yyvsp[-2].id, yyvsp[0].cbuf,yyvsp[-8].line,yyvsp[-1].line,
1435 push_function(PRIVATE_SCOPE, NULL, yyvsp[-6].id,
1436 yyvsp[-2].id, yyvsp[0].cbuf,yyvsp[-8].line,yyvsp[-1].line,
1443 if(strcmp(yyvsp[-4].id,"init")==0) {
1444 push_init_arg(yyvsp[-2].id,FALSE);
1445 push_function(INIT_METHOD, NULL,
1446 yyvsp[-4].id, NULL, yyvsp[0].cbuf,yyvsp[-3].line,
1448 } else if(strcmp(yyvsp[-4].id,"class_init")==0) {
1449 push_init_arg(yyvsp[-2].id,TRUE);
1450 push_function(CLASS_INIT_METHOD, NULL,
1451 yyvsp[-4].id, NULL, yyvsp[0].cbuf,yyvsp[-3].line,
1454 g_free(yyvsp[-4].id);
1455 g_free(yyvsp[-2].id);
1456 g_string_free(yyvsp[-2].cbuf,TRUE);
1457 yyerror(_("parse error"));
1464 { yyval.id = yyvsp[0].id; ;
1469 yyval.id = (yyvsp[0].cbuf)->str;
1470 g_string_free(yyvsp[0].cbuf,FALSE);
1479 { yyval.id = NULL; ;
1483 { vararg = FALSE; has_self = FALSE; ;
1490 if(strcmp(yyvsp[0].id,"this")==0) {
1491 push_self(yyvsp[0].id);
1492 print_error(TRUE,_("Use of 'this' is "
1493 "depreciated, use 'self' "
1494 "instead"),line_no);
1495 } else if(strcmp(yyvsp[0].id,"self")==0)
1496 push_self(yyvsp[0].id);
1498 g_free(yyvsp[0].id);
1499 yyerror(_("parse error"));
1508 if(strcmp(yyvsp[-2].id,"this")==0) {
1509 push_self(yyvsp[-2].id);
1510 print_error(TRUE,_("Use of 'this' is "
1511 "depreciated, use 'self' "
1512 "instead"),line_no);
1513 } else if(strcmp(yyvsp[-2].id,"self")==0)
1514 push_self(yyvsp[-2].id);
1516 g_free(yyvsp[-2].id);
1517 yyerror(_("parse error"));
1524 { has_self = FALSE; ;
1545 push_funcarg(yyvsp[0].id);
1551 if(strcmp(yyvsp[-2].id,"check")!=0) {
1552 yyerror(_("parse error"));
1555 g_free(yyvsp[-2].id);
1556 push_funcarg(yyvsp[-4].id);
1570 if(strcmp(yyvsp[0].id,"type")==0) {
1571 Node *node = new_check(TYPE_CHECK,NULL);
1572 checks = g_list_append(checks,node);
1573 } else if(strcmp(yyvsp[0].id,"null")==0) {
1574 Node *node = new_check(NULL_CHECK,NULL);
1575 checks = g_list_append(checks,node);
1577 yyerror(_("parse error"));
1580 g_free(yyvsp[0].id);
1586 Node *node = new_check(GT_CHECK,yyvsp[0].id);
1587 checks = g_list_append(checks,node);
1593 Node *node = new_check(LT_CHECK,yyvsp[0].id);
1594 checks = g_list_append(checks,node);
1600 Node *node = new_check(GE_CHECK,yyvsp[0].id);
1601 checks = g_list_append(checks,node);
1607 Node *node = new_check(LE_CHECK,yyvsp[0].id);
1608 checks = g_list_append(checks,node);
1614 Node *node = new_check(EQ_CHECK,yyvsp[0].id);
1615 checks = g_list_append(checks,node);
1621 Node *node = new_check(NE_CHECK,yyvsp[0].id);
1622 checks = g_list_append(checks,node);
1627 { yyval.id = yyvsp[0].id; ;
1632 yyval.id = g_strconcat("-",yyvsp[0].id,NULL);
1633 g_free(yyvsp[0].id);
1638 { yyval.id = yyvsp[0].id; ;
1641 /* the action file gets copied in in place of this dollarsign */
1642 #line 498 "/usr/lib/bison.simple"
1653 short *ssp1 = yyss - 1;
1654 fprintf (stderr, "state stack now");
1655 while (ssp1 != yyssp)
1656 fprintf (stderr, " %d", *++ssp1);
1657 fprintf (stderr, "\n");
1667 yylsp->first_line = yylloc.first_line;
1668 yylsp->first_column = yylloc.first_column;
1669 yylsp->last_line = (yylsp-1)->last_line;
1670 yylsp->last_column = (yylsp-1)->last_column;
1675 yylsp->last_line = (yylsp+yylen-1)->last_line;
1676 yylsp->last_column = (yylsp+yylen-1)->last_column;
1680 /* Now "shift" the result of the reduction.
1681 Determine what state that goes to,
1682 based on the state we popped back to
1683 and the rule number reduced by. */
1687 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1688 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1689 yystate = yytable[yystate];
1691 yystate = yydefgoto[yyn - YYNTBASE];
1695 yyerrlab: /* here on detecting error */
1698 /* If not already recovering from an error, report this error. */
1702 #ifdef YYERROR_VERBOSE
1703 yyn = yypact[yystate];
1705 if (yyn > YYFLAG && yyn < YYLAST)
1712 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1713 for (x = (yyn < 0 ? -yyn : 0);
1714 x < (sizeof(yytname) / sizeof(char *)); x++)
1715 if (yycheck[x + yyn] == x)
1716 size += strlen(yytname[x]) + 15, count++;
1717 msg = (char *) malloc(size + 15);
1720 strcpy(msg, "parse error");
1725 for (x = (yyn < 0 ? -yyn : 0);
1726 x < (sizeof(yytname) / sizeof(char *)); x++)
1727 if (yycheck[x + yyn] == x)
1729 strcat(msg, count == 0 ? ", expecting `" : " or `");
1730 strcat(msg, yytname[x]);
1739 yyerror ("parse error; also virtual memory exceeded");
1742 #endif /* YYERROR_VERBOSE */
1743 yyerror("parse error");
1747 yyerrlab1: /* here on error raised explicitly by an action */
1749 if (yyerrstatus == 3)
1751 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1753 /* return failure if at end of input */
1754 if (yychar == YYEOF)
1759 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1765 /* Else will try to reuse lookahead token
1766 after shifting the error token. */
1768 yyerrstatus = 3; /* Each real token shifted decrements this */
1772 yyerrdefault: /* current state does not do anything special for the error token. */
1775 /* This is wrong; only states that explicitly want error tokens
1776 should shift them. */
1777 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1778 if (yyn) goto yydefault;
1781 yyerrpop: /* pop the current state because it cannot handle the error token */
1783 if (yyssp == yyss) YYABORT;
1793 short *ssp1 = yyss - 1;
1794 fprintf (stderr, "Error: state stack now");
1795 while (ssp1 != yyssp)
1796 fprintf (stderr, " %d", *++ssp1);
1797 fprintf (stderr, "\n");
1803 yyn = yypact[yystate];
1808 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1827 fprintf(stderr, "Shifting error token, ");