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 /* a complicated and ugly test to figure out if we have
124 the wrong number of types for a signal */
125 if((scope == SIGNAL_FIRST_METHOD ||
126 scope == SIGNAL_LAST_METHOD ||
127 scope == PRIVATE_SIGNAL_FIRST_METHOD ||
128 scope == PRIVATE_SIGNAL_LAST_METHOD) &&
129 g_list_length(gtktypes) != g_list_length(funcargs) &&
130 !(g_list_length(funcargs) == 1 &&
131 g_list_length(gtktypes) == 2 &&
132 strcmp(gtktypes->next->data,"NONE")==0)) {
133 print_error(TRUE, _("The number of GTK arguments and "
134 "function arguments for a signal "
135 "don't seem to match"),line_no);
137 node = new_method(scope,type,oid,gtktypes,id,funcargs,
138 onerror,cbuf,line_no,ccode_line,vararg);
142 class_nodes = g_list_append(class_nodes, node);
146 push_funcarg(char *name)
149 Type *type = typestack->data;
150 typestack = g_list_remove(typestack,typestack->data);
152 node = new_funcarg(type,name,checks);
155 funcargs = g_list_append(funcargs, node);
159 push_init_arg(char *name, int is_class)
166 tn = g_strconcat(((Class *)class)->otype,":Class",NULL);
168 tn = g_strdup(((Class *)class)->otype);
170 type = new_type(1,tn);
171 node = new_funcarg((Type *)type,name,NULL);
172 funcargs = g_list_prepend(funcargs, node);
181 type = new_type(1,g_strdup(((Class *)class)->otype));
182 ch = g_list_append(ch,new_check(NULL_CHECK,NULL));
183 ch = g_list_append(ch,new_check(TYPE_CHECK,NULL));
184 node = new_funcarg((Type *)type,id,ch);
185 funcargs = g_list_prepend(funcargs, node);
212 #define YYFLAG -32768
215 #define YYTRANSLATE(x) ((unsigned)(x) <= 284 ? yytranslate[x] : 73)
217 static const char yytranslate[] = { 0,
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, 43, 2, 2, 2, 2, 2, 2, 34,
222 35, 37, 2, 38, 44, 2, 2, 2, 40, 2,
223 2, 2, 2, 2, 2, 2, 2, 2, 33, 42,
224 39, 41, 2, 2, 2, 2, 2, 2, 2, 2,
225 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
226 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
227 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
228 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
229 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
230 2, 2, 31, 36, 32, 2, 2, 2, 2, 2,
231 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
232 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
233 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
234 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
235 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
236 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
237 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
238 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
239 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
240 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
241 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
242 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
243 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
244 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
245 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
250 static const short yyprhs[] = { 0,
251 0, 4, 7, 10, 12, 15, 18, 20, 22, 27,
252 32, 35, 38, 41, 43, 45, 47, 52, 57, 69,
253 78, 82, 83, 87, 89, 91, 94, 96, 99, 102,
254 105, 107, 110, 113, 115, 117, 119, 121, 124, 126,
255 128, 131, 133, 136, 138, 140, 142, 144, 146, 149,
256 151, 155, 159, 162, 165, 167, 172, 176, 178, 181,
257 183, 193, 203, 212, 225, 235, 245, 251, 254, 258,
258 261, 262, 264, 266, 270, 272, 276, 278, 282, 284,
259 287, 294, 297, 299, 301, 304, 307, 311, 315, 319,
263 static const short yyrhs[] = { 46,
264 47, 46, 0, 47, 46, 0, 46, 47, 0, 47,
265 0, 46, 23, 0, 46, 24, 0, 23, 0, 24,
266 0, 48, 31, 49, 32, 0, 3, 22, 4, 22,
267 0, 49, 64, 0, 49, 50, 0, 49, 51, 0,
268 64, 0, 50, 0, 51, 0, 25, 54, 20, 33,
269 0, 26, 54, 20, 33, 0, 27, 52, 20, 20,
270 20, 31, 23, 20, 31, 23, 33, 0, 27, 52,
271 20, 20, 20, 31, 23, 33, 0, 34, 53, 35,
272 0, 0, 20, 36, 53, 0, 20, 0, 55, 0,
273 5, 55, 0, 56, 0, 56, 59, 0, 12, 57,
274 0, 11, 57, 0, 57, 0, 12, 18, 0, 11,
275 18, 0, 18, 0, 17, 0, 16, 0, 20, 0,
276 58, 20, 0, 22, 0, 6, 0, 13, 15, 0,
277 13, 0, 14, 15, 0, 14, 0, 15, 0, 9,
278 0, 8, 0, 7, 0, 37, 59, 0, 37, 0,
279 26, 20, 61, 0, 20, 26, 61, 0, 26, 61,
280 0, 20, 61, 0, 61, 0, 20, 34, 62, 35,
281 0, 62, 38, 20, 0, 20, 0, 31, 23, 0,
282 33, 0, 29, 60, 54, 20, 34, 66, 35, 65,
283 63, 0, 28, 26, 54, 20, 34, 66, 35, 65,
284 63, 0, 28, 54, 20, 34, 66, 35, 65, 63,
285 0, 30, 34, 22, 35, 54, 20, 34, 66, 35,
286 65, 31, 23, 0, 25, 54, 20, 34, 66, 35,
287 65, 31, 23, 0, 26, 54, 20, 34, 66, 35,
288 65, 31, 23, 0, 20, 34, 20, 35, 63, 0,
289 19, 72, 0, 19, 31, 23, 0, 39, 40, 0,
290 0, 6, 0, 20, 0, 20, 38, 67, 0, 67,
291 0, 68, 38, 10, 0, 68, 0, 68, 38, 69,
292 0, 69, 0, 54, 20, 0, 54, 20, 34, 20,
293 70, 35, 0, 70, 71, 0, 71, 0, 20, 0,
294 41, 72, 0, 42, 72, 0, 41, 39, 72, 0,
295 42, 39, 72, 0, 39, 39, 72, 0, 43, 39,
296 72, 0, 21, 0, 44, 21, 0, 20, 0
302 static const short yyrline[] = { 0,
303 193, 194, 195, 196, 199, 203, 207, 211, 217, 224,
304 229, 230, 231, 232, 233, 234, 237, 240, 244, 273,
305 299, 300, 303, 306, 312, 313, 321, 325, 332, 335,
306 338, 341, 344, 347, 350, 353, 356, 359, 363, 366,
307 371, 374, 377, 380, 383, 388, 391, 394, 399, 400,
308 403, 415, 427, 430, 442, 447, 452, 455, 460, 461,
309 465, 475, 485, 495, 501, 506, 511, 532, 533, 537,
310 538, 541, 542, 553, 563, 566, 567, 570, 571, 574,
311 577, 587, 588, 591, 604, 608, 612, 616, 620, 624,
317 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
319 static const char * const yytname[] = { "$","error","$undefined.","CLASS",
320 "FROM","CONST","VOID","STRUCT","UNION","ENUM","THREEDOTS","SIGNED","UNSIGNED",
321 "LONG","SHORT","INT","FLOAT","DOUBLE","CHAR","ONERROR","TOKEN","NUMBER","TYPETOKEN",
322 "CCODE","HCODE","PUBLIC","PRIVATE","ARGUMENT","VIRTUAL","SIGNAL","OVERRIDE",
323 "'{'","'}'","';'","'('","')'","'|'","'*'","','","'='","'1'","'>'","'<'","'!'",
324 "'-'","prog","ccodes","class","classdec","classcode","variable","argument","argflags",
325 "flaglist","type","type1","type2","integer","tspecifier","stars","fullsigtype",
326 "sigtype","tokenlist","codenocode","method","onerror","funcargs","arglist","arglist1",
327 "arg","checklist","check","numtok", NULL
331 static const short yyr1[] = { 0,
332 45, 45, 45, 45, 46, 46, 46, 46, 47, 48,
333 49, 49, 49, 49, 49, 49, 50, 50, 51, 51,
334 52, 52, 53, 53, 54, 54, 55, 55, 56, 56,
335 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
336 57, 57, 57, 57, 57, 58, 58, 58, 59, 59,
337 60, 60, 60, 60, 60, 61, 62, 62, 63, 63,
338 64, 64, 64, 64, 64, 64, 64, 65, 65, 65,
339 65, 66, 66, 66, 66, 67, 67, 68, 68, 69,
340 69, 70, 70, 71, 71, 71, 71, 71, 71, 71,
344 static const short yyr2[] = { 0,
345 3, 2, 2, 1, 2, 2, 1, 1, 4, 4,
346 2, 2, 2, 1, 1, 1, 4, 4, 11, 8,
347 3, 0, 3, 1, 1, 2, 1, 2, 2, 2,
348 1, 2, 2, 1, 1, 1, 1, 2, 1, 1,
349 2, 1, 2, 1, 1, 1, 1, 1, 2, 1,
350 3, 3, 2, 2, 1, 4, 3, 1, 2, 1,
351 9, 9, 8, 12, 9, 9, 5, 2, 3, 2,
352 0, 1, 1, 3, 1, 3, 1, 3, 1, 2,
353 6, 2, 1, 1, 2, 2, 3, 3, 3, 3,
357 static const short yydefact[] = { 0,
358 0, 7, 8, 0, 4, 0, 0, 5, 6, 3,
359 2, 0, 0, 1, 0, 0, 0, 22, 0, 0,
360 0, 0, 15, 16, 14, 10, 0, 0, 40, 48,
361 47, 46, 0, 0, 42, 44, 45, 36, 35, 34,
362 37, 39, 0, 25, 27, 31, 0, 0, 0, 0,
363 0, 0, 0, 0, 0, 55, 0, 9, 12, 13,
364 11, 0, 26, 33, 30, 32, 29, 41, 43, 0,
365 50, 28, 38, 0, 24, 0, 0, 0, 0, 0,
366 0, 0, 54, 0, 53, 0, 0, 0, 17, 0,
367 49, 18, 0, 0, 21, 0, 0, 0, 52, 58,
368 0, 51, 0, 0, 0, 60, 67, 40, 37, 0,
369 0, 75, 77, 79, 0, 23, 0, 0, 0, 56,
370 0, 0, 0, 59, 0, 80, 71, 0, 71, 0,
371 0, 71, 57, 0, 0, 74, 0, 0, 0, 0,
372 76, 78, 0, 0, 71, 0, 71, 0, 0, 93,
373 91, 0, 0, 68, 70, 0, 0, 0, 20, 0,
374 63, 0, 0, 84, 0, 0, 0, 0, 0, 83,
375 69, 92, 65, 66, 0, 62, 61, 71, 0, 0,
376 85, 0, 86, 0, 81, 82, 0, 0, 89, 87,
377 88, 90, 19, 0, 64, 0, 0, 0
380 static const short yydefgoto[] = { 196,
381 4, 5, 6, 22, 23, 24, 50, 76, 110, 44,
382 45, 46, 47, 72, 55, 56, 101, 107, 25, 140,
383 111, 112, 113, 114, 169, 170, 154
386 static const short yypact[] = { 21,
387 -18,-32768,-32768, 68, 66, 20, 54,-32768,-32768, 66,
388 155, 171, 0, 155, 48, 116, 116, 52, 61, -14,
389 59, 160,-32768,-32768,-32768,-32768, 29, 151,-32768,-32768,
390 -32768,-32768, 81, 189, 111, 120,-32768,-32768,-32768,-32768,
391 -32768,-32768, 117,-32768, 64,-32768, 124, 133, 135, 152,
392 116, 154, 150, 163, 116,-32768, 186,-32768,-32768,-32768,
393 -32768, 158,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 148,
394 64,-32768,-32768, 161, 173, 175, 191, 192, 179, 180,
395 195, 196,-32768, 28,-32768, 197, 183, 86,-32768, 134,
396 -32768,-32768, 134, 135,-32768, 199, 187, 134,-32768,-32768,
397 -22,-32768, 188, 116, 200,-32768,-32768, 185, 18, 204,
398 190,-32768, 193,-32768, 194,-32768, 201, 134, 198,-32768,
399 206, 134, 207,-32768, 116, 202, 41, 98, 41, 205,
400 203, 41,-32768, 208, 210,-32768, 214, -6, 209, 211,
401 -32768,-32768, 215, 26, 41, 86, 41, 134, 22,-32768,
402 -32768, 212, 216,-32768,-32768, 217, 218, 219,-32768, 86,
403 -32768, 86, 213,-32768, 220, -3, 8, 221, -9,-32768,
404 -32768,-32768,-32768,-32768, 222,-32768,-32768, 41, -1, -1,
405 -32768, -1,-32768, -1,-32768,-32768, 223, 224,-32768,-32768,
406 -32768,-32768,-32768, 228,-32768, 230, 239,-32768
409 static const short yypgoto[] = {-32768,
410 45, 243,-32768,-32768, 231, 232,-32768, 164, -16, 229,
411 -32768, 172,-32768, 181,-32768, -44,-32768, 15, 240, -124,
412 -91, 136,-32768, 137,-32768, 94, -82
419 static const short yytable[] = { 43,
420 48, 115, 52, 7, 143, 53, 119, 146, 83, 85,
421 164, 54, 120, 150, 151, 121, 150, 151, 150, 151,
422 160, 26, 162, 1, 152, 185, 131, 150, 151, 165,
423 134, 166, 167, 168, 78, 180, 99, 153, 86, 102,
424 153, 164, 153, 2, 3, 158, 182, 80, 62, 11,
425 12, 153, -73, 188, 14, 125, 163, 13, 159, 138,
426 165, 82, 166, 167, 168, 28, 29, 30, 31, 32,
427 1, 33, 34, 35, 36, 37, 38, 39, 40, 139,
428 41, 27, 42, 181, 183, 49, 51, 123, 2, 3,
429 8, 9, 57, 35, 36, 37, 189, 190, 64, 191,
430 71, 192, 28, 29, 30, 31, 32, 141, 33, 34,
431 35, 36, 37, 38, 39, 40, 105, 41, 106, 42,
432 28, 29, 30, 31, 32, 68, 33, 34, 35, 36,
433 37, 38, 39, 40, 69, 41, 70, 42, 28, 108,
434 30, 31, 32, 73, 33, 34, 35, 36, 37, 38,
435 39, 40, 74, 109, 75, 42, 29, 30, 31, 32,
436 161, 33, 34, 35, 36, 37, 38, 39, 40, 80,
437 41, 77, 42, 79, 176, 81, 177, 8, 9, 15,
438 89, 90, 84, 82, 16, 17, 18, 19, 20, 21,
439 15, 58, 88, 92, 93, 16, 17, 18, 19, 20,
440 21, 35, 36, 37, 65, 67, 66, 87, 94, 95,
441 96, 97, 98, 82, 80, 100, 103, 104, 117, -72,
442 118, 122, 124, 126, 127, 133, 135, 144, 129, 197,
443 128, 130, 132, 149, 171, 137, 172, 145, 198, 173,
444 174, 156, 147, 148, 187, 157, 10, 178, 155, 175,
445 195, 91, 59, 60, 194, 193, 63, 116, 179, 184,
449 static const short yycheck[] = { 16,
450 17, 93, 19, 22, 129, 20, 98, 132, 53, 54,
451 20, 26, 35, 20, 21, 38, 20, 21, 20, 21,
452 145, 22, 147, 3, 31, 35, 118, 20, 21, 39,
453 122, 41, 42, 43, 51, 39, 81, 44, 55, 84,
454 44, 20, 44, 23, 24, 20, 39, 20, 20, 5,
455 31, 44, 35, 178, 10, 38, 148, 4, 33, 19,
456 39, 34, 41, 42, 43, 5, 6, 7, 8, 9,
457 3, 11, 12, 13, 14, 15, 16, 17, 18, 39,
458 20, 34, 22, 166, 167, 34, 26, 104, 23, 24,
459 23, 24, 34, 13, 14, 15, 179, 180, 18, 182,
460 37, 184, 5, 6, 7, 8, 9, 10, 11, 12,
461 13, 14, 15, 16, 17, 18, 31, 20, 33, 22,
462 5, 6, 7, 8, 9, 15, 11, 12, 13, 14,
463 15, 16, 17, 18, 15, 20, 20, 22, 5, 6,
464 7, 8, 9, 20, 11, 12, 13, 14, 15, 16,
465 17, 18, 20, 20, 20, 22, 6, 7, 8, 9,
466 146, 11, 12, 13, 14, 15, 16, 17, 18, 20,
467 20, 20, 22, 20, 160, 26, 162, 23, 24, 20,
468 33, 34, 20, 34, 25, 26, 27, 28, 29, 30,
469 20, 32, 35, 33, 34, 25, 26, 27, 28, 29,
470 30, 13, 14, 15, 33, 34, 18, 22, 36, 35,
471 20, 20, 34, 34, 20, 20, 20, 35, 20, 35,
472 34, 34, 23, 20, 35, 20, 20, 23, 35, 0,
473 38, 31, 35, 20, 23, 34, 21, 35, 0, 23,
474 23, 31, 35, 34, 23, 31, 4, 35, 40, 31,
475 23, 71, 22, 22, 31, 33, 28, 94, 39, 39,
476 125, 22, 169, -1, 128
478 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
479 #line 3 "/usr/lib/bison.simple"
480 /* This file comes from bison-1.28. */
482 /* Skeleton output parser for bison,
483 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
485 This program is free software; you can redistribute it and/or modify
486 it under the terms of the GNU General Public License as published by
487 the Free Software Foundation; either version 2, or (at your option)
490 This program is distributed in the hope that it will be useful,
491 but WITHOUT ANY WARRANTY; without even the implied warranty of
492 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
493 GNU General Public License for more details.
495 You should have received a copy of the GNU General Public License
496 along with this program; if not, write to the Free Software
497 Foundation, Inc., 59 Temple Place - Suite 330,
498 Boston, MA 02111-1307, USA. */
500 /* As a special exception, when this file is copied by Bison into a
501 Bison output file, you may use that output file without restriction.
502 This special exception was added by the Free Software Foundation
503 in version 1.24 of Bison. */
505 /* This is the parser code that is written into each bison parser
506 when the %semantic_parser declaration is not specified in the grammar.
507 It was written by Richard Stallman by simplifying the hairy parser
508 used when %semantic_parser is specified. */
510 #ifndef YYSTACK_USE_ALLOCA
512 #define YYSTACK_USE_ALLOCA
513 #else /* alloca not defined */
515 #define YYSTACK_USE_ALLOCA
516 #define alloca __builtin_alloca
517 #else /* not GNU C. */
518 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
519 #define YYSTACK_USE_ALLOCA
521 #else /* not sparc */
522 /* We think this test detects Watcom and Microsoft C. */
523 /* This used to test MSDOS, but that is a bad idea
524 since that symbol is in the user namespace. */
525 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
526 #if 0 /* No need for malloc.h, which pollutes the namespace;
527 instead, just don't use alloca. */
530 #else /* not MSDOS, or __TURBOC__ */
532 /* I don't know what this was needed for, but it pollutes the namespace.
533 So I turned it off. rms, 2 May 1997. */
534 /* #include <malloc.h> */
536 #define YYSTACK_USE_ALLOCA
537 #else /* not MSDOS, or __TURBOC__, or _AIX */
539 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
540 and on HPUX 10. Eventually we can turn this on. */
541 #define YYSTACK_USE_ALLOCA
542 #define alloca __builtin_alloca
545 #endif /* not _AIX */
546 #endif /* not MSDOS, or __TURBOC__ */
547 #endif /* not sparc */
548 #endif /* not GNU C */
549 #endif /* alloca not defined */
550 #endif /* YYSTACK_USE_ALLOCA not defined */
552 #ifdef YYSTACK_USE_ALLOCA
553 #define YYSTACK_ALLOC alloca
555 #define YYSTACK_ALLOC malloc
558 /* Note: there must be only one dollar sign in this file.
559 It is replaced by the list of actions, each action
560 as one case of the switch. */
562 #define yyerrok (yyerrstatus = 0)
563 #define yyclearin (yychar = YYEMPTY)
566 #define YYACCEPT goto yyacceptlab
567 #define YYABORT goto yyabortlab
568 #define YYERROR goto yyerrlab1
569 /* Like YYERROR except do call yyerror.
570 This remains here temporarily to ease the
571 transition to the new meaning of YYERROR, for GCC.
572 Once GCC version 2 has supplanted version 1, this can go. */
573 #define YYFAIL goto yyerrlab
574 #define YYRECOVERING() (!!yyerrstatus)
575 #define YYBACKUP(token, value) \
577 if (yychar == YYEMPTY && yylen == 1) \
578 { yychar = (token), yylval = (value); \
579 yychar1 = YYTRANSLATE (yychar); \
584 { yyerror ("syntax error: cannot back up"); YYERROR; } \
588 #define YYERRCODE 256
591 #define YYLEX yylex()
597 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
599 #define YYLEX yylex(&yylval, &yylloc)
601 #else /* not YYLSP_NEEDED */
603 #define YYLEX yylex(&yylval, YYLEX_PARAM)
605 #define YYLEX yylex(&yylval)
607 #endif /* not YYLSP_NEEDED */
610 /* If nonreentrant, generate the variables here */
614 int yychar; /* the lookahead symbol */
615 YYSTYPE yylval; /* the semantic value of the */
616 /* lookahead symbol */
619 YYLTYPE yylloc; /* location data for the lookahead */
623 int yynerrs; /* number of parse errors so far */
624 #endif /* not YYPURE */
627 int yydebug; /* nonzero means print parse trace */
628 /* Since this is uninitialized, it does not stop multiple parsers
632 /* YYINITDEPTH indicates the initial size of the parser's stacks */
635 #define YYINITDEPTH 200
638 /* YYMAXDEPTH is the maximum size the stacks can grow to
639 (effective only if the built-in stack extension method is used). */
646 #define YYMAXDEPTH 10000
649 /* Define __yy_memcpy. Note that the size argument
650 should be passed with type unsigned int, because that is what the non-GCC
651 definitions require. With GCC, __builtin_memcpy takes an arg
652 of type size_t, but it can handle unsigned int. */
654 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
655 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
656 #else /* not GNU C or C++ */
659 /* This is the most reliable way to avoid incompatibilities
660 in available built-in functions on various systems. */
662 __yy_memcpy (to, from, count)
667 register char *f = from;
668 register char *t = to;
669 register int i = count;
675 #else /* __cplusplus */
677 /* This is the most reliable way to avoid incompatibilities
678 in available built-in functions on various systems. */
680 __yy_memcpy (char *to, char *from, unsigned int count)
682 register char *t = to;
683 register char *f = from;
684 register int i = count;
693 #line 217 "/usr/lib/bison.simple"
695 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
696 into yyparse. The argument should have type void *.
697 It should actually point to an object.
698 Grammar actions can access the variable by casting it
699 to the proper pointer type. */
703 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
704 #define YYPARSE_PARAM_DECL
705 #else /* not __cplusplus */
706 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
707 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
708 #endif /* not __cplusplus */
709 #else /* not YYPARSE_PARAM */
710 #define YYPARSE_PARAM_ARG
711 #define YYPARSE_PARAM_DECL
712 #endif /* not YYPARSE_PARAM */
714 /* Prevent warning if -Wstrict-prototypes. */
717 int yyparse (void *);
724 yyparse(YYPARSE_PARAM_ARG)
727 register int yystate;
729 register short *yyssp;
730 register YYSTYPE *yyvsp;
731 int yyerrstatus; /* number of tokens to shift before error messages enabled */
732 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
734 short yyssa[YYINITDEPTH]; /* the state stack */
735 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
737 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
738 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
741 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
742 YYLTYPE *yyls = yylsa;
745 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
747 #define YYPOPSTACK (yyvsp--, yyssp--)
750 int yystacksize = YYINITDEPTH;
751 int yyfree_stacks = 0;
762 YYSTYPE yyval; /* the variable used to return */
763 /* semantic values from the action */
770 fprintf(stderr, "Starting parse\n");
776 yychar = YYEMPTY; /* Cause a token to be read. */
778 /* Initialize stack pointers.
779 Waste one element of value and location stack
780 so that they stay on the same level as the state stack.
781 The wasted elements are never initialized. */
789 /* Push a new state, which is found in yystate . */
790 /* In all cases, when you get here, the value and location stacks
791 have just been pushed. so pushing a state here evens the stacks. */
796 if (yyssp >= yyss + yystacksize - 1)
798 /* Give user a chance to reallocate the stack */
799 /* Use copies of these so that the &'s don't force the real ones into memory. */
800 YYSTYPE *yyvs1 = yyvs;
803 YYLTYPE *yyls1 = yyls;
806 /* Get the current used size of the three stacks, in elements. */
807 int size = yyssp - yyss + 1;
810 /* Each stack pointer address is followed by the size of
811 the data in use in that stack, in bytes. */
813 /* This used to be a conditional around just the two extra args,
814 but that might be undefined if yyoverflow is a macro. */
815 yyoverflow("parser stack overflow",
816 &yyss1, size * sizeof (*yyssp),
817 &yyvs1, size * sizeof (*yyvsp),
818 &yyls1, size * sizeof (*yylsp),
821 yyoverflow("parser stack overflow",
822 &yyss1, size * sizeof (*yyssp),
823 &yyvs1, size * sizeof (*yyvsp),
827 yyss = yyss1; yyvs = yyvs1;
831 #else /* no yyoverflow */
832 /* Extend the stack our own way. */
833 if (yystacksize >= YYMAXDEPTH)
835 yyerror("parser stack overflow");
847 if (yystacksize > YYMAXDEPTH)
848 yystacksize = YYMAXDEPTH;
849 #ifndef YYSTACK_USE_ALLOCA
852 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
853 __yy_memcpy ((char *)yyss, (char *)yyss1,
854 size * (unsigned int) sizeof (*yyssp));
855 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
856 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
857 size * (unsigned int) sizeof (*yyvsp));
859 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
860 __yy_memcpy ((char *)yyls, (char *)yyls1,
861 size * (unsigned int) sizeof (*yylsp));
863 #endif /* no yyoverflow */
865 yyssp = yyss + size - 1;
866 yyvsp = yyvs + size - 1;
868 yylsp = yyls + size - 1;
873 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
876 if (yyssp >= yyss + yystacksize - 1)
882 fprintf(stderr, "Entering state %d\n", yystate);
888 /* Do appropriate processing given the current state. */
889 /* Read a lookahead token if we need one and don't already have one. */
892 /* First try to decide what to do without reference to lookahead token. */
894 yyn = yypact[yystate];
898 /* Not known => get a lookahead token if don't already have one. */
900 /* yychar is either YYEMPTY or YYEOF
901 or a valid token in external form. */
903 if (yychar == YYEMPTY)
907 fprintf(stderr, "Reading a token: ");
912 /* Convert token to internal form (in yychar1) for indexing tables with */
914 if (yychar <= 0) /* This means end of input. */
917 yychar = YYEOF; /* Don't call YYLEX any more */
921 fprintf(stderr, "Now at end of input.\n");
926 yychar1 = YYTRANSLATE(yychar);
931 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
932 /* Give the individual parser a way to print the precise meaning
933 of a token, for further debugging info. */
935 YYPRINT (stderr, yychar, yylval);
937 fprintf (stderr, ")\n");
943 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
948 /* yyn is what to do for this token type in this state.
949 Negative => reduce, -yyn is rule number.
950 Positive => shift, yyn is new state.
951 New state is final state => don't bother to shift,
953 0, or most negative number => error. */
968 /* Shift the lookahead token. */
972 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
975 /* Discard the token being shifted unless it is eof. */
984 /* count tokens shifted since error; after three, turn off error status. */
985 if (yyerrstatus) yyerrstatus--;
990 /* Do the default action for the current state. */
993 yyn = yydefact[yystate];
997 /* Do a reduction. yyn is the number of a rule to reduce with. */
1001 yyval = yyvsp[1-yylen]; /* implement default value of the action */
1008 fprintf (stderr, "Reducing via rule %d (line %d), ",
1011 /* Print the symbols being reduced, and their result. */
1012 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
1013 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
1014 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
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 Node *node = new_ccode(FALSE,yyvsp[0].cbuf,ccode_line);
1055 nodes = g_list_append(nodes,node);
1061 Node *node = new_ccode(TRUE,yyvsp[0].cbuf,ccode_line);
1062 nodes = g_list_append(nodes,node);
1068 ((Class *)class)->nodes = class_nodes;
1070 nodes = g_list_append(nodes,class);
1076 class = new_class(yyvsp[-2].id,yyvsp[0].id,NULL);
1106 push_variable(yyvsp[-1].id,PUBLIC_SCOPE,yyvsp[-3].line);
1112 push_variable(yyvsp[-1].id,PRIVATE_SCOPE,yyvsp[-3].line);
1118 if(strcmp(yyvsp[-6].id,"get")==0 &&
1119 strcmp(yyvsp[-3].id,"set")==0) {
1121 g_free(yyvsp[-6].id); g_free(yyvsp[-3].id);
1122 node = new_argument(yyvsp[-8].id,yyvsp[-9].list,yyvsp[-7].id,
1123 yyvsp[-4].cbuf,yyvsp[-5].line,
1124 yyvsp[-1].cbuf,yyvsp[-2].line,
1126 class_nodes = g_list_append(class_nodes,node);
1127 } else if(strcmp(yyvsp[-6].id,"set")==0 &&
1128 strcmp(yyvsp[-3].id,"get")==0) {
1130 g_free(yyvsp[-6].id); g_free(yyvsp[-3].id);
1131 node = new_argument(yyvsp[-8].id,yyvsp[-9].list,yyvsp[-7].id,
1132 yyvsp[-1].cbuf,yyvsp[-2].line,
1133 yyvsp[-4].cbuf,yyvsp[-5].line,
1135 class_nodes = g_list_append(class_nodes,node);
1137 g_free(yyvsp[-8].id); g_free(yyvsp[-7].id);
1138 g_free(yyvsp[-6].id); g_free(yyvsp[-3].id);
1139 g_list_foreach(yyvsp[-9].list,(GFunc)g_free,NULL);
1140 g_string_free(yyvsp[-1].cbuf,TRUE);
1141 g_string_free(yyvsp[-4].cbuf,TRUE);
1142 yyerror(_("parse error"));
1150 if(strcmp(yyvsp[-3].id,"get")==0) {
1152 g_free(yyvsp[-3].id);
1153 node = new_argument(yyvsp[-5].id,yyvsp[-6].list,yyvsp[-4].id,
1154 yyvsp[-1].cbuf,yyvsp[-2].line,NULL,0,
1156 class_nodes = g_list_append(class_nodes,node);
1157 } else if(strcmp(yyvsp[-3].id,"set")==0) {
1159 g_free(yyvsp[-3].id);
1160 node = new_argument(yyvsp[-5].id,yyvsp[-6].list,yyvsp[-4].id,
1161 NULL,0,yyvsp[-1].cbuf,yyvsp[-2].line,
1163 class_nodes = g_list_append(class_nodes,node);
1165 g_free(yyvsp[-3].id); g_free(yyvsp[-5].id);
1166 g_free(yyvsp[-4].id);
1167 g_list_foreach(yyvsp[-6].list,(GFunc)g_free,NULL);
1168 g_string_free(yyvsp[-1].cbuf,TRUE);
1169 yyerror(_("parse error"));
1176 { yyval.list = yyvsp[-1].list; ;
1180 { yyval.list = NULL; ;
1185 yyval.list = g_list_append(yyvsp[0].list,yyvsp[-2].id);
1191 yyval.list = g_list_append(NULL,yyvsp[0].id);
1201 Type *type = typestack->data;
1202 char *oldname = type->name;
1203 type->name = g_strconcat("const ",oldname,NULL);
1210 Node *node = new_type(0,yyvsp[0].id);
1211 typestack = g_list_prepend(typestack,node);
1217 Node *node = new_type(stars,yyvsp[-1].id);
1219 typestack = g_list_prepend(typestack,node);
1225 yyval.id = g_strconcat("unsigned ",yyvsp[0].id,NULL);
1231 yyval.id = g_strconcat("signed ",yyvsp[0].id,NULL);
1237 yyval.id = g_strdup(yyvsp[0].id);
1243 yyval.id = g_strdup("unsigned char");
1249 yyval.id = g_strdup("signed char");
1255 yyval.id = g_strdup("char");
1261 yyval.id = g_strdup("double");
1267 yyval.id = g_strdup("float");
1273 yyval.id = yyvsp[0].id;
1279 yyval.id = g_strconcat(yyvsp[-1].id,yyvsp[0].id,NULL);
1280 g_free(yyvsp[0].id);
1286 yyval.id = yyvsp[0].id;
1292 yyval.id = g_strdup("void");
1298 yyval.id = "long int";
1310 yyval.id = "short int";
1334 yyval.id = "union ";
1340 yyval.id = "struct ";
1354 if(strcmp(yyvsp[-1].id,"first")==0)
1355 yyval.sigtype = PRIVATE_SIGNAL_FIRST_METHOD;
1356 else if(strcmp(yyvsp[-1].id,"last")==0)
1357 yyval.sigtype = PRIVATE_SIGNAL_LAST_METHOD;
1359 yyerror(_("signal must be 'first' or 'last'"));
1360 g_free(yyvsp[-1].id);
1363 g_free(yyvsp[-1].id);
1369 if(strcmp(yyvsp[-2].id,"first")==0)
1370 yyval.sigtype = PRIVATE_SIGNAL_FIRST_METHOD;
1371 else if(strcmp(yyvsp[-2].id,"last")==0)
1372 yyval.sigtype = PRIVATE_SIGNAL_LAST_METHOD;
1374 yyerror(_("signal must be 'first' or 'last'"));
1375 g_free(yyvsp[-2].id);
1378 g_free(yyvsp[-2].id);
1384 yyval.sigtype = PRIVATE_SIGNAL_LAST_METHOD;
1390 if(strcmp(yyvsp[-1].id,"first")==0)
1391 yyval.sigtype = SIGNAL_FIRST_METHOD;
1392 else if(strcmp(yyvsp[-1].id,"last")==0)
1393 yyval.sigtype = SIGNAL_LAST_METHOD;
1395 yyerror(_("signal must be 'first' or 'last'"));
1396 g_free(yyvsp[-1].id);
1399 g_free(yyvsp[-1].id);
1405 yyval.sigtype = SIGNAL_LAST_METHOD;
1411 gtktypes = g_list_prepend(gtktypes,yyvsp[-3].id);
1417 gtktypes = g_list_append(gtktypes,yyvsp[0].id);
1423 gtktypes = g_list_append(gtktypes,yyvsp[0].id);
1428 { yyval.cbuf=yyvsp[0].cbuf; ;
1432 { yyval.cbuf = NULL; ;
1438 yyerror(_("signal without 'self' as "
1439 "first parameter"));
1442 push_function(yyvsp[-7].sigtype,NULL,
1443 yyvsp[-5].id, yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-8].line,
1451 yyerror(_("virtual method without 'self' as "
1452 "first parameter"));
1455 push_function(PRIVATE_VIRTUAL_METHOD, NULL, yyvsp[-5].id,
1456 yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-8].line,
1464 yyerror(_("virtual method without 'self' as "
1465 "first parameter"));
1468 push_function(VIRTUAL_METHOD, NULL, yyvsp[-5].id,
1469 yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-7].line,
1476 push_function(OVERRIDE_METHOD, yyvsp[-9].id,
1477 yyvsp[-6].id, yyvsp[-2].id, yyvsp[0].cbuf,
1478 yyvsp[-11].line,yyvsp[-1].line,
1485 push_function(PUBLIC_SCOPE, NULL, yyvsp[-6].id,
1486 yyvsp[-2].id, yyvsp[0].cbuf,yyvsp[-8].line,yyvsp[-1].line,
1493 push_function(PRIVATE_SCOPE, NULL, yyvsp[-6].id,
1494 yyvsp[-2].id, yyvsp[0].cbuf,yyvsp[-8].line,yyvsp[-1].line,
1501 if(strcmp(yyvsp[-4].id,"init")==0) {
1502 push_init_arg(yyvsp[-2].id,FALSE);
1503 push_function(INIT_METHOD, NULL,
1504 yyvsp[-4].id, NULL, yyvsp[0].cbuf,yyvsp[-3].line,
1506 } else if(strcmp(yyvsp[-4].id,"class_init")==0) {
1507 push_init_arg(yyvsp[-2].id,TRUE);
1508 push_function(CLASS_INIT_METHOD, NULL,
1509 yyvsp[-4].id, NULL, yyvsp[0].cbuf,yyvsp[-3].line,
1512 g_free(yyvsp[-4].id);
1513 g_free(yyvsp[-2].id);
1514 g_string_free(yyvsp[-2].cbuf,TRUE);
1515 yyerror(_("parse error"));
1522 { yyval.id = yyvsp[0].id; ;
1527 yyval.id = (yyvsp[0].cbuf)->str;
1528 g_string_free(yyvsp[0].cbuf,FALSE);
1537 { yyval.id = NULL; ;
1541 { vararg = FALSE; has_self = FALSE; ;
1548 if(strcmp(yyvsp[0].id,"self")==0)
1549 push_self(yyvsp[0].id);
1551 g_free(yyvsp[0].id);
1552 yyerror(_("parse error"));
1561 if(strcmp(yyvsp[-2].id,"self")==0)
1562 push_self(yyvsp[-2].id);
1564 g_free(yyvsp[-2].id);
1565 yyerror(_("parse error"));
1572 { has_self = FALSE; ;
1593 push_funcarg(yyvsp[0].id);
1599 if(strcmp(yyvsp[-2].id,"check")!=0) {
1600 yyerror(_("parse error"));
1603 g_free(yyvsp[-2].id);
1604 push_funcarg(yyvsp[-4].id);
1618 if(strcmp(yyvsp[0].id,"type")==0) {
1619 Node *node = new_check(TYPE_CHECK,NULL);
1620 checks = g_list_append(checks,node);
1621 } else if(strcmp(yyvsp[0].id,"null")==0) {
1622 Node *node = new_check(NULL_CHECK,NULL);
1623 checks = g_list_append(checks,node);
1625 yyerror(_("parse error"));
1628 g_free(yyvsp[0].id);
1634 Node *node = new_check(GT_CHECK,yyvsp[0].id);
1635 checks = g_list_append(checks,node);
1641 Node *node = new_check(LT_CHECK,yyvsp[0].id);
1642 checks = g_list_append(checks,node);
1648 Node *node = new_check(GE_CHECK,yyvsp[0].id);
1649 checks = g_list_append(checks,node);
1655 Node *node = new_check(LE_CHECK,yyvsp[0].id);
1656 checks = g_list_append(checks,node);
1662 Node *node = new_check(EQ_CHECK,yyvsp[0].id);
1663 checks = g_list_append(checks,node);
1669 Node *node = new_check(NE_CHECK,yyvsp[0].id);
1670 checks = g_list_append(checks,node);
1675 { yyval.id = yyvsp[0].id; ;
1680 yyval.id = g_strconcat("-",yyvsp[0].id,NULL);
1681 g_free(yyvsp[0].id);
1686 { yyval.id = yyvsp[0].id; ;
1689 /* the action file gets copied in in place of this dollarsign */
1690 #line 543 "/usr/lib/bison.simple"
1701 short *ssp1 = yyss - 1;
1702 fprintf (stderr, "state stack now");
1703 while (ssp1 != yyssp)
1704 fprintf (stderr, " %d", *++ssp1);
1705 fprintf (stderr, "\n");
1715 yylsp->first_line = yylloc.first_line;
1716 yylsp->first_column = yylloc.first_column;
1717 yylsp->last_line = (yylsp-1)->last_line;
1718 yylsp->last_column = (yylsp-1)->last_column;
1723 yylsp->last_line = (yylsp+yylen-1)->last_line;
1724 yylsp->last_column = (yylsp+yylen-1)->last_column;
1728 /* Now "shift" the result of the reduction.
1729 Determine what state that goes to,
1730 based on the state we popped back to
1731 and the rule number reduced by. */
1735 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1736 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1737 yystate = yytable[yystate];
1739 yystate = yydefgoto[yyn - YYNTBASE];
1743 yyerrlab: /* here on detecting error */
1746 /* If not already recovering from an error, report this error. */
1750 #ifdef YYERROR_VERBOSE
1751 yyn = yypact[yystate];
1753 if (yyn > YYFLAG && yyn < YYLAST)
1760 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1761 for (x = (yyn < 0 ? -yyn : 0);
1762 x < (sizeof(yytname) / sizeof(char *)); x++)
1763 if (yycheck[x + yyn] == x)
1764 size += strlen(yytname[x]) + 15, count++;
1765 msg = (char *) malloc(size + 15);
1768 strcpy(msg, "parse error");
1773 for (x = (yyn < 0 ? -yyn : 0);
1774 x < (sizeof(yytname) / sizeof(char *)); x++)
1775 if (yycheck[x + yyn] == x)
1777 strcat(msg, count == 0 ? ", expecting `" : " or `");
1778 strcat(msg, yytname[x]);
1787 yyerror ("parse error; also virtual memory exceeded");
1790 #endif /* YYERROR_VERBOSE */
1791 yyerror("parse error");
1795 yyerrlab1: /* here on error raised explicitly by an action */
1797 if (yyerrstatus == 3)
1799 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1801 /* return failure if at end of input */
1802 if (yychar == YYEOF)
1807 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1813 /* Else will try to reuse lookahead token
1814 after shifting the error token. */
1816 yyerrstatus = 3; /* Each real token shifted decrements this */
1820 yyerrdefault: /* current state does not do anything special for the error token. */
1823 /* This is wrong; only states that explicitly want error tokens
1824 should shift them. */
1825 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1826 if (yyn) goto yydefault;
1829 yyerrpop: /* pop the current state because it cannot handle the error token */
1831 if (yyssp == yyss) YYABORT;
1841 short *ssp1 = yyss - 1;
1842 fprintf (stderr, "Error: state stack now");
1843 while (ssp1 != yyssp)
1844 fprintf (stderr, " %d", *++ssp1);
1845 fprintf (stderr, "\n");
1851 yyn = yypact[yystate];
1856 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1875 fprintf(stderr, "Shifting error token, ");
1887 /* YYACCEPT comes here. */
1899 /* YYABORT comes here. */