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;
63 static GList *gtktypes = NULL;
68 extern int ccode_line;
79 if(strcmp(yytext,"\n")==0) {
80 out=g_strconcat("Error: ",str," before newline",NULL);
81 } else if(yytext[0]=='\0') {
82 out=g_strconcat("Error: ",str," at end of input",NULL);
84 char *tmp = g_strdup(yytext);
85 while((p=strchr(tmp,'\n')))
88 out=g_strconcat("Error: ",str," before '",tmp,"'",NULL);
92 fprintf(stderr,"%s:%d: %s\n",filename,line_no,out);
99 push_variable(char *name, int scope, int line_no)
102 Type *type = typestack->data;
103 typestack = g_list_remove(typestack,typestack->data);
105 var = new_variable(scope,type,name,line_no);
106 class_nodes = g_list_append(class_nodes, var);
110 push_function(int scope, char *oid, char *id, char *onerror,
111 GString *cbuf,int line_no, int ccode_line)
116 if(scope!=INIT_METHOD && scope!=CLASS_INIT_METHOD) {
117 type = typestack->data;
118 typestack = g_list_remove(typestack,typestack->data);
120 type = (Type *)new_type(0,g_strdup("void"));
123 node = new_method(scope,type,oid,gtktypes,id,funcargs,
124 onerror,cbuf,line_no,ccode_line);
128 class_nodes = g_list_append(class_nodes, node);
132 push_funcarg(char *name)
135 Type *type = typestack->data;
136 typestack = g_list_remove(typestack,typestack->data);
138 node = new_funcarg(type,name,checks);
141 funcargs = g_list_append(funcargs, node);
145 push_init_arg(char *name, int is_class)
152 tn = g_strconcat(((Class *)class)->otype,":Class",NULL);
154 tn = g_strdup(((Class *)class)->otype);
156 type = new_type(1,tn);
157 node = new_funcarg((Type *)type,name,NULL);
158 funcargs = g_list_prepend(funcargs, node);
167 type = new_type(1,g_strdup(((Class *)class)->otype));
168 ch = g_list_append(ch,new_check(NULL_CHECK,NULL));
169 ch = g_list_append(ch,new_check(TYPE_CHECK,NULL));
170 node = new_funcarg((Type *)type,id,ch);
171 funcargs = g_list_prepend(funcargs, node);
197 #define YYFLAG -32768
200 #define YYTRANSLATE(x) ((unsigned)(x) <= 285 ? yytranslate[x] : 70)
202 static const char yytranslate[] = { 0,
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, 2, 2, 2, 2, 2, 2, 2, 2,
206 2, 2, 43, 2, 2, 2, 2, 2, 2, 34,
207 35, 37, 2, 38, 44, 2, 2, 2, 40, 2,
208 2, 2, 2, 2, 2, 2, 2, 2, 33, 42,
209 39, 41, 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, 2, 2, 2, 2, 2, 2, 2, 2,
215 2, 2, 31, 36, 32, 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, 2, 2, 2, 2, 2,
228 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
229 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
230 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
235 static const short yyprhs[] = { 0,
236 0, 4, 7, 10, 12, 15, 18, 20, 22, 27,
237 32, 35, 38, 41, 43, 45, 47, 52, 57, 69,
238 78, 82, 83, 87, 89, 91, 94, 97, 100, 102,
239 105, 108, 110, 112, 114, 116, 119, 121, 123, 126,
240 128, 131, 133, 135, 137, 139, 141, 144, 146, 151,
241 155, 157, 160, 162, 173, 183, 192, 205, 215, 225,
242 231, 238, 241, 245, 248, 249, 251, 253, 257, 259,
243 263, 265, 268, 275, 278, 280, 282, 285, 288, 292,
244 296, 300, 304, 306, 309
247 static const short yyrhs[] = { 46,
248 47, 46, 0, 47, 46, 0, 46, 47, 0, 47,
249 0, 46, 23, 0, 46, 24, 0, 23, 0, 24,
250 0, 48, 31, 49, 32, 0, 3, 22, 4, 22,
251 0, 49, 62, 0, 49, 50, 0, 49, 51, 0,
252 62, 0, 50, 0, 51, 0, 25, 54, 20, 33,
253 0, 26, 54, 20, 33, 0, 27, 52, 20, 20,
254 20, 31, 23, 20, 31, 23, 33, 0, 27, 52,
255 20, 20, 20, 31, 23, 33, 0, 34, 53, 35,
256 0, 0, 20, 36, 53, 0, 20, 0, 55, 0,
257 55, 58, 0, 10, 56, 0, 9, 56, 0, 56,
258 0, 10, 16, 0, 9, 16, 0, 16, 0, 15,
259 0, 14, 0, 20, 0, 57, 20, 0, 22, 0,
260 5, 0, 11, 13, 0, 11, 0, 12, 13, 0,
261 12, 0, 13, 0, 8, 0, 7, 0, 6, 0,
262 37, 58, 0, 37, 0, 20, 34, 60, 35, 0,
263 60, 38, 20, 0, 20, 0, 31, 23, 0, 33,
264 0, 29, 20, 59, 54, 20, 34, 64, 35, 63,
265 61, 0, 29, 59, 54, 20, 34, 64, 35, 63,
266 61, 0, 28, 54, 20, 34, 64, 35, 63, 61,
267 0, 30, 34, 22, 35, 54, 20, 34, 64, 35,
268 63, 31, 23, 0, 25, 54, 20, 34, 64, 35,
269 63, 31, 23, 0, 26, 54, 20, 34, 64, 35,
270 63, 31, 23, 0, 20, 34, 20, 35, 33, 0,
271 20, 34, 20, 35, 31, 23, 0, 19, 69, 0,
272 19, 31, 23, 0, 39, 40, 0, 0, 5, 0,
273 20, 0, 20, 38, 65, 0, 65, 0, 65, 38,
274 66, 0, 66, 0, 54, 20, 0, 54, 20, 34,
275 20, 67, 35, 0, 67, 68, 0, 68, 0, 20,
276 0, 41, 69, 0, 42, 69, 0, 41, 39, 69,
277 0, 42, 39, 69, 0, 39, 39, 69, 0, 43,
278 39, 69, 0, 21, 0, 44, 21, 0, 20, 0
284 static const short yyrline[] = { 0,
285 177, 178, 179, 180, 183, 187, 191, 195, 201, 208,
286 213, 214, 215, 216, 217, 218, 221, 224, 228, 257,
287 283, 284, 287, 290, 296, 300, 307, 310, 313, 316,
288 319, 322, 325, 328, 331, 334, 338, 341, 346, 349,
289 352, 355, 358, 363, 366, 369, 374, 375, 378, 383,
290 386, 391, 392, 396, 417, 426, 435, 439, 443, 447,
291 463, 484, 485, 489, 490, 495, 496, 511, 526, 529,
292 530, 533, 536, 546, 547, 550, 563, 567, 571, 575,
293 579, 583, 589, 590, 594
298 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
300 static const char * const yytname[] = { "$","error","$undefined.","CLASS",
301 "FROM","VOID","STRUCT","UNION","ENUM","SIGNED","UNSIGNED","LONG","SHORT","INT",
302 "FLOAT","DOUBLE","CHAR","FIRST","LAST","ONERROR","TOKEN","NUMBER","TYPETOKEN",
303 "CCODE","HCODE","PUBLIC","PRIVATE","ARGUMENT","VIRTUAL","SIGNAL","OVERRIDE",
304 "'{'","'}'","';'","'('","')'","'|'","'*'","','","'='","'1'","'>'","'<'","'!'",
305 "'-'","prog","ccodes","class","classdec","classcode","variable","argument","argflags",
306 "flaglist","type","type1","integer","tspecifier","stars","sigtype","tokenlist",
307 "codenocode","method","onerror","funcargs","arglist","arg","checklist","check",
312 static const short yyr1[] = { 0,
313 45, 45, 45, 45, 46, 46, 46, 46, 47, 48,
314 49, 49, 49, 49, 49, 49, 50, 50, 51, 51,
315 52, 52, 53, 53, 54, 54, 55, 55, 55, 55,
316 55, 55, 55, 55, 55, 55, 55, 55, 56, 56,
317 56, 56, 56, 57, 57, 57, 58, 58, 59, 60,
318 60, 61, 61, 62, 62, 62, 62, 62, 62, 62,
319 62, 63, 63, 63, 63, 64, 64, 64, 64, 65,
320 65, 66, 66, 67, 67, 68, 68, 68, 68, 68,
324 static const short yyr2[] = { 0,
325 3, 2, 2, 1, 2, 2, 1, 1, 4, 4,
326 2, 2, 2, 1, 1, 1, 4, 4, 11, 8,
327 3, 0, 3, 1, 1, 2, 2, 2, 1, 2,
328 2, 1, 1, 1, 1, 2, 1, 1, 2, 1,
329 2, 1, 1, 1, 1, 1, 2, 1, 4, 3,
330 1, 2, 1, 10, 9, 8, 12, 9, 9, 5,
331 6, 2, 3, 2, 0, 1, 1, 3, 1, 3,
332 1, 2, 6, 2, 1, 1, 2, 2, 3, 3,
336 static const short yydefact[] = { 0,
337 0, 7, 8, 0, 4, 0, 0, 5, 6, 3,
338 2, 0, 0, 1, 0, 0, 0, 22, 0, 0,
339 0, 0, 15, 16, 14, 10, 0, 38, 46, 45,
340 44, 0, 0, 40, 42, 43, 34, 33, 32, 35,
341 37, 0, 25, 29, 0, 0, 0, 0, 0, 0,
342 0, 0, 9, 12, 13, 11, 0, 31, 28, 30,
343 27, 39, 41, 0, 48, 26, 36, 0, 24, 0,
344 0, 0, 0, 0, 0, 0, 0, 0, 17, 0,
345 47, 18, 0, 0, 21, 0, 0, 51, 0, 0,
346 0, 0, 0, 60, 38, 35, 0, 0, 69, 71,
347 0, 23, 0, 0, 49, 0, 0, 0, 0, 61,
348 0, 72, 65, 0, 65, 0, 65, 50, 0, 0,
349 0, 68, 0, 0, 0, 0, 70, 0, 0, 0,
350 0, 65, 0, 0, 85, 83, 0, 0, 62, 64,
351 0, 0, 0, 20, 0, 53, 56, 65, 0, 0,
352 76, 0, 0, 0, 0, 0, 75, 63, 84, 58,
353 59, 0, 52, 0, 55, 65, 0, 0, 77, 0,
354 78, 0, 73, 74, 0, 54, 0, 81, 79, 80,
355 82, 19, 0, 57, 0, 0, 0
358 static const short yydefgoto[] = { 185,
359 4, 5, 6, 22, 23, 24, 48, 70, 97, 43,
360 44, 45, 66, 51, 89, 147, 25, 126, 98, 99,
364 static const short yypact[] = { 26,
365 -14,-32768,-32768, 37, 51, -6, 43,-32768,-32768, 51,
366 98, 99, 8, 98, 20, 72, 72, 24, 72, 52,
367 57, 88,-32768,-32768,-32768,-32768, 69,-32768,-32768,-32768,
368 -32768, 119, 125, 94, 96,-32768,-32768,-32768,-32768,-32768,
369 -32768, 91, 86,-32768, 120, 127, 128, 129, 130, 33,
370 72, 131,-32768,-32768,-32768,-32768, 116,-32768,-32768,-32768,
371 -32768,-32768,-32768, 100, 86,-32768,-32768, 110, 118, 117,
372 135, 122, 123, 138, 72, 139, 126, 31,-32768, 90,
373 -32768,-32768, 90, 128,-32768, 140, 90,-32768, 55, 142,
374 132, 72, 141,-32768, 133, 104, 143, 134, 136,-32768,
375 137,-32768, 144, 145,-32768, 147, 148, 90, 150,-32768,
376 72, 149, -17, 72, -17, 153, -17,-32768, 90, 146,
377 151, 136, 157, -11, 152, 155,-32768, 156, 36, 40,
378 154, -17, 90, -15,-32768,-32768, 161, 158,-32768,-32768,
379 165, 167, 160,-32768, 170,-32768,-32768, -17, 40, 159,
380 -32768, 162, -8, -5, 163, 3,-32768,-32768,-32768,-32768,
381 -32768, 172,-32768, 40,-32768, -17, -3, -3,-32768, -3,
382 -32768, -3,-32768,-32768, 164,-32768, 168,-32768,-32768,-32768,
383 -32768,-32768, 173,-32768, 171, 178,-32768
386 static const short yypgoto[] = {-32768,
387 9, 169,-32768,-32768, 176, 181,-32768, 81, -16,-32768,
388 113,-32768, 166, 174,-32768, -101, 182, -111, -76, 89,
396 static const short yytable[] = { 42,
397 46, 124, 49, 128, 151, 130, 101, 7, 135, 136,
398 104, 135, 136, 11, 135, 136, 135, 136, 14, 137,
399 149, 125, 151, 152, 12, 153, 154, 155, 1, 26,
400 168, 120, 138, 170, 76, 138, 164, 173, 138, 1,
401 138, 152, 131, 153, 154, 155, 13, 165, 2, 3,
402 169, 171, 73, 27, 177, 143, 150, 47, 90, 8,
403 9, 93, 176, 94, 178, 179, 74, 180, 144, 181,
404 145, 50, 146, 2, 3, 109, 28, 29, 30, 31,
405 32, 33, 34, 35, 36, 37, 38, 39, 57, 105,
406 52, 40, 106, 41, 95, 29, 30, 31, 32, 33,
407 34, 35, 36, 37, 38, 39, 62, 15, 63, 96,
408 64, 41, 16, 17, 18, 19, 20, 21, 15, 53,
409 8, 9, 65, 16, 17, 18, 19, 20, 21, 34,
410 35, 36, 79, 80, 58, 34, 35, 36, -67, 67,
411 60, 111, 82, 83, 59, 61, 68, 69, 71, 72,
412 78, 85, 77, 84, 86, 87, 74, 88, 91, 103,
413 92, 107, 112, 110, 102, 108, 118, -66, 113, 121,
414 186, 115, 10, 114, 116, 129, 134, 187, 159, 117,
415 132, 119, 123, 158, 133, 141, 142, 160, 148, 161,
416 162, 140, 163, 166, 175, 184, 182, 54, 183, 122,
417 167, 172, 55, 56, 174, 127, 0, 0, 0, 0,
418 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
419 0, 0, 0, 75, 0, 0, 0, 0, 0, 0,
423 static const short yycheck[] = { 16,
424 17, 19, 19, 115, 20, 117, 83, 22, 20, 21,
425 87, 20, 21, 5, 20, 21, 20, 21, 10, 31,
426 132, 39, 20, 39, 31, 41, 42, 43, 3, 22,
427 39, 108, 44, 39, 51, 44, 148, 35, 44, 3,
428 44, 39, 119, 41, 42, 43, 4, 149, 23, 24,
429 153, 154, 20, 34, 166, 20, 133, 34, 75, 23,
430 24, 31, 164, 33, 167, 168, 34, 170, 33, 172,
431 31, 20, 33, 23, 24, 92, 5, 6, 7, 8,
432 9, 10, 11, 12, 13, 14, 15, 16, 20, 35,
433 34, 20, 38, 22, 5, 6, 7, 8, 9, 10,
434 11, 12, 13, 14, 15, 16, 13, 20, 13, 20,
435 20, 22, 25, 26, 27, 28, 29, 30, 20, 32,
436 23, 24, 37, 25, 26, 27, 28, 29, 30, 11,
437 12, 13, 33, 34, 16, 11, 12, 13, 35, 20,
438 16, 38, 33, 34, 32, 33, 20, 20, 20, 20,
439 35, 35, 22, 36, 20, 34, 34, 20, 20, 20,
440 35, 20, 20, 23, 84, 34, 20, 35, 35, 20,
441 0, 35, 4, 38, 31, 23, 20, 0, 21, 35,
442 35, 34, 34, 23, 34, 31, 31, 23, 35, 23,
443 31, 40, 23, 35, 23, 23, 33, 22, 31, 111,
444 39, 39, 22, 22, 156, 114, -1, -1, -1, -1,
445 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
446 -1, -1, -1, 50, -1, -1, -1, -1, -1, -1,
449 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
450 #line 3 "/usr/lib/bison.simple"
452 /* Skeleton output parser for bison,
453 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
455 This program is free software; you can redistribute it and/or modify
456 it under the terms of the GNU General Public License as published by
457 the Free Software Foundation; either version 2, or (at your option)
460 This program is distributed in the hope that it will be useful,
461 but WITHOUT ANY WARRANTY; without even the implied warranty of
462 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
463 GNU General Public License for more details.
465 You should have received a copy of the GNU General Public License
466 along with this program; if not, write to the Free Software
467 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
469 /* As a special exception, when this file is copied by Bison into a
470 Bison output file, you may use that output file without restriction.
471 This special exception was added by the Free Software Foundation
472 in version 1.24 of Bison. */
476 #define alloca __builtin_alloca
477 #else /* not GNU C. */
478 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
480 #else /* not sparc */
481 #if defined (MSDOS) && !defined (__TURBOC__)
483 #else /* not MSDOS, or __TURBOC__ */
487 #else /* not MSDOS, __TURBOC__, or _AIX */
491 void *alloca (unsigned int);
493 #else /* not __cplusplus */
495 #endif /* not __cplusplus */
497 #endif /* not _AIX */
498 #endif /* not MSDOS, or __TURBOC__ */
499 #endif /* not sparc. */
500 #endif /* not GNU C. */
501 #endif /* alloca not defined. */
503 /* This is the parser code that is written into each bison parser
504 when the %semantic_parser declaration is not specified in the grammar.
505 It was written by Richard Stallman by simplifying the hairy parser
506 used when %semantic_parser is specified. */
508 /* Note: there must be only one dollar sign in this file.
509 It is replaced by the list of actions, each action
510 as one case of the switch. */
512 #define yyerrok (yyerrstatus = 0)
513 #define yyclearin (yychar = YYEMPTY)
516 #define YYACCEPT return(0)
517 #define YYABORT return(1)
518 #define YYERROR goto yyerrlab1
519 /* Like YYERROR except do call yyerror.
520 This remains here temporarily to ease the
521 transition to the new meaning of YYERROR, for GCC.
522 Once GCC version 2 has supplanted version 1, this can go. */
523 #define YYFAIL goto yyerrlab
524 #define YYRECOVERING() (!!yyerrstatus)
525 #define YYBACKUP(token, value) \
527 if (yychar == YYEMPTY && yylen == 1) \
528 { yychar = (token), yylval = (value); \
529 yychar1 = YYTRANSLATE (yychar); \
534 { yyerror ("syntax error: cannot back up"); YYERROR; } \
538 #define YYERRCODE 256
541 #define YYLEX yylex()
547 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
549 #define YYLEX yylex(&yylval, &yylloc)
551 #else /* not YYLSP_NEEDED */
553 #define YYLEX yylex(&yylval, YYLEX_PARAM)
555 #define YYLEX yylex(&yylval)
557 #endif /* not YYLSP_NEEDED */
560 /* If nonreentrant, generate the variables here */
564 int yychar; /* the lookahead symbol */
565 YYSTYPE yylval; /* the semantic value of the */
566 /* lookahead symbol */
569 YYLTYPE yylloc; /* location data for the lookahead */
573 int yynerrs; /* number of parse errors so far */
574 #endif /* not YYPURE */
577 int yydebug; /* nonzero means print parse trace */
578 /* Since this is uninitialized, it does not stop multiple parsers
582 /* YYINITDEPTH indicates the initial size of the parser's stacks */
585 #define YYINITDEPTH 200
588 /* YYMAXDEPTH is the maximum size the stacks can grow to
589 (effective only if the built-in stack extension method is used). */
596 #define YYMAXDEPTH 10000
599 /* Prevent warning if -Wstrict-prototypes. */
604 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
605 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
606 #else /* not GNU C or C++ */
609 /* This is the most reliable way to avoid incompatibilities
610 in available built-in functions on various systems. */
612 __yy_memcpy (to, from, count)
617 register char *f = from;
618 register char *t = to;
619 register int i = count;
625 #else /* __cplusplus */
627 /* This is the most reliable way to avoid incompatibilities
628 in available built-in functions on various systems. */
630 __yy_memcpy (char *to, char *from, int count)
632 register char *f = from;
633 register char *t = to;
634 register int i = count;
643 #line 196 "/usr/lib/bison.simple"
645 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
646 into yyparse. The argument should have type void *.
647 It should actually point to an object.
648 Grammar actions can access the variable by casting it
649 to the proper pointer type. */
653 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
654 #define YYPARSE_PARAM_DECL
655 #else /* not __cplusplus */
656 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
657 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
658 #endif /* not __cplusplus */
659 #else /* not YYPARSE_PARAM */
660 #define YYPARSE_PARAM_ARG
661 #define YYPARSE_PARAM_DECL
662 #endif /* not YYPARSE_PARAM */
665 yyparse(YYPARSE_PARAM_ARG)
668 register int yystate;
670 register short *yyssp;
671 register YYSTYPE *yyvsp;
672 int yyerrstatus; /* number of tokens to shift before error messages enabled */
673 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
675 short yyssa[YYINITDEPTH]; /* the state stack */
676 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
678 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
679 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
682 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
683 YYLTYPE *yyls = yylsa;
686 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
688 #define YYPOPSTACK (yyvsp--, yyssp--)
691 int yystacksize = YYINITDEPTH;
702 YYSTYPE yyval; /* the variable used to return */
703 /* semantic values from the action */
710 fprintf(stderr, "Starting parse\n");
716 yychar = YYEMPTY; /* Cause a token to be read. */
718 /* Initialize stack pointers.
719 Waste one element of value and location stack
720 so that they stay on the same level as the state stack.
721 The wasted elements are never initialized. */
729 /* Push a new state, which is found in yystate . */
730 /* In all cases, when you get here, the value and location stacks
731 have just been pushed. so pushing a state here evens the stacks. */
736 if (yyssp >= yyss + yystacksize - 1)
738 /* Give user a chance to reallocate the stack */
739 /* Use copies of these so that the &'s don't force the real ones into memory. */
740 YYSTYPE *yyvs1 = yyvs;
743 YYLTYPE *yyls1 = yyls;
746 /* Get the current used size of the three stacks, in elements. */
747 int size = yyssp - yyss + 1;
750 /* Each stack pointer address is followed by the size of
751 the data in use in that stack, in bytes. */
753 /* This used to be a conditional around just the two extra args,
754 but that might be undefined if yyoverflow is a macro. */
755 yyoverflow("parser stack overflow",
756 &yyss1, size * sizeof (*yyssp),
757 &yyvs1, size * sizeof (*yyvsp),
758 &yyls1, size * sizeof (*yylsp),
761 yyoverflow("parser stack overflow",
762 &yyss1, size * sizeof (*yyssp),
763 &yyvs1, size * sizeof (*yyvsp),
767 yyss = yyss1; yyvs = yyvs1;
771 #else /* no yyoverflow */
772 /* Extend the stack our own way. */
773 if (yystacksize >= YYMAXDEPTH)
775 yyerror("parser stack overflow");
779 if (yystacksize > YYMAXDEPTH)
780 yystacksize = YYMAXDEPTH;
781 yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
782 __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
783 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
784 __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
786 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
787 __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
789 #endif /* no yyoverflow */
791 yyssp = yyss + size - 1;
792 yyvsp = yyvs + size - 1;
794 yylsp = yyls + size - 1;
799 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
802 if (yyssp >= yyss + yystacksize - 1)
808 fprintf(stderr, "Entering state %d\n", yystate);
814 /* Do appropriate processing given the current state. */
815 /* Read a lookahead token if we need one and don't already have one. */
818 /* First try to decide what to do without reference to lookahead token. */
820 yyn = yypact[yystate];
824 /* Not known => get a lookahead token if don't already have one. */
826 /* yychar is either YYEMPTY or YYEOF
827 or a valid token in external form. */
829 if (yychar == YYEMPTY)
833 fprintf(stderr, "Reading a token: ");
838 /* Convert token to internal form (in yychar1) for indexing tables with */
840 if (yychar <= 0) /* This means end of input. */
843 yychar = YYEOF; /* Don't call YYLEX any more */
847 fprintf(stderr, "Now at end of input.\n");
852 yychar1 = YYTRANSLATE(yychar);
857 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
858 /* Give the individual parser a way to print the precise meaning
859 of a token, for further debugging info. */
861 YYPRINT (stderr, yychar, yylval);
863 fprintf (stderr, ")\n");
869 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
874 /* yyn is what to do for this token type in this state.
875 Negative => reduce, -yyn is rule number.
876 Positive => shift, yyn is new state.
877 New state is final state => don't bother to shift,
879 0, or most negative number => error. */
894 /* Shift the lookahead token. */
898 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
901 /* Discard the token being shifted unless it is eof. */
910 /* count tokens shifted since error; after three, turn off error status. */
911 if (yyerrstatus) yyerrstatus--;
916 /* Do the default action for the current state. */
919 yyn = yydefact[yystate];
923 /* Do a reduction. yyn is the number of a rule to reduce with. */
927 yyval = yyvsp[1-yylen]; /* implement default value of the action */
934 fprintf (stderr, "Reducing via rule %d (line %d), ",
937 /* Print the symbols being reduced, and their result. */
938 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
939 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
940 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
966 Node *node = new_ccode(FALSE,yyvsp[0].cbuf,ccode_line);
967 nodes = g_list_append(nodes,node);
973 Node *node = new_ccode(TRUE,yyvsp[0].cbuf,ccode_line);
974 nodes = g_list_append(nodes,node);
980 Node *node = new_ccode(FALSE,yyvsp[0].cbuf,ccode_line);
981 nodes = g_list_append(nodes,node);
987 Node *node = new_ccode(TRUE,yyvsp[0].cbuf,ccode_line);
988 nodes = g_list_append(nodes,node);
994 ((Class *)class)->nodes = class_nodes;
996 nodes = g_list_append(nodes,class);
1002 class = new_class(yyvsp[-2].id,yyvsp[0].id,NULL);
1032 push_variable(yyvsp[-1].id,PUBLIC_SCOPE,yyvsp[-3].line);
1038 push_variable(yyvsp[-1].id,PRIVATE_SCOPE,yyvsp[-3].line);
1044 if(strcmp(yyvsp[-6].id,"get")==0 &&
1045 strcmp(yyvsp[-3].id,"set")==0) {
1047 g_free(yyvsp[-6].id); g_free(yyvsp[-3].id);
1048 node = new_argument(yyvsp[-8].id,yyvsp[-9].list,yyvsp[-7].id,
1049 yyvsp[-4].cbuf,yyvsp[-5].line,
1050 yyvsp[-1].cbuf,yyvsp[-2].line,
1052 class_nodes = g_list_append(class_nodes,node);
1053 } else if(strcmp(yyvsp[-6].id,"set")==0 &&
1054 strcmp(yyvsp[-3].id,"get")==0) {
1056 g_free(yyvsp[-6].id); g_free(yyvsp[-3].id);
1057 node = new_argument(yyvsp[-8].id,yyvsp[-9].list,yyvsp[-7].id,
1058 yyvsp[-1].cbuf,yyvsp[-2].line,
1059 yyvsp[-4].cbuf,yyvsp[-5].line,
1061 class_nodes = g_list_append(class_nodes,node);
1063 g_free(yyvsp[-8].id); g_free(yyvsp[-7].id);
1064 g_free(yyvsp[-6].id); g_free(yyvsp[-3].id);
1065 g_list_foreach(yyvsp[-9].list,(GFunc)g_free,NULL);
1066 g_string_free(yyvsp[-1].cbuf,TRUE);
1067 g_string_free(yyvsp[-4].cbuf,TRUE);
1068 yyerror(_("parse error"));
1076 if(strcmp(yyvsp[-3].id,"get")==0) {
1078 g_free(yyvsp[-3].id);
1079 node = new_argument(yyvsp[-5].id,yyvsp[-6].list,yyvsp[-4].id,
1080 yyvsp[-1].cbuf,yyvsp[-2].line,NULL,0,
1082 class_nodes = g_list_append(class_nodes,node);
1083 } else if(strcmp(yyvsp[-3].id,"set")==0) {
1085 g_free(yyvsp[-3].id);
1086 node = new_argument(yyvsp[-5].id,yyvsp[-6].list,yyvsp[-4].id,
1087 NULL,0,yyvsp[-1].cbuf,yyvsp[-2].line,
1089 class_nodes = g_list_append(class_nodes,node);
1091 g_free(yyvsp[-3].id); g_free(yyvsp[-5].id);
1092 g_free(yyvsp[-4].id);
1093 g_list_foreach(yyvsp[-6].list,(GFunc)g_free,NULL);
1094 g_string_free(yyvsp[-1].cbuf,TRUE);
1095 yyerror(_("parse error"));
1102 { yyval.list = yyvsp[-1].list; ;
1106 { yyval.list = NULL; ;
1111 yyval.list = g_list_append(yyvsp[0].list,yyvsp[-2].id);
1117 yyval.list = g_list_append(NULL,yyvsp[0].id);
1123 Node *node = new_type(0,yyvsp[0].id);
1124 typestack = g_list_prepend(typestack,node);
1130 Node *node = new_type(stars,yyvsp[-1].id);
1132 typestack = g_list_prepend(typestack,node);
1138 yyval.id = g_strconcat("unsigned ",yyvsp[0].id,NULL);
1144 yyval.id = g_strconcat("signed ",yyvsp[0].id,NULL);
1150 yyval.id = g_strdup(yyvsp[0].id);
1156 yyval.id = g_strdup("unsigned char");
1162 yyval.id = g_strdup("signed char");
1168 yyval.id = g_strdup("char");
1174 yyval.id = g_strdup("double");
1180 yyval.id = g_strdup("float");
1186 yyval.id = yyvsp[0].id;
1192 yyval.id = g_strconcat(yyvsp[-1].id,yyvsp[0].id,NULL);
1193 g_free(yyvsp[0].id);
1199 yyval.id = yyvsp[0].id;
1205 yyval.id = g_strdup("void");
1211 yyval.id = "long int";
1223 yyval.id = "short int";
1247 yyval.id = "union ";
1253 yyval.id = "struct ";
1267 gtktypes = g_list_prepend(gtktypes,yyvsp[-3].id);
1273 gtktypes = g_list_append(gtktypes,yyvsp[0].id);
1279 gtktypes = g_list_append(gtktypes,yyvsp[0].id);
1284 { yyval.cbuf=yyvsp[0].cbuf; ;
1288 { yyval.cbuf = NULL; ;
1293 int sigtype = SIGNAL_LAST_METHOD;
1294 if(strcmp(yyvsp[-8].id,"first")==0)
1295 sigtype = SIGNAL_FIRST_METHOD;
1296 else if(strcmp(yyvsp[-8].id,"last")==0)
1297 sigtype = SIGNAL_LAST_METHOD;
1299 yyerror(_("signal must be 'first' or 'last'"));
1300 g_free(yyvsp[-8].id);
1303 g_free(yyvsp[-8].id);
1306 yyerror(_("signal without 'self' as "
1307 "first parameter"));
1310 push_function(sigtype,NULL,
1311 yyvsp[-5].id, yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-9].line,ccode_line);
1318 yyerror(_("signal without 'self' as "
1319 "first parameter"));
1322 push_function(SIGNAL_LAST_METHOD, NULL,
1323 yyvsp[-5].id, yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-8].line,ccode_line);
1330 yyerror(_("virtual method without 'self' as "
1331 "first parameter"));
1334 push_function(VIRTUAL_METHOD, NULL, yyvsp[-5].id,
1335 yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-7].line,ccode_line);
1341 push_function(OVERRIDE_METHOD, yyvsp[-9].id,
1342 yyvsp[-6].id, yyvsp[-2].id, yyvsp[0].cbuf,yyvsp[-11].line,yyvsp[-1].line);
1348 push_function(PUBLIC_SCOPE, NULL, yyvsp[-6].id,
1349 yyvsp[-2].id, yyvsp[0].cbuf,yyvsp[-8].line,yyvsp[-1].line);
1355 push_function(PRIVATE_SCOPE, NULL, yyvsp[-6].id,
1356 yyvsp[-2].id, yyvsp[0].cbuf,yyvsp[-8].line,yyvsp[-1].line);
1362 if(strcmp(yyvsp[-4].id,"init")==0) {
1363 push_init_arg(yyvsp[-2].id,FALSE);
1364 push_function(INIT_METHOD, NULL, yyvsp[-4].id,
1365 NULL, NULL,yyvsp[-3].line,0);
1366 } else if(strcmp(yyvsp[-4].id,"class_init")==0) {
1367 push_init_arg(yyvsp[-2].id,TRUE);
1368 push_function(CLASS_INIT_METHOD, NULL,
1369 yyvsp[-4].id, NULL, NULL,yyvsp[-3].line,0);
1371 g_free(yyvsp[-4].id);
1372 g_free(yyvsp[-2].id);
1373 yyerror(_("parse error"));
1381 if(strcmp(yyvsp[-5].id,"init")==0) {
1382 push_init_arg(yyvsp[-3].id,FALSE);
1383 push_function(INIT_METHOD, NULL,
1384 yyvsp[-5].id, NULL, yyvsp[0].cbuf,yyvsp[-4].line,
1386 } else if(strcmp(yyvsp[-5].id,"class_init")==0) {
1387 push_init_arg(yyvsp[-3].id,TRUE);
1388 push_function(CLASS_INIT_METHOD, NULL,
1389 yyvsp[-5].id, NULL, yyvsp[0].cbuf,yyvsp[-4].line,
1392 g_free(yyvsp[-5].id);
1393 g_free(yyvsp[-3].id);
1394 g_string_free(yyvsp[-3].cbuf,TRUE);
1395 yyerror(_("parse error"));
1402 { yyval.id = yyvsp[0].id; ;
1407 yyval.id = (yyvsp[0].cbuf)->str;
1408 g_string_free(yyvsp[0].cbuf,FALSE);
1417 { yyval.id = NULL; ;
1421 { has_self = FALSE; ;
1427 if(strcmp(yyvsp[0].id,"this")==0) {
1428 push_self(yyvsp[0].id);
1429 print_error(TRUE,_("Use of 'this' is "
1430 "depreciated, use 'self' "
1431 "instead"),line_no);
1432 } else if(strcmp(yyvsp[0].id,"self")==0)
1433 push_self(yyvsp[0].id);
1435 g_free(yyvsp[0].id);
1436 yyerror(_("parse error"));
1445 if(strcmp(yyvsp[-2].id,"this")==0) {
1446 push_self(yyvsp[-2].id);
1447 print_error(TRUE,_("Use of 'this' is "
1448 "depreciated, use 'self' "
1449 "instead"),line_no);
1450 } else if(strcmp(yyvsp[-2].id,"self")==0)
1451 push_self(yyvsp[-2].id);
1453 g_free(yyvsp[-2].id);
1454 yyerror(_("parse error"));
1461 { has_self = FALSE; ;
1474 push_funcarg(yyvsp[0].id);
1480 if(strcmp(yyvsp[-2].id,"check")!=0) {
1481 yyerror(_("parse error"));
1484 g_free(yyvsp[-2].id);
1485 push_funcarg(yyvsp[-4].id);
1499 if(strcmp(yyvsp[0].id,"type")==0) {
1500 Node *node = new_check(TYPE_CHECK,NULL);
1501 checks = g_list_append(checks,node);
1502 } else if(strcmp(yyvsp[0].id,"null")==0) {
1503 Node *node = new_check(NULL_CHECK,NULL);
1504 checks = g_list_append(checks,node);
1506 yyerror(_("parse error"));
1509 g_free(yyvsp[0].id);
1515 Node *node = new_check(GT_CHECK,yyvsp[0].id);
1516 checks = g_list_append(checks,node);
1522 Node *node = new_check(LT_CHECK,yyvsp[0].id);
1523 checks = g_list_append(checks,node);
1529 Node *node = new_check(GE_CHECK,yyvsp[0].id);
1530 checks = g_list_append(checks,node);
1536 Node *node = new_check(LE_CHECK,yyvsp[0].id);
1537 checks = g_list_append(checks,node);
1543 Node *node = new_check(EQ_CHECK,yyvsp[0].id);
1544 checks = g_list_append(checks,node);
1550 Node *node = new_check(NE_CHECK,yyvsp[0].id);
1551 checks = g_list_append(checks,node);
1556 { yyval.id = yyvsp[0].id; ;
1561 yyval.id = g_strconcat("-",yyvsp[0].id,NULL);
1562 g_free(yyvsp[0].id);
1567 { yyval.id = yyvsp[0].id; ;
1570 /* the action file gets copied in in place of this dollarsign */
1571 #line 498 "/usr/lib/bison.simple"
1582 short *ssp1 = yyss - 1;
1583 fprintf (stderr, "state stack now");
1584 while (ssp1 != yyssp)
1585 fprintf (stderr, " %d", *++ssp1);
1586 fprintf (stderr, "\n");
1596 yylsp->first_line = yylloc.first_line;
1597 yylsp->first_column = yylloc.first_column;
1598 yylsp->last_line = (yylsp-1)->last_line;
1599 yylsp->last_column = (yylsp-1)->last_column;
1604 yylsp->last_line = (yylsp+yylen-1)->last_line;
1605 yylsp->last_column = (yylsp+yylen-1)->last_column;
1609 /* Now "shift" the result of the reduction.
1610 Determine what state that goes to,
1611 based on the state we popped back to
1612 and the rule number reduced by. */
1616 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1617 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1618 yystate = yytable[yystate];
1620 yystate = yydefgoto[yyn - YYNTBASE];
1624 yyerrlab: /* here on detecting error */
1627 /* If not already recovering from an error, report this error. */
1631 #ifdef YYERROR_VERBOSE
1632 yyn = yypact[yystate];
1634 if (yyn > YYFLAG && yyn < YYLAST)
1641 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1642 for (x = (yyn < 0 ? -yyn : 0);
1643 x < (sizeof(yytname) / sizeof(char *)); x++)
1644 if (yycheck[x + yyn] == x)
1645 size += strlen(yytname[x]) + 15, count++;
1646 msg = (char *) malloc(size + 15);
1649 strcpy(msg, "parse error");
1654 for (x = (yyn < 0 ? -yyn : 0);
1655 x < (sizeof(yytname) / sizeof(char *)); x++)
1656 if (yycheck[x + yyn] == x)
1658 strcat(msg, count == 0 ? ", expecting `" : " or `");
1659 strcat(msg, yytname[x]);
1668 yyerror ("parse error; also virtual memory exceeded");
1671 #endif /* YYERROR_VERBOSE */
1672 yyerror("parse error");
1676 yyerrlab1: /* here on error raised explicitly by an action */
1678 if (yyerrstatus == 3)
1680 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1682 /* return failure if at end of input */
1683 if (yychar == YYEOF)
1688 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1694 /* Else will try to reuse lookahead token
1695 after shifting the error token. */
1697 yyerrstatus = 3; /* Each real token shifted decrements this */
1701 yyerrdefault: /* current state does not do anything special for the error token. */
1704 /* This is wrong; only states that explicitly want error tokens
1705 should shift them. */
1706 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1707 if (yyn) goto yydefault;
1710 yyerrpop: /* pop the current state because it cannot handle the error token */
1712 if (yyssp == yyss) YYABORT;
1722 short *ssp1 = yyss - 1;
1723 fprintf (stderr, "Error: state stack now");
1724 while (ssp1 != yyssp)
1725 fprintf (stderr, " %d", *++ssp1);
1726 fprintf (stderr, "\n");
1732 yyn = yypact[yystate];
1737 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1756 fprintf(stderr, "Shifting error token, ");