2 /* A Bison parser, made from parse.y
3 by GNU Bison version 1.27
6 #define YYBISON 1 /* Identify Bison output. */
49 extern char *filename;
53 static GList *class_nodes = NULL;
56 static GList *typestack = NULL;
58 static GList *funcargs = NULL;
59 static GList *checks = NULL;
60 static int has_this = FALSE;
62 static GList *gtktypes = NULL;
67 extern int ccode_line;
78 if(strcmp(yytext,"\n")==0) {
79 out=g_strconcat("Error: ",str," before newline",NULL);
80 } else if(yytext[0]=='\0') {
81 out=g_strconcat("Error: ",str," at end of input",NULL);
83 char *tmp = g_strdup(yytext);
84 while((p=strchr(tmp,'\n')))
87 out=g_strconcat("Error: ",str," before '",tmp,"'",NULL);
91 fprintf(stderr,"%s:%d: %s\n",filename,line_no,out);
98 push_variable(char *name, int scope)
101 Type *type = typestack->data;
102 typestack = g_list_remove(typestack,typestack->data);
104 var = new_variable(scope,type,name);
105 class_nodes = g_list_append(class_nodes, var);
109 push_function(int scope, char *oid, char *id, char *onerror,
110 GString *cbuf,int line_no, int ccode_line)
115 if(scope!=INIT_METHOD && scope!=CLASS_INIT_METHOD) {
116 type = typestack->data;
117 typestack = g_list_remove(typestack,typestack->data);
119 type = (Type *)new_type(0,g_strdup("void"));
122 node = new_method(scope,type,oid,gtktypes,id,funcargs,
123 onerror,cbuf,line_no,ccode_line);
127 class_nodes = g_list_append(class_nodes, node);
131 push_funcarg(char *name)
134 Type *type = typestack->data;
135 typestack = g_list_remove(typestack,typestack->data);
137 node = new_funcarg(type,name,checks);
140 funcargs = g_list_append(funcargs, node);
144 push_init_arg(char *name, int is_class)
151 tn = g_strconcat(((Class *)class)->otype,":Class",NULL);
153 tn = g_strdup(((Class *)class)->otype);
155 type = new_type(1,tn);
156 node = new_funcarg((Type *)type,name,NULL);
157 funcargs = g_list_prepend(funcargs, node);
161 push_this(char *this)
166 type = new_type(1,g_strdup(((Class *)class)->otype));
167 ch = g_list_append(ch,new_check(NULL_CHECK,NULL));
168 ch = g_list_append(ch,new_check(TYPE_CHECK,NULL));
169 node = new_funcarg((Type *)type,this,ch);
170 funcargs = g_list_prepend(funcargs, node);
196 #define YYFLAG -32768
199 #define YYTRANSLATE(x) ((unsigned)(x) <= 284 ? yytranslate[x] : 69)
201 static const char yytranslate[] = { 0,
202 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
203 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
204 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
205 2, 2, 43, 2, 2, 2, 2, 2, 2, 34,
206 35, 37, 2, 38, 44, 2, 2, 2, 40, 2,
207 2, 2, 2, 2, 2, 2, 2, 2, 33, 42,
208 39, 41, 2, 2, 2, 2, 2, 2, 2, 2,
209 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
210 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
211 2, 2, 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, 31, 36, 32, 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, 2, 2, 2, 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, 1, 3, 4, 5, 6,
228 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
229 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
234 static const short yyprhs[] = { 0,
235 0, 4, 7, 10, 12, 15, 18, 20, 22, 27,
236 32, 35, 38, 41, 43, 45, 47, 52, 57, 69,
237 78, 82, 83, 87, 89, 91, 94, 97, 100, 102,
238 105, 108, 110, 112, 114, 116, 119, 121, 123, 126,
239 128, 131, 133, 135, 137, 139, 141, 144, 146, 151,
240 155, 157, 169, 180, 191, 201, 211, 220, 233, 243,
241 253, 259, 266, 269, 272, 276, 279, 280, 282, 284,
242 288, 290, 294, 296, 299, 306, 309, 311, 313, 316,
243 319, 323, 327, 331, 335, 337
246 static const short yyrhs[] = { 46,
247 47, 46, 0, 47, 46, 0, 46, 47, 0, 47,
248 0, 46, 23, 0, 46, 24, 0, 23, 0, 24,
249 0, 48, 31, 49, 32, 0, 3, 22, 4, 22,
250 0, 49, 61, 0, 49, 50, 0, 49, 51, 0,
251 61, 0, 50, 0, 51, 0, 25, 54, 20, 33,
252 0, 26, 54, 20, 33, 0, 27, 52, 20, 20,
253 20, 31, 23, 20, 31, 23, 33, 0, 27, 52,
254 20, 20, 20, 31, 23, 33, 0, 34, 53, 35,
255 0, 0, 20, 36, 53, 0, 20, 0, 55, 0,
256 55, 58, 0, 10, 56, 0, 9, 56, 0, 56,
257 0, 10, 16, 0, 9, 16, 0, 16, 0, 15,
258 0, 14, 0, 20, 0, 57, 20, 0, 22, 0,
259 5, 0, 11, 13, 0, 11, 0, 12, 13, 0,
260 12, 0, 13, 0, 8, 0, 7, 0, 6, 0,
261 37, 58, 0, 37, 0, 20, 34, 60, 35, 0,
262 60, 38, 20, 0, 20, 0, 29, 20, 59, 54,
263 20, 34, 63, 35, 62, 31, 23, 0, 29, 20,
264 59, 54, 20, 34, 63, 35, 62, 33, 0, 29,
265 59, 54, 20, 34, 63, 35, 62, 31, 23, 0,
266 29, 59, 54, 20, 34, 63, 35, 62, 33, 0,
267 28, 54, 20, 34, 63, 35, 62, 31, 23, 0,
268 28, 54, 20, 34, 63, 35, 62, 33, 0, 30,
269 34, 22, 35, 54, 20, 34, 63, 35, 62, 31,
270 23, 0, 25, 54, 20, 34, 63, 35, 62, 31,
271 23, 0, 26, 54, 20, 34, 63, 35, 62, 31,
272 23, 0, 20, 34, 20, 35, 33, 0, 20, 34,
273 20, 35, 31, 23, 0, 19, 20, 0, 19, 68,
274 0, 19, 31, 23, 0, 39, 40, 0, 0, 5,
275 0, 20, 0, 20, 38, 64, 0, 64, 0, 64,
276 38, 65, 0, 65, 0, 54, 20, 0, 54, 20,
277 34, 20, 66, 35, 0, 66, 67, 0, 67, 0,
278 20, 0, 41, 68, 0, 42, 68, 0, 41, 39,
279 68, 0, 42, 39, 68, 0, 39, 39, 68, 0,
280 43, 39, 68, 0, 21, 0, 44, 21, 0
286 static const short yyrline[] = { 0,
287 176, 177, 178, 179, 182, 186, 190, 194, 200, 207,
288 212, 213, 214, 215, 216, 217, 220, 223, 227, 254,
289 278, 279, 282, 285, 291, 295, 302, 305, 308, 311,
290 314, 317, 320, 323, 326, 329, 333, 336, 341, 344,
291 347, 350, 353, 358, 361, 364, 369, 370, 373, 378,
292 381, 387, 408, 428, 437, 446, 450, 454, 458, 462,
293 466, 482, 503, 504, 505, 509, 510, 515, 516, 526,
294 536, 539, 540, 543, 546, 556, 557, 560, 573, 577,
295 581, 585, 589, 593, 599, 600
300 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
302 static const char * const yytname[] = { "$","error","$undefined.","CLASS",
303 "FROM","VOID","STRUCT","UNION","ENUM","SIGNED","UNSIGNED","LONG","SHORT","INT",
304 "FLOAT","DOUBLE","CHAR","FIRST","LAST","ONERROR","TOKEN","NUMBER","TYPETOKEN",
305 "CCODE","HCODE","PUBLIC","PRIVATE","ARGUMENT","VIRTUAL","SIGNAL","OVERRIDE",
306 "'{'","'}'","';'","'('","')'","'|'","'*'","','","'='","'1'","'>'","'<'","'!'",
307 "'-'","prog","ccodes","class","classdec","classcode","variable","argument","argflags",
308 "flaglist","type","type1","integer","tspecifier","stars","sigtype","tokenlist",
309 "method","onerror","funcargs","arglist","arg","checklist","check","number", NULL
313 static const short yyr1[] = { 0,
314 45, 45, 45, 45, 46, 46, 46, 46, 47, 48,
315 49, 49, 49, 49, 49, 49, 50, 50, 51, 51,
316 52, 52, 53, 53, 54, 54, 55, 55, 55, 55,
317 55, 55, 55, 55, 55, 55, 55, 55, 56, 56,
318 56, 56, 56, 57, 57, 57, 58, 58, 59, 60,
319 60, 61, 61, 61, 61, 61, 61, 61, 61, 61,
320 61, 61, 62, 62, 62, 62, 62, 63, 63, 63,
321 63, 64, 64, 65, 65, 66, 66, 67, 67, 67,
322 67, 67, 67, 67, 68, 68
325 static const short yyr2[] = { 0,
326 3, 2, 2, 1, 2, 2, 1, 1, 4, 4,
327 2, 2, 2, 1, 1, 1, 4, 4, 11, 8,
328 3, 0, 3, 1, 1, 2, 2, 2, 1, 2,
329 2, 1, 1, 1, 1, 2, 1, 1, 2, 1,
330 2, 1, 1, 1, 1, 1, 2, 1, 4, 3,
331 1, 11, 10, 10, 9, 9, 8, 12, 9, 9,
332 5, 6, 2, 2, 3, 2, 0, 1, 1, 3,
333 1, 3, 1, 2, 6, 2, 1, 1, 2, 2,
337 static const short yydefact[] = { 0,
338 0, 7, 8, 0, 4, 0, 0, 5, 6, 3,
339 2, 0, 0, 1, 0, 0, 0, 22, 0, 0,
340 0, 0, 15, 16, 14, 10, 0, 38, 46, 45,
341 44, 0, 0, 40, 42, 43, 34, 33, 32, 35,
342 37, 0, 25, 29, 0, 0, 0, 0, 0, 0,
343 0, 0, 9, 12, 13, 11, 0, 31, 28, 30,
344 27, 39, 41, 0, 48, 26, 36, 0, 24, 0,
345 0, 0, 0, 0, 0, 0, 0, 0, 17, 0,
346 47, 18, 0, 0, 21, 0, 0, 51, 0, 0,
347 0, 0, 0, 61, 38, 35, 0, 0, 71, 73,
348 0, 23, 0, 0, 49, 0, 0, 0, 0, 62,
349 0, 74, 67, 0, 67, 0, 67, 50, 0, 0,
350 0, 70, 0, 0, 0, 0, 72, 0, 0, 0,
351 0, 67, 0, 0, 63, 85, 0, 0, 64, 66,
352 0, 0, 0, 20, 0, 57, 67, 0, 0, 78,
353 0, 0, 0, 0, 0, 77, 65, 86, 59, 60,
354 0, 56, 0, 0, 55, 67, 0, 0, 79, 0,
355 80, 0, 75, 76, 0, 0, 53, 54, 0, 83,
356 81, 82, 84, 19, 52, 0, 58, 0, 0, 0
359 static const short yydefgoto[] = { 188,
360 4, 5, 6, 22, 23, 24, 48, 70, 97, 43,
361 44, 45, 66, 51, 89, 25, 126, 98, 99, 100,
365 static const short yypact[] = { 20,
366 34,-32768,-32768, 42, 37, -9, 60,-32768,-32768, 37,
367 44, 100, 69, 44, 78, 73, 73, 88, 73, 74,
368 97, 89,-32768,-32768,-32768,-32768, 120,-32768,-32768,-32768,
369 -32768, 0, 58, 128, 129,-32768,-32768,-32768,-32768,-32768,
370 -32768, 123, 107,-32768, 125, 126, 127, 130, 131, 28,
371 73, 132,-32768,-32768,-32768,-32768, 113,-32768,-32768,-32768,
372 -32768,-32768,-32768, 90, 107,-32768,-32768, 103, 116, 114,
373 133, 121, 122, 137, 73, 138, 124, 59,-32768, 91,
374 -32768,-32768, 91, 127,-32768, 140, 91,-32768, 14, 141,
375 134, 73, 139,-32768, 135, 16, 143, 136, 142,-32768,
376 144,-32768, 145, 146,-32768, 147, 148, 91, 149,-32768,
377 73, 150, 7, 73, 7, 151, 7,-32768, 91, 152,
378 154, 142, 153, -13, 155, 158,-32768, 159, 30, 77,
379 156, 7, 91, -3,-32768,-32768, 160, 157,-32768,-32768,
380 162, 163, 161,-32768, 170,-32768, 7, 101, 164,-32768,
381 165, -7, 3, 166, -14,-32768,-32768,-32768,-32768,-32768,
382 171,-32768, 102, 173,-32768, 7, -11, -11,-32768, -11,
383 -32768, -11,-32768,-32768, 167, 174,-32768,-32768, 172,-32768,
384 -32768,-32768,-32768,-32768,-32768, 175,-32768, 177, 201,-32768
387 static const short yypgoto[] = {-32768,
388 10, 168,-32768,-32768, 180, 184,-32768, 80, -16,-32768,
389 106,-32768, 110, 115,-32768, 185, -113, -78, 55, 94,
397 static const short yytable[] = { 42,
398 46, 128, 49, 130, 101, 150, 135, 136, 104, 136,
399 34, 35, 36, 136, 11, 58, 150, 137, 148, 14,
400 173, 12, 1, 136, 151, 124, 152, 153, 154, 120,
401 138, 168, 138, 163, 76, 151, 138, 152, 153, 154,
402 131, 170, 2, 3, 1, 125, 138, 73, 105, 143,
403 -69, 106, 179, 111, 149, 7, 169, 171, 90, 2,
404 3, 74, 144, 13, 8, 9, 8, 9, 34, 35,
405 36, 180, 181, 60, 182, 109, 183, 28, 29, 30,
406 31, 32, 33, 34, 35, 36, 37, 38, 39, 93,
407 26, 94, 40, 50, 41, 95, 29, 30, 31, 32,
408 33, 34, 35, 36, 37, 38, 39, 145, 15, 146,
409 96, 27, 41, 16, 17, 18, 19, 20, 21, 15,
410 53, 47, 79, 80, 16, 17, 18, 19, 20, 21,
411 52, 164, 176, 165, 177, 82, 83, 59, 61, 57,
412 62, 63, 64, 65, 67, 68, 69, 78, 85, 71,
413 72, 84, 86, 77, 87, 74, 88, 91, 92, 103,
414 107, 110, 112, 102, 75, 122, 118, 108, 121, -68,
415 113, 10, 134, 129, 81, 116, 189, 158, 115, 114,
416 117, 119, 157, 123, 159, 160, 132, 133, 141, 142,
417 147, 161, 162, 175, 140, 178, 185, 187, 166, 184,
418 190, 54, 186, 167, 172, 55, 56, 127, 174
421 static const short yycheck[] = { 16,
422 17, 115, 19, 117, 83, 20, 20, 21, 87, 21,
423 11, 12, 13, 21, 5, 16, 20, 31, 132, 10,
424 35, 31, 3, 21, 39, 19, 41, 42, 43, 108,
425 44, 39, 44, 147, 51, 39, 44, 41, 42, 43,
426 119, 39, 23, 24, 3, 39, 44, 20, 35, 20,
427 35, 38, 166, 38, 133, 22, 152, 153, 75, 23,
428 24, 34, 33, 4, 23, 24, 23, 24, 11, 12,
429 13, 167, 168, 16, 170, 92, 172, 5, 6, 7,
430 8, 9, 10, 11, 12, 13, 14, 15, 16, 31,
431 22, 33, 20, 20, 22, 5, 6, 7, 8, 9,
432 10, 11, 12, 13, 14, 15, 16, 31, 20, 33,
433 20, 34, 22, 25, 26, 27, 28, 29, 30, 20,
434 32, 34, 33, 34, 25, 26, 27, 28, 29, 30,
435 34, 31, 31, 33, 33, 33, 34, 32, 33, 20,
436 13, 13, 20, 37, 20, 20, 20, 35, 35, 20,
437 20, 36, 20, 22, 34, 34, 20, 20, 35, 20,
438 20, 23, 20, 84, 50, 111, 20, 34, 20, 35,
439 35, 4, 20, 23, 65, 31, 0, 21, 35, 38,
440 35, 34, 23, 34, 23, 23, 35, 34, 31, 31,
441 35, 31, 23, 23, 40, 23, 23, 23, 35, 33,
442 0, 22, 31, 39, 39, 22, 22, 114, 155
444 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
445 #line 3 "/usr/lib/bison.simple"
446 /* This file comes from bison-1.27. */
448 /* Skeleton output parser for bison,
449 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
451 This program is free software; you can redistribute it and/or modify
452 it under the terms of the GNU General Public License as published by
453 the Free Software Foundation; either version 2, or (at your option)
456 This program is distributed in the hope that it will be useful,
457 but WITHOUT ANY WARRANTY; without even the implied warranty of
458 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
459 GNU General Public License for more details.
461 You should have received a copy of the GNU General Public License
462 along with this program; if not, write to the Free Software
463 Foundation, Inc., 59 Temple Place - Suite 330,
464 Boston, MA 02111-1307, USA. */
466 /* As a special exception, when this file is copied by Bison into a
467 Bison output file, you may use that output file without restriction.
468 This special exception was added by the Free Software Foundation
469 in version 1.24 of Bison. */
471 /* This is the parser code that is written into each bison parser
472 when the %semantic_parser declaration is not specified in the grammar.
473 It was written by Richard Stallman by simplifying the hairy parser
474 used when %semantic_parser is specified. */
476 #ifndef YYSTACK_USE_ALLOCA
478 #define YYSTACK_USE_ALLOCA
479 #else /* alloca not defined */
481 #define YYSTACK_USE_ALLOCA
482 #define alloca __builtin_alloca
483 #else /* not GNU C. */
484 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
485 #define YYSTACK_USE_ALLOCA
487 #else /* not sparc */
488 /* We think this test detects Watcom and Microsoft C. */
489 /* This used to test MSDOS, but that is a bad idea
490 since that symbol is in the user namespace. */
491 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
492 #if 0 /* No need for malloc.h, which pollutes the namespace;
493 instead, just don't use alloca. */
496 #else /* not MSDOS, or __TURBOC__ */
498 /* I don't know what this was needed for, but it pollutes the namespace.
499 So I turned it off. rms, 2 May 1997. */
500 /* #include <malloc.h> */
502 #define YYSTACK_USE_ALLOCA
503 #else /* not MSDOS, or __TURBOC__, or _AIX */
505 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
506 and on HPUX 10. Eventually we can turn this on. */
507 #define YYSTACK_USE_ALLOCA
508 #define alloca __builtin_alloca
511 #endif /* not _AIX */
512 #endif /* not MSDOS, or __TURBOC__ */
513 #endif /* not sparc */
514 #endif /* not GNU C */
515 #endif /* alloca not defined */
516 #endif /* YYSTACK_USE_ALLOCA not defined */
518 #ifdef YYSTACK_USE_ALLOCA
519 #define YYSTACK_ALLOC alloca
521 #define YYSTACK_ALLOC malloc
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 goto yyacceptlab
533 #define YYABORT goto yyabortlab
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 /* Define __yy_memcpy. Note that the size argument
616 should be passed with type unsigned int, because that is what the non-GCC
617 definitions require. With GCC, __builtin_memcpy takes an arg
618 of type size_t, but it can handle unsigned int. */
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, unsigned int count)
648 register char *t = to;
649 register char *f = from;
650 register int i = count;
659 #line 216 "/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 */
680 /* Prevent warning if -Wstrict-prototypes. */
683 int yyparse (void *);
690 yyparse(YYPARSE_PARAM_ARG)
693 register int yystate;
695 register short *yyssp;
696 register YYSTYPE *yyvsp;
697 int yyerrstatus; /* number of tokens to shift before error messages enabled */
698 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
700 short yyssa[YYINITDEPTH]; /* the state stack */
701 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
703 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
704 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
707 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
708 YYLTYPE *yyls = yylsa;
711 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
713 #define YYPOPSTACK (yyvsp--, yyssp--)
716 int yystacksize = YYINITDEPTH;
717 int yyfree_stacks = 0;
728 YYSTYPE yyval; /* the variable used to return */
729 /* semantic values from the action */
736 fprintf(stderr, "Starting parse\n");
742 yychar = YYEMPTY; /* Cause a token to be read. */
744 /* Initialize stack pointers.
745 Waste one element of value and location stack
746 so that they stay on the same level as the state stack.
747 The wasted elements are never initialized. */
755 /* Push a new state, which is found in yystate . */
756 /* In all cases, when you get here, the value and location stacks
757 have just been pushed. so pushing a state here evens the stacks. */
762 if (yyssp >= yyss + yystacksize - 1)
764 /* Give user a chance to reallocate the stack */
765 /* Use copies of these so that the &'s don't force the real ones into memory. */
766 YYSTYPE *yyvs1 = yyvs;
769 YYLTYPE *yyls1 = yyls;
772 /* Get the current used size of the three stacks, in elements. */
773 int size = yyssp - yyss + 1;
776 /* Each stack pointer address is followed by the size of
777 the data in use in that stack, in bytes. */
779 /* This used to be a conditional around just the two extra args,
780 but that might be undefined if yyoverflow is a macro. */
781 yyoverflow("parser stack overflow",
782 &yyss1, size * sizeof (*yyssp),
783 &yyvs1, size * sizeof (*yyvsp),
784 &yyls1, size * sizeof (*yylsp),
787 yyoverflow("parser stack overflow",
788 &yyss1, size * sizeof (*yyssp),
789 &yyvs1, size * sizeof (*yyvsp),
793 yyss = yyss1; yyvs = yyvs1;
797 #else /* no yyoverflow */
798 /* Extend the stack our own way. */
799 if (yystacksize >= YYMAXDEPTH)
801 yyerror("parser stack overflow");
813 if (yystacksize > YYMAXDEPTH)
814 yystacksize = YYMAXDEPTH;
815 #ifndef YYSTACK_USE_ALLOCA
818 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
819 __yy_memcpy ((char *)yyss, (char *)yyss1,
820 size * (unsigned int) sizeof (*yyssp));
821 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
822 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
823 size * (unsigned int) sizeof (*yyvsp));
825 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
826 __yy_memcpy ((char *)yyls, (char *)yyls1,
827 size * (unsigned int) sizeof (*yylsp));
829 #endif /* no yyoverflow */
831 yyssp = yyss + size - 1;
832 yyvsp = yyvs + size - 1;
834 yylsp = yyls + size - 1;
839 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
842 if (yyssp >= yyss + yystacksize - 1)
848 fprintf(stderr, "Entering state %d\n", yystate);
854 /* Do appropriate processing given the current state. */
855 /* Read a lookahead token if we need one and don't already have one. */
858 /* First try to decide what to do without reference to lookahead token. */
860 yyn = yypact[yystate];
864 /* Not known => get a lookahead token if don't already have one. */
866 /* yychar is either YYEMPTY or YYEOF
867 or a valid token in external form. */
869 if (yychar == YYEMPTY)
873 fprintf(stderr, "Reading a token: ");
878 /* Convert token to internal form (in yychar1) for indexing tables with */
880 if (yychar <= 0) /* This means end of input. */
883 yychar = YYEOF; /* Don't call YYLEX any more */
887 fprintf(stderr, "Now at end of input.\n");
892 yychar1 = YYTRANSLATE(yychar);
897 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
898 /* Give the individual parser a way to print the precise meaning
899 of a token, for further debugging info. */
901 YYPRINT (stderr, yychar, yylval);
903 fprintf (stderr, ")\n");
909 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
914 /* yyn is what to do for this token type in this state.
915 Negative => reduce, -yyn is rule number.
916 Positive => shift, yyn is new state.
917 New state is final state => don't bother to shift,
919 0, or most negative number => error. */
934 /* Shift the lookahead token. */
938 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
941 /* Discard the token being shifted unless it is eof. */
950 /* count tokens shifted since error; after three, turn off error status. */
951 if (yyerrstatus) yyerrstatus--;
956 /* Do the default action for the current state. */
959 yyn = yydefact[yystate];
963 /* Do a reduction. yyn is the number of a rule to reduce with. */
967 yyval = yyvsp[1-yylen]; /* implement default value of the action */
974 fprintf (stderr, "Reducing via rule %d (line %d), ",
977 /* Print the symbols being reduced, and their result. */
978 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
979 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
980 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1006 Node *node = new_ccode(FALSE,yyvsp[0].cbuf,ccode_line);
1007 nodes = g_list_append(nodes,node);
1013 Node *node = new_ccode(TRUE,yyvsp[0].cbuf,ccode_line);
1014 nodes = g_list_append(nodes,node);
1020 Node *node = new_ccode(FALSE,yyvsp[0].cbuf,ccode_line);
1021 nodes = g_list_append(nodes,node);
1027 Node *node = new_ccode(TRUE,yyvsp[0].cbuf,ccode_line);
1028 nodes = g_list_append(nodes,node);
1034 ((Class *)class)->nodes = class_nodes;
1036 nodes = g_list_append(nodes,class);
1042 class = new_class(yyvsp[-2].id,yyvsp[0].id,NULL);
1072 push_variable(yyvsp[-1].id,PUBLIC_SCOPE);
1078 push_variable(yyvsp[-1].id,PRIVATE_SCOPE);
1084 if(strcmp(yyvsp[-6].id,"get")==0 &&
1085 strcmp(yyvsp[-3].id,"set")==0) {
1087 g_free(yyvsp[-6].id); g_free(yyvsp[-3].id);
1088 node = new_argument(yyvsp[-8].id,yyvsp[-9].list,yyvsp[-7].id,
1089 yyvsp[-4].cbuf,yyvsp[-5].line,
1090 yyvsp[-1].cbuf,yyvsp[-2].line);
1091 class_nodes = g_list_append(class_nodes,node);
1092 } else if(strcmp(yyvsp[-6].id,"set")==0 &&
1093 strcmp(yyvsp[-3].id,"get")==0) {
1095 g_free(yyvsp[-6].id); g_free(yyvsp[-3].id);
1096 node = new_argument(yyvsp[-8].id,yyvsp[-9].list,yyvsp[-7].id,
1097 yyvsp[-1].cbuf,yyvsp[-2].line,
1098 yyvsp[-4].cbuf,yyvsp[-5].line);
1099 class_nodes = g_list_append(class_nodes,node);
1101 g_free(yyvsp[-8].id); g_free(yyvsp[-7].id);
1102 g_free(yyvsp[-6].id); g_free(yyvsp[-3].id);
1103 g_list_foreach(yyvsp[-9].list,(GFunc)g_free,NULL);
1104 g_string_free(yyvsp[-1].cbuf,TRUE);
1105 g_string_free(yyvsp[-4].cbuf,TRUE);
1106 yyerror(_("parse error"));
1114 if(strcmp(yyvsp[-3].id,"get")==0) {
1116 g_free(yyvsp[-3].id);
1117 node = new_argument(yyvsp[-5].id,yyvsp[-6].list,yyvsp[-4].id,
1118 yyvsp[-1].cbuf,yyvsp[-2].line,NULL,0);
1119 class_nodes = g_list_append(class_nodes,node);
1120 } else if(strcmp(yyvsp[-3].id,"set")==0) {
1122 g_free(yyvsp[-3].id);
1123 node = new_argument(yyvsp[-5].id,yyvsp[-6].list,yyvsp[-4].id,
1124 NULL,0,yyvsp[-1].cbuf,yyvsp[-2].line);
1125 class_nodes = g_list_append(class_nodes,node);
1127 g_free(yyvsp[-3].id); g_free(yyvsp[-5].id);
1128 g_free(yyvsp[-4].id);
1129 g_list_foreach(yyvsp[-6].list,(GFunc)g_free,NULL);
1130 g_string_free(yyvsp[-1].cbuf,TRUE);
1131 yyerror(_("parse error"));
1138 { yyval.list = yyvsp[-1].list; ;
1142 { yyval.list = NULL; ;
1147 yyval.list = g_list_append(yyvsp[0].list,yyvsp[-2].id);
1153 yyval.list = g_list_append(NULL,yyvsp[0].id);
1159 Node *node = new_type(0,yyvsp[0].id);
1160 typestack = g_list_prepend(typestack,node);
1166 Node *node = new_type(stars,yyvsp[-1].id);
1168 typestack = g_list_prepend(typestack,node);
1174 yyval.id = g_strconcat("unsigned ",yyvsp[0].id,NULL);
1180 yyval.id = g_strconcat("signed ",yyvsp[0].id,NULL);
1186 yyval.id = g_strdup(yyvsp[0].id);
1192 yyval.id = g_strdup("unsigned char");
1198 yyval.id = g_strdup("signed char");
1204 yyval.id = g_strdup("char");
1210 yyval.id = g_strdup("double");
1216 yyval.id = g_strdup("float");
1222 yyval.id = yyvsp[0].id;
1228 yyval.id = g_strconcat(yyvsp[-1].id,yyvsp[0].id,NULL);
1229 g_free(yyvsp[0].id);
1235 yyval.id = yyvsp[0].id;
1241 yyval.id = g_strdup("void");
1247 yyval.id = "long int";
1259 yyval.id = "short int";
1283 yyval.id = "union ";
1289 yyval.id = "struct ";
1303 gtktypes = g_list_prepend(gtktypes,yyvsp[-3].id);
1309 gtktypes = g_list_append(gtktypes,yyvsp[0].id);
1315 gtktypes = g_list_append(gtktypes,yyvsp[0].id);
1321 int sigtype = SIGNAL_LAST_METHOD;
1322 if(strcmp(yyvsp[-9].id,"first")==0)
1323 sigtype = SIGNAL_FIRST_METHOD;
1324 else if(strcmp(yyvsp[-9].id,"last")==0)
1325 sigtype = SIGNAL_LAST_METHOD;
1327 yyerror(_("signal must be 'first' or 'last'"));
1328 g_free(yyvsp[-9].id);
1331 g_free(yyvsp[-9].id);
1334 yyerror(_("signal without 'this' as "
1335 "first parameter"));
1338 push_function(sigtype,NULL,
1339 yyvsp[-6].id, yyvsp[-2].id, yyvsp[0].cbuf,yyvsp[-10].line,yyvsp[-1].line);
1345 int sigtype = SIGNAL_LAST_METHOD;
1346 if(strcmp(yyvsp[-8].id,"first")==0)
1347 sigtype = SIGNAL_FIRST_METHOD;
1348 else if(strcmp(yyvsp[-8].id,"last")==0)
1349 sigtype = SIGNAL_LAST_METHOD;
1351 yyerror(_("signal must be 'first' or 'last'"));
1352 g_free(yyvsp[-8].id);
1355 g_free(yyvsp[-8].id);
1357 yyerror(_("signal without 'this' as "
1358 "first parameter"));
1361 push_function(sigtype, NULL,
1362 yyvsp[-5].id, yyvsp[-1].id, NULL,yyvsp[-9].line,0);
1369 yyerror(_("signal without 'this' as "
1370 "first parameter"));
1373 push_function(SIGNAL_LAST_METHOD, NULL,
1374 yyvsp[-6].id, yyvsp[-2].id, yyvsp[0].cbuf,yyvsp[-9].line,yyvsp[-1].line);
1381 yyerror(_("signal without 'this' as "
1382 "first parameter"));
1385 push_function(SIGNAL_LAST_METHOD, NULL, yyvsp[-5].id,
1386 yyvsp[-1].id, NULL,yyvsp[-8].line,0);
1392 push_function(VIRTUAL_METHOD, NULL, yyvsp[-6].id,
1393 yyvsp[-2].id, yyvsp[0].cbuf,yyvsp[-8].line,yyvsp[-1].line);
1399 push_function(VIRTUAL_METHOD, NULL, yyvsp[-5].id,
1400 yyvsp[-1].id, NULL,yyvsp[-7].line,0);
1406 push_function(OVERRIDE_METHOD, yyvsp[-9].id,
1407 yyvsp[-6].id, yyvsp[-2].id, yyvsp[0].cbuf,yyvsp[-11].line,yyvsp[-1].line);
1413 push_function(PUBLIC_SCOPE, NULL, yyvsp[-6].id,
1414 yyvsp[-2].id, yyvsp[0].cbuf,yyvsp[-8].line,yyvsp[-1].line);
1420 push_function(PRIVATE_SCOPE, NULL, yyvsp[-6].id,
1421 yyvsp[-2].id, yyvsp[0].cbuf,yyvsp[-8].line,yyvsp[-1].line);
1427 if(strcmp(yyvsp[-4].id,"init")==0) {
1428 push_init_arg(yyvsp[-2].id,FALSE);
1429 push_function(INIT_METHOD, NULL, yyvsp[-4].id,
1430 NULL, NULL,yyvsp[-3].line,0);
1431 } else if(strcmp(yyvsp[-4].id,"class_init")==0) {
1432 push_init_arg(yyvsp[-2].id,TRUE);
1433 push_function(CLASS_INIT_METHOD, NULL,
1434 yyvsp[-4].id, NULL, NULL,yyvsp[-3].line,0);
1436 g_free(yyvsp[-4].id);
1437 g_free(yyvsp[-2].id);
1438 yyerror(_("parse error"));
1446 if(strcmp(yyvsp[-5].id,"init")==0) {
1447 push_init_arg(yyvsp[-3].id,FALSE);
1448 push_function(INIT_METHOD, NULL,
1449 yyvsp[-5].id, NULL, yyvsp[0].cbuf,yyvsp[-4].line,
1451 } else if(strcmp(yyvsp[-5].id,"class_init")==0) {
1452 push_init_arg(yyvsp[-3].id,TRUE);
1453 push_function(CLASS_INIT_METHOD, NULL,
1454 yyvsp[-5].id, NULL, yyvsp[0].cbuf,yyvsp[-4].line,
1457 g_free(yyvsp[-5].id);
1458 g_free(yyvsp[-3].id);
1459 g_string_free(yyvsp[-3].cbuf,TRUE);
1460 yyerror(_("parse error"));
1467 { yyval.id = yyvsp[0].id; ;
1471 { yyval.id = yyvsp[0].id; ;
1476 yyval.id = (yyvsp[0].cbuf)->str;
1477 g_string_free(yyvsp[0].cbuf,FALSE);
1486 { yyval.id = NULL; ;
1490 { has_this = FALSE; ;
1496 if(strcmp(yyvsp[0].id,"this")==0)
1497 push_this(yyvsp[0].id);
1499 g_free(yyvsp[0].id);
1500 yyerror(_("parse error"));
1509 if(strcmp(yyvsp[-2].id,"this")==0)
1510 push_this(yyvsp[-2].id);
1512 g_free(yyvsp[-2].id);
1513 yyerror(_("parse error"));
1520 { has_this = FALSE; ;
1533 push_funcarg(yyvsp[0].id);
1539 if(strcmp(yyvsp[-2].id,"check")!=0) {
1540 yyerror(_("parse error"));
1543 g_free(yyvsp[-2].id);
1544 push_funcarg(yyvsp[-4].id);
1558 if(strcmp(yyvsp[0].id,"type")==0) {
1559 Node *node = new_check(TYPE_CHECK,NULL);
1560 checks = g_list_append(checks,node);
1561 } else if(strcmp(yyvsp[0].id,"null")==0) {
1562 Node *node = new_check(NULL_CHECK,NULL);
1563 checks = g_list_append(checks,node);
1565 yyerror(_("parse error"));
1568 g_free(yyvsp[0].id);
1574 Node *node = new_check(GT_CHECK,yyvsp[0].id);
1575 checks = g_list_append(checks,node);
1581 Node *node = new_check(LT_CHECK,yyvsp[0].id);
1582 checks = g_list_append(checks,node);
1588 Node *node = new_check(GE_CHECK,yyvsp[0].id);
1589 checks = g_list_append(checks,node);
1595 Node *node = new_check(LE_CHECK,yyvsp[0].id);
1596 checks = g_list_append(checks,node);
1602 Node *node = new_check(EQ_CHECK,yyvsp[0].id);
1603 checks = g_list_append(checks,node);
1609 Node *node = new_check(NE_CHECK,yyvsp[0].id);
1610 checks = g_list_append(checks,node);
1615 { yyval.id = yyvsp[0].id; ;
1620 yyval.id = g_strconcat("-",yyvsp[0].id,NULL);
1621 g_free(yyvsp[0].id);
1625 /* the action file gets copied in in place of this dollarsign */
1626 #line 542 "/usr/lib/bison.simple"
1637 short *ssp1 = yyss - 1;
1638 fprintf (stderr, "state stack now");
1639 while (ssp1 != yyssp)
1640 fprintf (stderr, " %d", *++ssp1);
1641 fprintf (stderr, "\n");
1651 yylsp->first_line = yylloc.first_line;
1652 yylsp->first_column = yylloc.first_column;
1653 yylsp->last_line = (yylsp-1)->last_line;
1654 yylsp->last_column = (yylsp-1)->last_column;
1659 yylsp->last_line = (yylsp+yylen-1)->last_line;
1660 yylsp->last_column = (yylsp+yylen-1)->last_column;
1664 /* Now "shift" the result of the reduction.
1665 Determine what state that goes to,
1666 based on the state we popped back to
1667 and the rule number reduced by. */
1671 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1672 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1673 yystate = yytable[yystate];
1675 yystate = yydefgoto[yyn - YYNTBASE];
1679 yyerrlab: /* here on detecting error */
1682 /* If not already recovering from an error, report this error. */
1686 #ifdef YYERROR_VERBOSE
1687 yyn = yypact[yystate];
1689 if (yyn > YYFLAG && yyn < YYLAST)
1696 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1697 for (x = (yyn < 0 ? -yyn : 0);
1698 x < (sizeof(yytname) / sizeof(char *)); x++)
1699 if (yycheck[x + yyn] == x)
1700 size += strlen(yytname[x]) + 15, count++;
1701 msg = (char *) malloc(size + 15);
1704 strcpy(msg, "parse error");
1709 for (x = (yyn < 0 ? -yyn : 0);
1710 x < (sizeof(yytname) / sizeof(char *)); x++)
1711 if (yycheck[x + yyn] == x)
1713 strcat(msg, count == 0 ? ", expecting `" : " or `");
1714 strcat(msg, yytname[x]);
1723 yyerror ("parse error; also virtual memory exceeded");
1726 #endif /* YYERROR_VERBOSE */
1727 yyerror("parse error");
1731 yyerrlab1: /* here on error raised explicitly by an action */
1733 if (yyerrstatus == 3)
1735 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1737 /* return failure if at end of input */
1738 if (yychar == YYEOF)
1743 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1749 /* Else will try to reuse lookahead token
1750 after shifting the error token. */
1752 yyerrstatus = 3; /* Each real token shifted decrements this */
1756 yyerrdefault: /* current state does not do anything special for the error token. */
1759 /* This is wrong; only states that explicitly want error tokens
1760 should shift them. */
1761 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1762 if (yyn) goto yydefault;
1765 yyerrpop: /* pop the current state because it cannot handle the error token */
1767 if (yyssp == yyss) YYABORT;
1777 short *ssp1 = yyss - 1;
1778 fprintf (stderr, "Error: state stack now");
1779 while (ssp1 != yyssp)
1780 fprintf (stderr, " %d", *++ssp1);
1781 fprintf (stderr, "\n");
1787 yyn = yypact[yystate];
1792 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1811 fprintf(stderr, "Shifting error token, ");
1823 /* YYACCEPT comes here. */
1835 /* YYABORT comes here. */