2 /* A Bison parser, made from parse.y
3 by GNU Bison version 1.28 */
5 #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_self = FALSE;
61 static int vararg = 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, int vararg)
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,vararg);
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);
198 #define YYFLAG -32768
201 #define YYTRANSLATE(x) ((unsigned)(x) <= 284 ? yytranslate[x] : 73)
203 static const char yytranslate[] = { 0,
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, 2, 2, 2, 2, 2, 2, 2, 2,
207 2, 2, 43, 2, 2, 2, 2, 2, 2, 34,
208 35, 37, 2, 38, 44, 2, 2, 2, 40, 2,
209 2, 2, 2, 2, 2, 2, 2, 2, 33, 42,
210 39, 41, 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, 2, 2, 2, 2, 2, 2, 2, 2,
216 2, 2, 31, 36, 32, 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, 2, 2, 2, 2, 2,
229 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
230 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
231 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
236 static const short yyprhs[] = { 0,
237 0, 4, 7, 10, 12, 15, 18, 20, 22, 27,
238 32, 35, 38, 41, 43, 45, 47, 52, 57, 69,
239 78, 82, 83, 87, 89, 91, 94, 96, 99, 102,
240 105, 107, 110, 113, 115, 117, 119, 121, 124, 126,
241 128, 131, 133, 136, 138, 140, 142, 144, 146, 149,
242 151, 155, 159, 162, 165, 167, 172, 176, 178, 181,
243 183, 193, 203, 212, 225, 235, 245, 251, 254, 258,
244 261, 262, 264, 266, 270, 272, 276, 278, 282, 284,
245 287, 294, 297, 299, 301, 304, 307, 311, 315, 319,
249 static const short yyrhs[] = { 46,
250 47, 46, 0, 47, 46, 0, 46, 47, 0, 47,
251 0, 46, 23, 0, 46, 24, 0, 23, 0, 24,
252 0, 48, 31, 49, 32, 0, 3, 22, 4, 22,
253 0, 49, 64, 0, 49, 50, 0, 49, 51, 0,
254 64, 0, 50, 0, 51, 0, 25, 54, 20, 33,
255 0, 26, 54, 20, 33, 0, 27, 52, 20, 20,
256 20, 31, 23, 20, 31, 23, 33, 0, 27, 52,
257 20, 20, 20, 31, 23, 33, 0, 34, 53, 35,
258 0, 0, 20, 36, 53, 0, 20, 0, 55, 0,
259 5, 55, 0, 56, 0, 56, 59, 0, 12, 57,
260 0, 11, 57, 0, 57, 0, 12, 18, 0, 11,
261 18, 0, 18, 0, 17, 0, 16, 0, 20, 0,
262 58, 20, 0, 22, 0, 6, 0, 13, 15, 0,
263 13, 0, 14, 15, 0, 14, 0, 15, 0, 9,
264 0, 8, 0, 7, 0, 37, 59, 0, 37, 0,
265 26, 20, 61, 0, 20, 26, 61, 0, 26, 61,
266 0, 20, 61, 0, 61, 0, 20, 34, 62, 35,
267 0, 62, 38, 20, 0, 20, 0, 31, 23, 0,
268 33, 0, 29, 60, 54, 20, 34, 66, 35, 65,
269 63, 0, 28, 26, 54, 20, 34, 66, 35, 65,
270 63, 0, 28, 54, 20, 34, 66, 35, 65, 63,
271 0, 30, 34, 22, 35, 54, 20, 34, 66, 35,
272 65, 31, 23, 0, 25, 54, 20, 34, 66, 35,
273 65, 31, 23, 0, 26, 54, 20, 34, 66, 35,
274 65, 31, 23, 0, 20, 34, 20, 35, 63, 0,
275 19, 72, 0, 19, 31, 23, 0, 39, 40, 0,
276 0, 6, 0, 20, 0, 20, 38, 67, 0, 67,
277 0, 68, 38, 10, 0, 68, 0, 68, 38, 69,
278 0, 69, 0, 54, 20, 0, 54, 20, 34, 20,
279 70, 35, 0, 70, 71, 0, 71, 0, 20, 0,
280 41, 72, 0, 42, 72, 0, 41, 39, 72, 0,
281 42, 39, 72, 0, 39, 39, 72, 0, 43, 39,
282 72, 0, 21, 0, 44, 21, 0, 20, 0
288 static const short yyrline[] = { 0,
289 179, 180, 181, 182, 185, 189, 193, 197, 203, 210,
290 215, 216, 217, 218, 219, 220, 223, 226, 230, 259,
291 285, 286, 289, 292, 298, 299, 307, 311, 318, 321,
292 324, 327, 330, 333, 336, 339, 342, 345, 349, 352,
293 357, 360, 363, 366, 369, 374, 377, 380, 385, 386,
294 389, 401, 413, 416, 428, 433, 438, 441, 446, 447,
295 451, 461, 471, 481, 487, 492, 497, 518, 519, 523,
296 524, 527, 528, 544, 559, 562, 563, 566, 567, 570,
297 573, 583, 584, 587, 600, 604, 608, 612, 616, 620,
303 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
305 static const char * const yytname[] = { "$","error","$undefined.","CLASS",
306 "FROM","CONST","VOID","STRUCT","UNION","ENUM","THREEDOTS","SIGNED","UNSIGNED",
307 "LONG","SHORT","INT","FLOAT","DOUBLE","CHAR","ONERROR","TOKEN","NUMBER","TYPETOKEN",
308 "CCODE","HCODE","PUBLIC","PRIVATE","ARGUMENT","VIRTUAL","SIGNAL","OVERRIDE",
309 "'{'","'}'","';'","'('","')'","'|'","'*'","','","'='","'1'","'>'","'<'","'!'",
310 "'-'","prog","ccodes","class","classdec","classcode","variable","argument","argflags",
311 "flaglist","type","type1","type2","integer","tspecifier","stars","fullsigtype",
312 "sigtype","tokenlist","codenocode","method","onerror","funcargs","arglist","arglist1",
313 "arg","checklist","check","numtok", NULL
317 static const short yyr1[] = { 0,
318 45, 45, 45, 45, 46, 46, 46, 46, 47, 48,
319 49, 49, 49, 49, 49, 49, 50, 50, 51, 51,
320 52, 52, 53, 53, 54, 54, 55, 55, 56, 56,
321 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
322 57, 57, 57, 57, 57, 58, 58, 58, 59, 59,
323 60, 60, 60, 60, 60, 61, 62, 62, 63, 63,
324 64, 64, 64, 64, 64, 64, 64, 65, 65, 65,
325 65, 66, 66, 66, 66, 67, 67, 68, 68, 69,
326 69, 70, 70, 71, 71, 71, 71, 71, 71, 71,
330 static const short yyr2[] = { 0,
331 3, 2, 2, 1, 2, 2, 1, 1, 4, 4,
332 2, 2, 2, 1, 1, 1, 4, 4, 11, 8,
333 3, 0, 3, 1, 1, 2, 1, 2, 2, 2,
334 1, 2, 2, 1, 1, 1, 1, 2, 1, 1,
335 2, 1, 2, 1, 1, 1, 1, 1, 2, 1,
336 3, 3, 2, 2, 1, 4, 3, 1, 2, 1,
337 9, 9, 8, 12, 9, 9, 5, 2, 3, 2,
338 0, 1, 1, 3, 1, 3, 1, 3, 1, 2,
339 6, 2, 1, 1, 2, 2, 3, 3, 3, 3,
343 static const short yydefact[] = { 0,
344 0, 7, 8, 0, 4, 0, 0, 5, 6, 3,
345 2, 0, 0, 1, 0, 0, 0, 22, 0, 0,
346 0, 0, 15, 16, 14, 10, 0, 0, 40, 48,
347 47, 46, 0, 0, 42, 44, 45, 36, 35, 34,
348 37, 39, 0, 25, 27, 31, 0, 0, 0, 0,
349 0, 0, 0, 0, 0, 55, 0, 9, 12, 13,
350 11, 0, 26, 33, 30, 32, 29, 41, 43, 0,
351 50, 28, 38, 0, 24, 0, 0, 0, 0, 0,
352 0, 0, 54, 0, 53, 0, 0, 0, 17, 0,
353 49, 18, 0, 0, 21, 0, 0, 0, 52, 58,
354 0, 51, 0, 0, 0, 60, 67, 40, 37, 0,
355 0, 75, 77, 79, 0, 23, 0, 0, 0, 56,
356 0, 0, 0, 59, 0, 80, 71, 0, 71, 0,
357 0, 71, 57, 0, 0, 74, 0, 0, 0, 0,
358 76, 78, 0, 0, 71, 0, 71, 0, 0, 93,
359 91, 0, 0, 68, 70, 0, 0, 0, 20, 0,
360 63, 0, 0, 84, 0, 0, 0, 0, 0, 83,
361 69, 92, 65, 66, 0, 62, 61, 71, 0, 0,
362 85, 0, 86, 0, 81, 82, 0, 0, 89, 87,
363 88, 90, 19, 0, 64, 0, 0, 0
366 static const short yydefgoto[] = { 196,
367 4, 5, 6, 22, 23, 24, 50, 76, 110, 44,
368 45, 46, 47, 72, 55, 56, 101, 107, 25, 140,
369 111, 112, 113, 114, 169, 170, 154
372 static const short yypact[] = { 21,
373 -18,-32768,-32768, 68, 66, 20, 54,-32768,-32768, 66,
374 155, 171, 0, 155, 48, 116, 116, 52, 61, -14,
375 59, 160,-32768,-32768,-32768,-32768, 29, 151,-32768,-32768,
376 -32768,-32768, 81, 189, 111, 120,-32768,-32768,-32768,-32768,
377 -32768,-32768, 117,-32768, 64,-32768, 124, 133, 135, 152,
378 116, 154, 150, 163, 116,-32768, 186,-32768,-32768,-32768,
379 -32768, 158,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 148,
380 64,-32768,-32768, 161, 173, 175, 191, 192, 179, 180,
381 195, 196,-32768, 28,-32768, 197, 183, 86,-32768, 134,
382 -32768,-32768, 134, 135,-32768, 199, 187, 134,-32768,-32768,
383 -22,-32768, 188, 116, 200,-32768,-32768, 185, 18, 204,
384 190,-32768, 193,-32768, 194,-32768, 201, 134, 198,-32768,
385 206, 134, 207,-32768, 116, 202, 41, 98, 41, 205,
386 203, 41,-32768, 208, 210,-32768, 214, -6, 209, 211,
387 -32768,-32768, 215, 26, 41, 86, 41, 134, 22,-32768,
388 -32768, 212, 216,-32768,-32768, 217, 218, 219,-32768, 86,
389 -32768, 86, 213,-32768, 220, -3, 8, 221, -9,-32768,
390 -32768,-32768,-32768,-32768, 222,-32768,-32768, 41, -1, -1,
391 -32768, -1,-32768, -1,-32768,-32768, 223, 224,-32768,-32768,
392 -32768,-32768,-32768, 228,-32768, 230, 239,-32768
395 static const short yypgoto[] = {-32768,
396 45, 243,-32768,-32768, 231, 232,-32768, 164, -16, 229,
397 -32768, 172,-32768, 181,-32768, -44,-32768, 15, 240, -124,
398 -91, 136,-32768, 137,-32768, 94, -82
405 static const short yytable[] = { 43,
406 48, 115, 52, 7, 143, 53, 119, 146, 83, 85,
407 164, 54, 120, 150, 151, 121, 150, 151, 150, 151,
408 160, 26, 162, 1, 152, 185, 131, 150, 151, 165,
409 134, 166, 167, 168, 78, 180, 99, 153, 86, 102,
410 153, 164, 153, 2, 3, 158, 182, 80, 62, 11,
411 12, 153, -73, 188, 14, 125, 163, 13, 159, 138,
412 165, 82, 166, 167, 168, 28, 29, 30, 31, 32,
413 1, 33, 34, 35, 36, 37, 38, 39, 40, 139,
414 41, 27, 42, 181, 183, 49, 51, 123, 2, 3,
415 8, 9, 57, 35, 36, 37, 189, 190, 64, 191,
416 71, 192, 28, 29, 30, 31, 32, 141, 33, 34,
417 35, 36, 37, 38, 39, 40, 105, 41, 106, 42,
418 28, 29, 30, 31, 32, 68, 33, 34, 35, 36,
419 37, 38, 39, 40, 69, 41, 70, 42, 28, 108,
420 30, 31, 32, 73, 33, 34, 35, 36, 37, 38,
421 39, 40, 74, 109, 75, 42, 29, 30, 31, 32,
422 161, 33, 34, 35, 36, 37, 38, 39, 40, 80,
423 41, 77, 42, 79, 176, 81, 177, 8, 9, 15,
424 89, 90, 84, 82, 16, 17, 18, 19, 20, 21,
425 15, 58, 88, 92, 93, 16, 17, 18, 19, 20,
426 21, 35, 36, 37, 65, 67, 66, 87, 94, 95,
427 96, 97, 98, 82, 80, 100, 103, 104, 117, -72,
428 118, 122, 124, 126, 127, 133, 135, 144, 129, 197,
429 128, 130, 132, 149, 171, 137, 172, 145, 198, 173,
430 174, 156, 147, 148, 187, 157, 10, 178, 155, 175,
431 195, 91, 59, 60, 194, 193, 63, 116, 179, 184,
435 static const short yycheck[] = { 16,
436 17, 93, 19, 22, 129, 20, 98, 132, 53, 54,
437 20, 26, 35, 20, 21, 38, 20, 21, 20, 21,
438 145, 22, 147, 3, 31, 35, 118, 20, 21, 39,
439 122, 41, 42, 43, 51, 39, 81, 44, 55, 84,
440 44, 20, 44, 23, 24, 20, 39, 20, 20, 5,
441 31, 44, 35, 178, 10, 38, 148, 4, 33, 19,
442 39, 34, 41, 42, 43, 5, 6, 7, 8, 9,
443 3, 11, 12, 13, 14, 15, 16, 17, 18, 39,
444 20, 34, 22, 166, 167, 34, 26, 104, 23, 24,
445 23, 24, 34, 13, 14, 15, 179, 180, 18, 182,
446 37, 184, 5, 6, 7, 8, 9, 10, 11, 12,
447 13, 14, 15, 16, 17, 18, 31, 20, 33, 22,
448 5, 6, 7, 8, 9, 15, 11, 12, 13, 14,
449 15, 16, 17, 18, 15, 20, 20, 22, 5, 6,
450 7, 8, 9, 20, 11, 12, 13, 14, 15, 16,
451 17, 18, 20, 20, 20, 22, 6, 7, 8, 9,
452 146, 11, 12, 13, 14, 15, 16, 17, 18, 20,
453 20, 20, 22, 20, 160, 26, 162, 23, 24, 20,
454 33, 34, 20, 34, 25, 26, 27, 28, 29, 30,
455 20, 32, 35, 33, 34, 25, 26, 27, 28, 29,
456 30, 13, 14, 15, 33, 34, 18, 22, 36, 35,
457 20, 20, 34, 34, 20, 20, 20, 35, 20, 35,
458 34, 34, 23, 20, 35, 20, 20, 23, 35, 0,
459 38, 31, 35, 20, 23, 34, 21, 35, 0, 23,
460 23, 31, 35, 34, 23, 31, 4, 35, 40, 31,
461 23, 71, 22, 22, 31, 33, 28, 94, 39, 39,
462 125, 22, 169, -1, 128
464 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
465 #line 3 "/usr/lib/bison.simple"
466 /* This file comes from bison-1.28. */
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., 59 Temple Place - Suite 330,
484 Boston, MA 02111-1307, USA. */
486 /* As a special exception, when this file is copied by Bison into a
487 Bison output file, you may use that output file without restriction.
488 This special exception was added by the Free Software Foundation
489 in version 1.24 of Bison. */
491 /* This is the parser code that is written into each bison parser
492 when the %semantic_parser declaration is not specified in the grammar.
493 It was written by Richard Stallman by simplifying the hairy parser
494 used when %semantic_parser is specified. */
496 #ifndef YYSTACK_USE_ALLOCA
498 #define YYSTACK_USE_ALLOCA
499 #else /* alloca not defined */
501 #define YYSTACK_USE_ALLOCA
502 #define alloca __builtin_alloca
503 #else /* not GNU C. */
504 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
505 #define YYSTACK_USE_ALLOCA
507 #else /* not sparc */
508 /* We think this test detects Watcom and Microsoft C. */
509 /* This used to test MSDOS, but that is a bad idea
510 since that symbol is in the user namespace. */
511 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
512 #if 0 /* No need for malloc.h, which pollutes the namespace;
513 instead, just don't use alloca. */
516 #else /* not MSDOS, or __TURBOC__ */
518 /* I don't know what this was needed for, but it pollutes the namespace.
519 So I turned it off. rms, 2 May 1997. */
520 /* #include <malloc.h> */
522 #define YYSTACK_USE_ALLOCA
523 #else /* not MSDOS, or __TURBOC__, or _AIX */
525 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
526 and on HPUX 10. Eventually we can turn this on. */
527 #define YYSTACK_USE_ALLOCA
528 #define alloca __builtin_alloca
531 #endif /* not _AIX */
532 #endif /* not MSDOS, or __TURBOC__ */
533 #endif /* not sparc */
534 #endif /* not GNU C */
535 #endif /* alloca not defined */
536 #endif /* YYSTACK_USE_ALLOCA not defined */
538 #ifdef YYSTACK_USE_ALLOCA
539 #define YYSTACK_ALLOC alloca
541 #define YYSTACK_ALLOC malloc
544 /* Note: there must be only one dollar sign in this file.
545 It is replaced by the list of actions, each action
546 as one case of the switch. */
548 #define yyerrok (yyerrstatus = 0)
549 #define yyclearin (yychar = YYEMPTY)
552 #define YYACCEPT goto yyacceptlab
553 #define YYABORT goto yyabortlab
554 #define YYERROR goto yyerrlab1
555 /* Like YYERROR except do call yyerror.
556 This remains here temporarily to ease the
557 transition to the new meaning of YYERROR, for GCC.
558 Once GCC version 2 has supplanted version 1, this can go. */
559 #define YYFAIL goto yyerrlab
560 #define YYRECOVERING() (!!yyerrstatus)
561 #define YYBACKUP(token, value) \
563 if (yychar == YYEMPTY && yylen == 1) \
564 { yychar = (token), yylval = (value); \
565 yychar1 = YYTRANSLATE (yychar); \
570 { yyerror ("syntax error: cannot back up"); YYERROR; } \
574 #define YYERRCODE 256
577 #define YYLEX yylex()
583 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
585 #define YYLEX yylex(&yylval, &yylloc)
587 #else /* not YYLSP_NEEDED */
589 #define YYLEX yylex(&yylval, YYLEX_PARAM)
591 #define YYLEX yylex(&yylval)
593 #endif /* not YYLSP_NEEDED */
596 /* If nonreentrant, generate the variables here */
600 int yychar; /* the lookahead symbol */
601 YYSTYPE yylval; /* the semantic value of the */
602 /* lookahead symbol */
605 YYLTYPE yylloc; /* location data for the lookahead */
609 int yynerrs; /* number of parse errors so far */
610 #endif /* not YYPURE */
613 int yydebug; /* nonzero means print parse trace */
614 /* Since this is uninitialized, it does not stop multiple parsers
618 /* YYINITDEPTH indicates the initial size of the parser's stacks */
621 #define YYINITDEPTH 200
624 /* YYMAXDEPTH is the maximum size the stacks can grow to
625 (effective only if the built-in stack extension method is used). */
632 #define YYMAXDEPTH 10000
635 /* Define __yy_memcpy. Note that the size argument
636 should be passed with type unsigned int, because that is what the non-GCC
637 definitions require. With GCC, __builtin_memcpy takes an arg
638 of type size_t, but it can handle unsigned int. */
640 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
641 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
642 #else /* not GNU C or C++ */
645 /* This is the most reliable way to avoid incompatibilities
646 in available built-in functions on various systems. */
648 __yy_memcpy (to, from, count)
653 register char *f = from;
654 register char *t = to;
655 register int i = count;
661 #else /* __cplusplus */
663 /* This is the most reliable way to avoid incompatibilities
664 in available built-in functions on various systems. */
666 __yy_memcpy (char *to, char *from, unsigned int count)
668 register char *t = to;
669 register char *f = from;
670 register int i = count;
679 #line 217 "/usr/lib/bison.simple"
681 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
682 into yyparse. The argument should have type void *.
683 It should actually point to an object.
684 Grammar actions can access the variable by casting it
685 to the proper pointer type. */
689 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
690 #define YYPARSE_PARAM_DECL
691 #else /* not __cplusplus */
692 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
693 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
694 #endif /* not __cplusplus */
695 #else /* not YYPARSE_PARAM */
696 #define YYPARSE_PARAM_ARG
697 #define YYPARSE_PARAM_DECL
698 #endif /* not YYPARSE_PARAM */
700 /* Prevent warning if -Wstrict-prototypes. */
703 int yyparse (void *);
710 yyparse(YYPARSE_PARAM_ARG)
713 register int yystate;
715 register short *yyssp;
716 register YYSTYPE *yyvsp;
717 int yyerrstatus; /* number of tokens to shift before error messages enabled */
718 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
720 short yyssa[YYINITDEPTH]; /* the state stack */
721 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
723 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
724 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
727 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
728 YYLTYPE *yyls = yylsa;
731 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
733 #define YYPOPSTACK (yyvsp--, yyssp--)
736 int yystacksize = YYINITDEPTH;
737 int yyfree_stacks = 0;
748 YYSTYPE yyval; /* the variable used to return */
749 /* semantic values from the action */
756 fprintf(stderr, "Starting parse\n");
762 yychar = YYEMPTY; /* Cause a token to be read. */
764 /* Initialize stack pointers.
765 Waste one element of value and location stack
766 so that they stay on the same level as the state stack.
767 The wasted elements are never initialized. */
775 /* Push a new state, which is found in yystate . */
776 /* In all cases, when you get here, the value and location stacks
777 have just been pushed. so pushing a state here evens the stacks. */
782 if (yyssp >= yyss + yystacksize - 1)
784 /* Give user a chance to reallocate the stack */
785 /* Use copies of these so that the &'s don't force the real ones into memory. */
786 YYSTYPE *yyvs1 = yyvs;
789 YYLTYPE *yyls1 = yyls;
792 /* Get the current used size of the three stacks, in elements. */
793 int size = yyssp - yyss + 1;
796 /* Each stack pointer address is followed by the size of
797 the data in use in that stack, in bytes. */
799 /* This used to be a conditional around just the two extra args,
800 but that might be undefined if yyoverflow is a macro. */
801 yyoverflow("parser stack overflow",
802 &yyss1, size * sizeof (*yyssp),
803 &yyvs1, size * sizeof (*yyvsp),
804 &yyls1, size * sizeof (*yylsp),
807 yyoverflow("parser stack overflow",
808 &yyss1, size * sizeof (*yyssp),
809 &yyvs1, size * sizeof (*yyvsp),
813 yyss = yyss1; yyvs = yyvs1;
817 #else /* no yyoverflow */
818 /* Extend the stack our own way. */
819 if (yystacksize >= YYMAXDEPTH)
821 yyerror("parser stack overflow");
833 if (yystacksize > YYMAXDEPTH)
834 yystacksize = YYMAXDEPTH;
835 #ifndef YYSTACK_USE_ALLOCA
838 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
839 __yy_memcpy ((char *)yyss, (char *)yyss1,
840 size * (unsigned int) sizeof (*yyssp));
841 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
842 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
843 size * (unsigned int) sizeof (*yyvsp));
845 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
846 __yy_memcpy ((char *)yyls, (char *)yyls1,
847 size * (unsigned int) sizeof (*yylsp));
849 #endif /* no yyoverflow */
851 yyssp = yyss + size - 1;
852 yyvsp = yyvs + size - 1;
854 yylsp = yyls + size - 1;
859 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
862 if (yyssp >= yyss + yystacksize - 1)
868 fprintf(stderr, "Entering state %d\n", yystate);
874 /* Do appropriate processing given the current state. */
875 /* Read a lookahead token if we need one and don't already have one. */
878 /* First try to decide what to do without reference to lookahead token. */
880 yyn = yypact[yystate];
884 /* Not known => get a lookahead token if don't already have one. */
886 /* yychar is either YYEMPTY or YYEOF
887 or a valid token in external form. */
889 if (yychar == YYEMPTY)
893 fprintf(stderr, "Reading a token: ");
898 /* Convert token to internal form (in yychar1) for indexing tables with */
900 if (yychar <= 0) /* This means end of input. */
903 yychar = YYEOF; /* Don't call YYLEX any more */
907 fprintf(stderr, "Now at end of input.\n");
912 yychar1 = YYTRANSLATE(yychar);
917 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
918 /* Give the individual parser a way to print the precise meaning
919 of a token, for further debugging info. */
921 YYPRINT (stderr, yychar, yylval);
923 fprintf (stderr, ")\n");
929 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
934 /* yyn is what to do for this token type in this state.
935 Negative => reduce, -yyn is rule number.
936 Positive => shift, yyn is new state.
937 New state is final state => don't bother to shift,
939 0, or most negative number => error. */
954 /* Shift the lookahead token. */
958 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
961 /* Discard the token being shifted unless it is eof. */
970 /* count tokens shifted since error; after three, turn off error status. */
971 if (yyerrstatus) yyerrstatus--;
976 /* Do the default action for the current state. */
979 yyn = yydefact[yystate];
983 /* Do a reduction. yyn is the number of a rule to reduce with. */
987 yyval = yyvsp[1-yylen]; /* implement default value of the action */
994 fprintf (stderr, "Reducing via rule %d (line %d), ",
997 /* Print the symbols being reduced, and their result. */
998 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
999 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
1000 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1026 Node *node = new_ccode(FALSE,yyvsp[0].cbuf,ccode_line);
1027 nodes = g_list_append(nodes,node);
1033 Node *node = new_ccode(TRUE,yyvsp[0].cbuf,ccode_line);
1034 nodes = g_list_append(nodes,node);
1040 Node *node = new_ccode(FALSE,yyvsp[0].cbuf,ccode_line);
1041 nodes = g_list_append(nodes,node);
1047 Node *node = new_ccode(TRUE,yyvsp[0].cbuf,ccode_line);
1048 nodes = g_list_append(nodes,node);
1054 ((Class *)class)->nodes = class_nodes;
1056 nodes = g_list_append(nodes,class);
1062 class = new_class(yyvsp[-2].id,yyvsp[0].id,NULL);
1092 push_variable(yyvsp[-1].id,PUBLIC_SCOPE,yyvsp[-3].line);
1098 push_variable(yyvsp[-1].id,PRIVATE_SCOPE,yyvsp[-3].line);
1104 if(strcmp(yyvsp[-6].id,"get")==0 &&
1105 strcmp(yyvsp[-3].id,"set")==0) {
1107 g_free(yyvsp[-6].id); g_free(yyvsp[-3].id);
1108 node = new_argument(yyvsp[-8].id,yyvsp[-9].list,yyvsp[-7].id,
1109 yyvsp[-4].cbuf,yyvsp[-5].line,
1110 yyvsp[-1].cbuf,yyvsp[-2].line,
1112 class_nodes = g_list_append(class_nodes,node);
1113 } else if(strcmp(yyvsp[-6].id,"set")==0 &&
1114 strcmp(yyvsp[-3].id,"get")==0) {
1116 g_free(yyvsp[-6].id); g_free(yyvsp[-3].id);
1117 node = new_argument(yyvsp[-8].id,yyvsp[-9].list,yyvsp[-7].id,
1118 yyvsp[-1].cbuf,yyvsp[-2].line,
1119 yyvsp[-4].cbuf,yyvsp[-5].line,
1121 class_nodes = g_list_append(class_nodes,node);
1123 g_free(yyvsp[-8].id); g_free(yyvsp[-7].id);
1124 g_free(yyvsp[-6].id); g_free(yyvsp[-3].id);
1125 g_list_foreach(yyvsp[-9].list,(GFunc)g_free,NULL);
1126 g_string_free(yyvsp[-1].cbuf,TRUE);
1127 g_string_free(yyvsp[-4].cbuf,TRUE);
1128 yyerror(_("parse error"));
1136 if(strcmp(yyvsp[-3].id,"get")==0) {
1138 g_free(yyvsp[-3].id);
1139 node = new_argument(yyvsp[-5].id,yyvsp[-6].list,yyvsp[-4].id,
1140 yyvsp[-1].cbuf,yyvsp[-2].line,NULL,0,
1142 class_nodes = g_list_append(class_nodes,node);
1143 } else if(strcmp(yyvsp[-3].id,"set")==0) {
1145 g_free(yyvsp[-3].id);
1146 node = new_argument(yyvsp[-5].id,yyvsp[-6].list,yyvsp[-4].id,
1147 NULL,0,yyvsp[-1].cbuf,yyvsp[-2].line,
1149 class_nodes = g_list_append(class_nodes,node);
1151 g_free(yyvsp[-3].id); g_free(yyvsp[-5].id);
1152 g_free(yyvsp[-4].id);
1153 g_list_foreach(yyvsp[-6].list,(GFunc)g_free,NULL);
1154 g_string_free(yyvsp[-1].cbuf,TRUE);
1155 yyerror(_("parse error"));
1162 { yyval.list = yyvsp[-1].list; ;
1166 { yyval.list = NULL; ;
1171 yyval.list = g_list_append(yyvsp[0].list,yyvsp[-2].id);
1177 yyval.list = g_list_append(NULL,yyvsp[0].id);
1187 Type *type = typestack->data;
1188 char *oldname = type->name;
1189 type->name = g_strconcat("const ",oldname,NULL);
1196 Node *node = new_type(0,yyvsp[0].id);
1197 typestack = g_list_prepend(typestack,node);
1203 Node *node = new_type(stars,yyvsp[-1].id);
1205 typestack = g_list_prepend(typestack,node);
1211 yyval.id = g_strconcat("unsigned ",yyvsp[0].id,NULL);
1217 yyval.id = g_strconcat("signed ",yyvsp[0].id,NULL);
1223 yyval.id = g_strdup(yyvsp[0].id);
1229 yyval.id = g_strdup("unsigned char");
1235 yyval.id = g_strdup("signed char");
1241 yyval.id = g_strdup("char");
1247 yyval.id = g_strdup("double");
1253 yyval.id = g_strdup("float");
1259 yyval.id = yyvsp[0].id;
1265 yyval.id = g_strconcat(yyvsp[-1].id,yyvsp[0].id,NULL);
1266 g_free(yyvsp[0].id);
1272 yyval.id = yyvsp[0].id;
1278 yyval.id = g_strdup("void");
1284 yyval.id = "long int";
1296 yyval.id = "short int";
1320 yyval.id = "union ";
1326 yyval.id = "struct ";
1340 if(strcmp(yyvsp[-1].id,"first")==0)
1341 yyval.sigtype = PRIVATE_SIGNAL_FIRST_METHOD;
1342 else if(strcmp(yyvsp[-1].id,"last")==0)
1343 yyval.sigtype = PRIVATE_SIGNAL_LAST_METHOD;
1345 yyerror(_("signal must be 'first' or 'last'"));
1346 g_free(yyvsp[-1].id);
1349 g_free(yyvsp[-1].id);
1355 if(strcmp(yyvsp[-2].id,"first")==0)
1356 yyval.sigtype = PRIVATE_SIGNAL_FIRST_METHOD;
1357 else if(strcmp(yyvsp[-2].id,"last")==0)
1358 yyval.sigtype = PRIVATE_SIGNAL_LAST_METHOD;
1360 yyerror(_("signal must be 'first' or 'last'"));
1361 g_free(yyvsp[-2].id);
1364 g_free(yyvsp[-2].id);
1370 yyval.sigtype = PRIVATE_SIGNAL_LAST_METHOD;
1376 if(strcmp(yyvsp[-1].id,"first")==0)
1377 yyval.sigtype = SIGNAL_FIRST_METHOD;
1378 else if(strcmp(yyvsp[-1].id,"last")==0)
1379 yyval.sigtype = SIGNAL_LAST_METHOD;
1381 yyerror(_("signal must be 'first' or 'last'"));
1382 g_free(yyvsp[-1].id);
1385 g_free(yyvsp[-1].id);
1391 yyval.sigtype = SIGNAL_LAST_METHOD;
1397 gtktypes = g_list_prepend(gtktypes,yyvsp[-3].id);
1403 gtktypes = g_list_append(gtktypes,yyvsp[0].id);
1409 gtktypes = g_list_append(gtktypes,yyvsp[0].id);
1414 { yyval.cbuf=yyvsp[0].cbuf; ;
1418 { yyval.cbuf = NULL; ;
1424 yyerror(_("signal without 'self' as "
1425 "first parameter"));
1428 push_function(yyvsp[-7].sigtype,NULL,
1429 yyvsp[-5].id, yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-8].line,
1437 yyerror(_("virtual method without 'self' as "
1438 "first parameter"));
1441 push_function(PRIVATE_VIRTUAL_METHOD, NULL, yyvsp[-5].id,
1442 yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-8].line,
1450 yyerror(_("virtual method without 'self' as "
1451 "first parameter"));
1454 push_function(VIRTUAL_METHOD, NULL, yyvsp[-5].id,
1455 yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-7].line,
1462 push_function(OVERRIDE_METHOD, yyvsp[-9].id,
1463 yyvsp[-6].id, yyvsp[-2].id, yyvsp[0].cbuf,
1464 yyvsp[-11].line,yyvsp[-1].line,
1471 push_function(PUBLIC_SCOPE, NULL, yyvsp[-6].id,
1472 yyvsp[-2].id, yyvsp[0].cbuf,yyvsp[-8].line,yyvsp[-1].line,
1479 push_function(PRIVATE_SCOPE, NULL, yyvsp[-6].id,
1480 yyvsp[-2].id, yyvsp[0].cbuf,yyvsp[-8].line,yyvsp[-1].line,
1487 if(strcmp(yyvsp[-4].id,"init")==0) {
1488 push_init_arg(yyvsp[-2].id,FALSE);
1489 push_function(INIT_METHOD, NULL,
1490 yyvsp[-4].id, NULL, yyvsp[0].cbuf,yyvsp[-3].line,
1492 } else if(strcmp(yyvsp[-4].id,"class_init")==0) {
1493 push_init_arg(yyvsp[-2].id,TRUE);
1494 push_function(CLASS_INIT_METHOD, NULL,
1495 yyvsp[-4].id, NULL, yyvsp[0].cbuf,yyvsp[-3].line,
1498 g_free(yyvsp[-4].id);
1499 g_free(yyvsp[-2].id);
1500 g_string_free(yyvsp[-2].cbuf,TRUE);
1501 yyerror(_("parse error"));
1508 { yyval.id = yyvsp[0].id; ;
1513 yyval.id = (yyvsp[0].cbuf)->str;
1514 g_string_free(yyvsp[0].cbuf,FALSE);
1523 { yyval.id = NULL; ;
1527 { vararg = FALSE; has_self = FALSE; ;
1534 if(strcmp(yyvsp[0].id,"this")==0) {
1535 push_self(yyvsp[0].id);
1536 print_error(TRUE,_("Use of 'this' is "
1537 "depreciated, use 'self' "
1538 "instead"),line_no);
1539 } else if(strcmp(yyvsp[0].id,"self")==0)
1540 push_self(yyvsp[0].id);
1542 g_free(yyvsp[0].id);
1543 yyerror(_("parse error"));
1552 if(strcmp(yyvsp[-2].id,"this")==0) {
1553 push_self(yyvsp[-2].id);
1554 print_error(TRUE,_("Use of 'this' is "
1555 "depreciated, use 'self' "
1556 "instead"),line_no);
1557 } else if(strcmp(yyvsp[-2].id,"self")==0)
1558 push_self(yyvsp[-2].id);
1560 g_free(yyvsp[-2].id);
1561 yyerror(_("parse error"));
1568 { has_self = FALSE; ;
1589 push_funcarg(yyvsp[0].id);
1595 if(strcmp(yyvsp[-2].id,"check")!=0) {
1596 yyerror(_("parse error"));
1599 g_free(yyvsp[-2].id);
1600 push_funcarg(yyvsp[-4].id);
1614 if(strcmp(yyvsp[0].id,"type")==0) {
1615 Node *node = new_check(TYPE_CHECK,NULL);
1616 checks = g_list_append(checks,node);
1617 } else if(strcmp(yyvsp[0].id,"null")==0) {
1618 Node *node = new_check(NULL_CHECK,NULL);
1619 checks = g_list_append(checks,node);
1621 yyerror(_("parse error"));
1624 g_free(yyvsp[0].id);
1630 Node *node = new_check(GT_CHECK,yyvsp[0].id);
1631 checks = g_list_append(checks,node);
1637 Node *node = new_check(LT_CHECK,yyvsp[0].id);
1638 checks = g_list_append(checks,node);
1644 Node *node = new_check(GE_CHECK,yyvsp[0].id);
1645 checks = g_list_append(checks,node);
1651 Node *node = new_check(LE_CHECK,yyvsp[0].id);
1652 checks = g_list_append(checks,node);
1658 Node *node = new_check(EQ_CHECK,yyvsp[0].id);
1659 checks = g_list_append(checks,node);
1665 Node *node = new_check(NE_CHECK,yyvsp[0].id);
1666 checks = g_list_append(checks,node);
1671 { yyval.id = yyvsp[0].id; ;
1676 yyval.id = g_strconcat("-",yyvsp[0].id,NULL);
1677 g_free(yyvsp[0].id);
1682 { yyval.id = yyvsp[0].id; ;
1685 /* the action file gets copied in in place of this dollarsign */
1686 #line 543 "/usr/lib/bison.simple"
1697 short *ssp1 = yyss - 1;
1698 fprintf (stderr, "state stack now");
1699 while (ssp1 != yyssp)
1700 fprintf (stderr, " %d", *++ssp1);
1701 fprintf (stderr, "\n");
1711 yylsp->first_line = yylloc.first_line;
1712 yylsp->first_column = yylloc.first_column;
1713 yylsp->last_line = (yylsp-1)->last_line;
1714 yylsp->last_column = (yylsp-1)->last_column;
1719 yylsp->last_line = (yylsp+yylen-1)->last_line;
1720 yylsp->last_column = (yylsp+yylen-1)->last_column;
1724 /* Now "shift" the result of the reduction.
1725 Determine what state that goes to,
1726 based on the state we popped back to
1727 and the rule number reduced by. */
1731 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1732 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1733 yystate = yytable[yystate];
1735 yystate = yydefgoto[yyn - YYNTBASE];
1739 yyerrlab: /* here on detecting error */
1742 /* If not already recovering from an error, report this error. */
1746 #ifdef YYERROR_VERBOSE
1747 yyn = yypact[yystate];
1749 if (yyn > YYFLAG && yyn < YYLAST)
1756 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1757 for (x = (yyn < 0 ? -yyn : 0);
1758 x < (sizeof(yytname) / sizeof(char *)); x++)
1759 if (yycheck[x + yyn] == x)
1760 size += strlen(yytname[x]) + 15, count++;
1761 msg = (char *) malloc(size + 15);
1764 strcpy(msg, "parse error");
1769 for (x = (yyn < 0 ? -yyn : 0);
1770 x < (sizeof(yytname) / sizeof(char *)); x++)
1771 if (yycheck[x + yyn] == x)
1773 strcat(msg, count == 0 ? ", expecting `" : " or `");
1774 strcat(msg, yytname[x]);
1783 yyerror ("parse error; also virtual memory exceeded");
1786 #endif /* YYERROR_VERBOSE */
1787 yyerror("parse error");
1791 yyerrlab1: /* here on error raised explicitly by an action */
1793 if (yyerrstatus == 3)
1795 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1797 /* return failure if at end of input */
1798 if (yychar == YYEOF)
1803 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1809 /* Else will try to reuse lookahead token
1810 after shifting the error token. */
1812 yyerrstatus = 3; /* Each real token shifted decrements this */
1816 yyerrdefault: /* current state does not do anything special for the error token. */
1819 /* This is wrong; only states that explicitly want error tokens
1820 should shift them. */
1821 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1822 if (yyn) goto yydefault;
1825 yyerrpop: /* pop the current state because it cannot handle the error token */
1827 if (yyssp == yyss) YYABORT;
1837 short *ssp1 = yyss - 1;
1838 fprintf (stderr, "Error: state stack now");
1839 while (ssp1 != yyssp)
1840 fprintf (stderr, " %d", *++ssp1);
1841 fprintf (stderr, "\n");
1847 yyn = yypact[yystate];
1852 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1871 fprintf(stderr, "Shifting error token, ");
1883 /* YYACCEPT comes here. */
1895 /* YYABORT comes here. */