]> git.draconx.ca Git - gob-dx.git/blob - src/parse.c
480d236c95927f0beaa9910d03f4c68dd4d0ed9b
[gob-dx.git] / src / parse.c
1
2 /*  A Bison parser, made from parse.y
3     by GNU Bison version 1.28  */
4
5 #define YYBISON 1  /* Identify Bison output.  */
6
7 #define CLASS   257
8 #define FROM    258
9 #define CONST   259
10 #define VOID    260
11 #define STRUCT  261
12 #define UNION   262
13 #define ENUM    263
14 #define THREEDOTS       264
15 #define SIGNED  265
16 #define UNSIGNED        266
17 #define LONG    267
18 #define SHORT   268
19 #define INT     269
20 #define FLOAT   270
21 #define DOUBLE  271
22 #define CHAR    272
23 #define TOKEN   273
24 #define NUMBER  274
25 #define TYPETOKEN       275
26 #define ARRAY_DIM       276
27 #define CCODE   277
28 #define HTCODE  278
29 #define PHCODE  279
30 #define HCODE   280
31 #define ACODE   281
32 #define ATCODE  282
33 #define PUBLIC  283
34 #define PRIVATE 284
35 #define PROTECTED       285
36 #define ARGUMENT        286
37 #define VIRTUAL 287
38 #define SIGNAL  288
39 #define OVERRIDE        289
40
41 #line 21 "parse.y"
42
43
44 #include "config.h"
45 #include <glib.h>
46 #include <stdio.h>
47 #include <string.h>
48
49 #include "treefuncs.h"
50 #include "main.h"
51 #include "util.h"
52
53 #define _(x) (x)
54         
55 GList *nodes = NULL;
56
57 static GList *class_nodes = NULL;
58 Node *class = NULL;
59
60 static GList *typestack = NULL;
61 static int stars = 0;
62 static GList *funcargs = NULL;
63 static GList *checks = NULL;
64 static int has_self = FALSE;
65 static int vararg = FALSE;
66
67 /* destructor and initializer for variables */
68 static char *destructor = NULL;
69 static int destructor_line = 0;
70 static gboolean destructor_simple = TRUE;
71 static char *initializer = NULL;
72 static int initializer_line = 0;
73
74 static char *onerror = NULL;
75 static char *defreturn = NULL;
76
77 static GList *gtktypes = NULL;
78
79 /* this can be a global as we will only do one function at a time
80    anyway */
81 static int the_scope = NO_SCOPE;
82
83 void free(void *ptr);
84 int yylex(void);
85
86 extern int ccode_line;
87 extern int line_no;
88
89 extern char *yytext;
90
91 static void
92 yyerror(char *str)
93 {
94         char *out=NULL;
95         char *p;
96         
97         if(strcmp(yytext,"\n")==0) {
98                 out=g_strconcat("Error: ",str," before newline",NULL);
99         } else if(yytext[0]=='\0') {
100                 out=g_strconcat("Error: ", str, " at end of input", NULL);
101         } else {
102                 char *tmp = g_strdup(yytext);
103                 while((p=strchr(tmp, '\n')))
104                         *p='.';
105
106                 out=g_strconcat("Error: ", str, " before '", tmp, "'", NULL);
107                 g_free(tmp);
108         }
109
110         fprintf(stderr, "%s:%d: %s\n", filename, line_no, out);
111         g_free(out);
112         
113         exit(1);
114 }
115
116 static Type *
117 pop_type(void)
118 {
119         Type *type = typestack->data;
120         typestack = g_list_remove(typestack,typestack->data);
121         return type;
122 }
123
124 static void
125 push_variable(char *name, int scope, int line_no, char *postfix)
126 {
127         Node *var;
128         Type *type = pop_type();
129
130         type->postfix = postfix;
131         
132         var = new_variable(scope, type, name, line_no,
133                            destructor, destructor_line,
134                            destructor_simple,
135                            initializer, initializer_line);
136         class_nodes = g_list_append(class_nodes, var);
137 }
138
139 static void
140 push_function(int scope, int method, char *oid, char *id,
141               GString *cbuf, int line_no, int ccode_line,
142               gboolean vararg, GList *flags)
143 {
144         Node *node;
145         Type *type;
146         char *c_cbuf;
147        
148         if(method!=INIT_METHOD && method!=CLASS_INIT_METHOD) {
149                 type = pop_type();
150         } else {
151                 type = (Type *)new_type(0,g_strdup("void"),NULL);
152         }
153         
154         /* a complicated and ugly test to figure out if we have
155            the wrong number of types for a signal */
156         if((method == SIGNAL_FIRST_METHOD ||
157             method == SIGNAL_LAST_METHOD) &&
158            g_list_length(gtktypes) != g_list_length(funcargs) &&
159            !(g_list_length(funcargs) == 1 &&
160              g_list_length(gtktypes) == 2 &&
161              strcmp(gtktypes->next->data,"NONE")==0)) {
162                 print_error(TRUE, _("The number of GTK arguments and "
163                                     "function arguments for a signal "
164                                     "don't seem to match"), line_no);
165         }
166         if(cbuf) {
167                 char *p;
168                 c_cbuf = p = cbuf->str;
169                 while(p && *p && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
170                         p++;
171                 if(!p || !*p)
172                         c_cbuf = NULL;
173         } else
174                 c_cbuf = NULL;
175
176         node = new_method(scope, method, type, oid, gtktypes, flags,
177                           id, funcargs, onerror, defreturn, c_cbuf, line_no,
178                           ccode_line, vararg);
179
180         if(cbuf)
181                 g_string_free(cbuf,
182                               /*only free segment if we haven't passed it
183                                 above */
184                               c_cbuf?FALSE:TRUE);
185         gtktypes = NULL;
186         funcargs = NULL;
187
188         onerror = NULL;
189         defreturn = NULL;
190
191         class_nodes = g_list_append(class_nodes, node);
192 }
193
194 static void
195 free_all_global_state(void)
196 {
197         g_free(onerror);
198         onerror = NULL;
199         g_free(defreturn);
200         defreturn = NULL;
201
202         g_list_foreach(gtktypes, (GFunc)g_free, NULL);
203         g_list_free(gtktypes);
204         gtktypes = NULL;
205
206         free_node_list(funcargs);
207         funcargs = NULL;
208 }
209
210 static void
211 push_funcarg(char *name, char *postfix)
212 {
213         Node *node;
214         Type *type = pop_type();
215
216         type->postfix = postfix;
217         
218         node = new_funcarg(type, name, checks);
219         checks = NULL;
220         
221         funcargs = g_list_append(funcargs, node);
222 }
223
224 static void
225 push_init_arg(char *name, int is_class)
226 {
227         Node *node;
228         Node *type;
229         char *tn;
230         
231         if(is_class)
232                 tn = g_strconcat(((Class *)class)->otype,":Class",NULL);
233         else
234                 tn = g_strdup(((Class *)class)->otype);
235
236         type = new_type(1,tn,NULL);
237         node = new_funcarg((Type *)type,name,NULL);
238         funcargs = g_list_prepend(funcargs, node);
239 }
240
241 static void
242 push_self(char *id)
243 {
244         Node *node;
245         Node *type;
246         GList *ch = NULL;
247         type = new_type(1,g_strdup(((Class *)class)->otype),NULL);
248         ch = g_list_append(ch,new_check(NULL_CHECK,NULL));
249         ch = g_list_append(ch,new_check(TYPE_CHECK,NULL));
250         node = new_funcarg((Type *)type,id,ch);
251         funcargs = g_list_prepend(funcargs, node);
252 }
253
254 static Variable *
255 find_var_or_die(const char *id, int line)
256 {
257         GList *li;
258         char *s;
259
260         for(li = class_nodes; li != NULL; li = li->next) {
261                 Variable *var;
262                 Node *node = li->data;
263                 if(node->type != VARIABLE_NODE)
264                         continue;
265                 var = li->data;
266                 if(strcmp(var->id, id)==0)
267                         return var;
268         }
269
270         s = g_strdup_printf(_("Variable %s not defined here"), id);
271         print_error(FALSE, s, line);
272
273         g_assert_not_reached();
274         return NULL;
275 }
276
277 static gboolean
278 set_return_value(char *type, char *val)
279 {
280         if(strcmp(type, "onerror")==0) {
281                 if(!onerror) {
282                         onerror = val;
283                         return TRUE;
284                 } else
285                         return FALSE;
286         } else if(strcmp(type, "defreturn")==0) {
287                 if(!defreturn) {
288                         defreturn = val;
289                         return TRUE;
290                 } else
291                         return FALSE;
292         }
293         return FALSE;
294 }
295
296
297 #line 277 "parse.y"
298 typedef union {
299         char *id;
300         GString *cbuf;
301         GList *list;
302         int line;
303         int sigtype;
304 } YYSTYPE;
305 #ifndef YYDEBUG
306 #define YYDEBUG 1
307 #endif
308
309 #include <stdio.h>
310
311 #ifndef __cplusplus
312 #ifndef __STDC__
313 #define const
314 #endif
315 #endif
316
317
318
319 #define YYFINAL         242
320 #define YYFLAG          -32768
321 #define YYNTBASE        49
322
323 #define YYTRANSLATE(x) ((unsigned)(x) <= 289 ? yytranslate[x] : 86)
324
325 static const char yytranslate[] = {     0,
326      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
327      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
328      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
329      2,     2,    47,     2,     2,     2,     2,     2,     2,    40,
330     41,    43,     2,    44,    48,     2,     2,     2,     2,     2,
331      2,     2,     2,     2,     2,     2,     2,     2,    38,    46,
332     39,    45,     2,     2,     2,     2,     2,     2,     2,     2,
333      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
334      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
335      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
336      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
337      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
338      2,     2,    36,    42,    37,     2,     2,     2,     2,     2,
339      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
340      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
341      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
342      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
343      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
344      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
345      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
346      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
347      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
348      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
349      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
350      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
351      2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
352      7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
353     17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
354     27,    28,    29,    30,    31,    32,    33,    34,    35
355 };
356
357 #if YYDEBUG != 0
358 static const short yyprhs[] = {     0,
359      0,     4,     7,    10,    12,    14,    16,    18,    20,    22,
360     24,    27,    29,    34,    38,    43,    46,    48,    50,    52,
361     54,    56,    58,    60,    62,    65,    69,    72,    76,    79,
362     82,    84,    86,    87,    93,   100,   112,   121,   127,   133,
363    135,   139,   140,   144,   146,   148,   151,   153,   156,   159,
364    162,   164,   167,   170,   172,   174,   176,   178,   181,   183,
365    185,   188,   190,   193,   195,   197,   199,   201,   203,   206,
366    208,   211,   213,   217,   221,   224,   226,   231,   235,   237,
367    240,   242,   253,   265,   275,   285,   294,   306,   315,   321,
368    324,   329,   330,   332,   335,   337,   339,   343,   345,   349,
369    351,   355,   357,   360,   364,   371,   379,   382,   384,   386,
370    389,   392,   396,   400,   404,   408,   410,   413
371 };
372
373 static const short yyrhs[] = {    51,
374     52,    51,     0,    52,    51,     0,    51,    52,     0,    52,
375      0,    23,     0,    26,     0,    24,     0,    25,     0,    27,
376      0,    28,     0,    51,    50,     0,    50,     0,    53,    36,
377     54,    37,     0,    53,    36,    37,     0,     3,    21,     4,
378     21,     0,    54,    55,     0,    55,     0,    76,     0,    60,
379      0,    61,     0,    38,     0,    29,     0,    30,     0,    31,
380      0,    19,    19,     0,    19,    36,    23,     0,    39,    85,
381      0,    39,    36,    23,     0,    57,    58,     0,    58,    57,
382      0,    58,     0,    57,     0,     0,    56,    65,    19,    59,
383     38,     0,    56,    65,    19,    22,    59,    38,     0,    32,
384     63,    62,    19,    19,    36,    23,    19,    36,    23,    38,
385      0,    32,    63,    62,    19,    19,    36,    23,    38,     0,
386     32,    63,    62,    19,    19,     0,    19,    40,    19,    65,
387     41,     0,    19,     0,    40,    64,    41,     0,     0,    19,
388     42,    64,     0,    19,     0,    66,     0,     5,    66,     0,
389     67,     0,    67,    70,     0,    12,    68,     0,    11,    68,
390      0,    68,     0,    12,    18,     0,    11,    18,     0,    18,
391      0,    17,     0,    16,     0,    19,     0,    69,    19,     0,
392     21,     0,     6,     0,    13,    15,     0,    13,     0,    14,
393     15,     0,    14,     0,    15,     0,     9,     0,     8,     0,
394      7,     0,    43,    70,     0,    43,     0,    19,    73,     0,
395     73,     0,    56,    19,    73,     0,    19,    56,    73,     0,
396     56,    73,     0,    71,     0,    19,    40,    74,    41,     0,
397     74,    44,    19,     0,    19,     0,    36,    23,     0,    38,
398      0,    34,    63,    72,    65,    19,    40,    79,    41,    77,
399     75,     0,    56,    34,    63,    71,    65,    19,    40,    79,
400     41,    77,    75,     0,    33,    56,    65,    19,    40,    79,
401     41,    77,    75,     0,    56,    33,    65,    19,    40,    79,
402     41,    77,    75,     0,    33,    65,    19,    40,    79,    41,
403     77,    75,     0,    35,    40,    21,    41,    65,    19,    40,
404     79,    41,    77,    75,     0,    56,    65,    19,    40,    79,
405     41,    77,    75,     0,    19,    40,    19,    41,    75,     0,
406     19,    78,     0,    19,    78,    19,    78,     0,     0,    85,
407      0,    36,    23,     0,     6,     0,    19,     0,    19,    44,
408     80,     0,    80,     0,    81,    44,    10,     0,    81,     0,
409     81,    44,    82,     0,    82,     0,    65,    19,     0,    65,
410     19,    22,     0,    65,    19,    40,    19,    83,    41,     0,
411     65,    19,    22,    40,    19,    83,    41,     0,    83,    84,
412      0,    84,     0,    19,     0,    45,    85,     0,    46,    85,
413      0,    45,    39,    85,     0,    46,    39,    85,     0,    39,
414     39,    85,     0,    47,    39,    85,     0,    20,     0,    48,
415     20,     0,    19,     0
416 };
417
418 #endif
419
420 #if YYDEBUG != 0
421 static const short yyrline[] = { 0,
422    295,   296,   297,   298,   301,   307,   313,   319,   325,   331,
423    339,   340,   343,   348,   355,   360,   361,   364,   365,   366,
424    367,   370,   371,   372,   375,   388,   404,   408,   416,   417,
425    418,   419,   420,   426,   429,   433,   468,   496,   561,   570,
426    576,   577,   580,   583,   589,   590,   598,   602,   609,   612,
427    615,   618,   621,   624,   627,   630,   633,   636,   640,   643,
428    648,   651,   654,   657,   660,   665,   668,   671,   676,   677,
429    681,   693,   699,   711,   723,   726,   732,   737,   740,   745,
430    746,   750,   761,   772,   783,   794,   805,   811,   816,   837,
431    848,   867,   873,   874,   880,   881,   892,   902,   905,   906,
432    909,   910,   913,   916,   919,   927,   937,   938,   941,   954,
433    958,   962,   966,   970,   974,   980,   981,   985
434 };
435 #endif
436
437
438 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
439
440 static const char * const yytname[] = {   "$","error","$undefined.","CLASS",
441 "FROM","CONST","VOID","STRUCT","UNION","ENUM","THREEDOTS","SIGNED","UNSIGNED",
442 "LONG","SHORT","INT","FLOAT","DOUBLE","CHAR","TOKEN","NUMBER","TYPETOKEN","ARRAY_DIM",
443 "CCODE","HTCODE","PHCODE","HCODE","ACODE","ATCODE","PUBLIC","PRIVATE","PROTECTED",
444 "ARGUMENT","VIRTUAL","SIGNAL","OVERRIDE","'{'","'}'","';'","'='","'('","')'",
445 "'|'","'*'","','","'>'","'<'","'!'","'-'","prog","ccode","ccodes","class","classdec",
446 "classcode","thing","scope","destructor","initializer","varoptions","variable",
447 "argument","argtype","flags","flaglist","type","type1","type2","integer","tspecifier",
448 "stars","simplesigtype","fullsigtype","sigtype","tokenlist","codenocode","method",
449 "returnvals","retcode","funcargs","arglist","arglist1","arg","checklist","check",
450 "numtok", NULL
451 };
452 #endif
453
454 static const short yyr1[] = {     0,
455     49,    49,    49,    49,    50,    50,    50,    50,    50,    50,
456     51,    51,    52,    52,    53,    54,    54,    55,    55,    55,
457     55,    56,    56,    56,    57,    57,    58,    58,    59,    59,
458     59,    59,    59,    60,    60,    61,    61,    61,    62,    62,
459     63,    63,    64,    64,    65,    65,    66,    66,    67,    67,
460     67,    67,    67,    67,    67,    67,    67,    67,    67,    67,
461     68,    68,    68,    68,    68,    69,    69,    69,    70,    70,
462     71,    71,    72,    72,    72,    72,    73,    74,    74,    75,
463     75,    76,    76,    76,    76,    76,    76,    76,    76,    77,
464     77,    77,    78,    78,    79,    79,    79,    79,    80,    80,
465     81,    81,    82,    82,    82,    82,    83,    83,    84,    84,
466     84,    84,    84,    84,    84,    85,    85,    85
467 };
468
469 static const short yyr2[] = {     0,
470      3,     2,     2,     1,     1,     1,     1,     1,     1,     1,
471      2,     1,     4,     3,     4,     2,     1,     1,     1,     1,
472      1,     1,     1,     1,     2,     3,     2,     3,     2,     2,
473      1,     1,     0,     5,     6,    11,     8,     5,     5,     1,
474      3,     0,     3,     1,     1,     2,     1,     2,     2,     2,
475      1,     2,     2,     1,     1,     1,     1,     2,     1,     1,
476      2,     1,     2,     1,     1,     1,     1,     1,     2,     1,
477      2,     1,     3,     3,     2,     1,     4,     3,     1,     2,
478      1,    10,    11,     9,     9,     8,    11,     8,     5,     2,
479      4,     0,     1,     2,     1,     1,     3,     1,     3,     1,
480      3,     1,     2,     3,     6,     7,     2,     1,     1,     2,
481      2,     3,     3,     3,     3,     1,     2,     1
482 };
483
484 static const short yydefact[] = {     0,
485      0,     5,     7,     8,     6,     9,    10,    12,     0,     4,
486      0,     0,    11,     3,     2,     0,     0,     1,     0,    22,
487     23,    24,    42,     0,    42,     0,    14,    21,     0,    17,
488      0,    19,    20,    18,    15,     0,     0,     0,     0,    60,
489     68,    67,    66,     0,     0,    62,    64,    65,    56,    55,
490     54,    57,    59,     0,     0,    45,    47,    51,     0,     0,
491      0,    13,    16,     0,    42,     0,     0,    44,     0,    40,
492      0,    46,    53,    50,    52,    49,    61,    63,     0,     0,
493     70,    48,    58,     0,     0,    76,     0,    72,     0,     0,
494      0,    33,     0,     0,    41,     0,     0,     0,     0,    69,
495      0,     0,     0,    71,     0,    75,     0,     0,     0,     0,
496      0,     0,    33,     0,     0,    32,    31,     0,     0,    81,
497     89,    43,     0,    38,     0,    60,    57,     0,     0,    98,
498    100,   102,    79,     0,    74,    73,     0,     0,     0,     0,
499     25,     0,     0,   118,   116,     0,     0,    27,     0,    29,
500     30,    34,    80,     0,     0,     0,     0,   103,    92,     0,
501     77,     0,     0,     0,     0,     0,    26,    35,    28,   117,
502     92,    39,     0,    92,    97,   104,     0,     0,     0,    99,
503    101,    78,     0,     0,    92,     0,     0,     0,    37,     0,
504      0,     0,     0,    90,    93,    86,    92,     0,     0,     0,
505     88,     0,    84,     0,   109,     0,     0,     0,     0,     0,
506    108,    94,     0,     0,    92,    85,    92,     0,     0,     0,
507      0,   110,     0,   111,     0,   105,   107,    91,    82,     0,
508      0,    36,   106,   114,   112,   113,   115,    87,    83,     0,
509      0,     0
510 };
511
512 static const short yydefgoto[] = {   240,
513      8,     9,    10,    11,    29,    30,    31,   116,   117,   118,
514     32,    33,    71,    38,    69,   128,    56,    57,    58,    59,
515     82,    86,    87,    88,   134,   121,    34,   179,   194,   129,
516    130,   131,   132,   210,   211,   195
517 };
518
519 static const short yypact[] = {   136,
520    -17,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   136,   167,
521    -16,    13,-32768,   167,   167,   150,    15,   167,    19,-32768,
522 -32768,-32768,    27,   137,    27,    37,-32768,-32768,   170,-32768,
523    107,-32768,-32768,-32768,-32768,    25,    61,    98,   254,-32768,
524 -32768,-32768,-32768,   263,   269,   114,   118,-32768,-32768,-32768,
525 -32768,-32768,-32768,   221,   116,-32768,   104,-32768,   138,    73,
526    151,-32768,-32768,   221,    27,   154,   133,   155,   157,   156,
527    159,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   187,   184,
528    104,-32768,-32768,   146,   212,-32768,   221,-32768,   200,   229,
529    239,    43,    96,    61,-32768,   245,   255,   240,   238,-32768,
530    246,   260,   266,-32768,    -8,-32768,   270,   221,   248,    -8,
531    221,    36,     3,    -1,   238,   251,   272,   256,   273,-32768,
532 -32768,-32768,   221,   257,   238,   258,    57,   276,   259,-32768,
533    253,-32768,-32768,    64,-32768,-32768,   252,   279,   238,   282,
534 -32768,   280,   264,-32768,-32768,   281,   285,-32768,   265,-32768,
535 -32768,-32768,-32768,   267,   284,   268,   221,     5,   291,   204,
536 -32768,   292,   238,   274,   271,   275,-32768,-32768,-32768,-32768,
537    291,-32768,   -10,   291,-32768,   277,   294,    18,    96,-32768,
538 -32768,-32768,   278,   238,   291,   238,    96,   286,-32768,    96,
539    297,    91,   295,   301,-32768,-32768,   291,   283,    96,   287,
540 -32768,   298,-32768,    91,-32768,   288,    -5,    10,   290,    29,
541 -32768,-32768,    18,    96,   291,-32768,   291,   293,    50,     4,
542      4,-32768,     4,-32768,     4,-32768,-32768,-32768,-32768,    96,
543     96,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   323,
544    325,-32768
545 };
546
547 static const short yypgoto[] = {-32768,
548     69,   117,   317,-32768,-32768,   303,   -21,   213,   217,   222,
549 -32768,-32768,-32768,   -19,   242,   -23,   299,-32768,   126,-32768,
550    261,   243,-32768,   -24,-32768,  -174,-32768,  -164,   124,  -113,
551    182,-32768,   180,   139,  -120,  -114
552 };
553
554
555 #define YYLAST          343
556
557
558 static const short yytable[] = {   148,
559     55,   149,    54,    12,   196,    60,   187,    66,   188,   190,
560    101,   156,   201,   144,   145,   203,    17,   144,   145,    16,
561    199,   112,   144,   145,   216,   165,   176,   189,   144,   145,
562     79,   102,   214,   221,   146,    35,   144,   145,    85,   229,
563     90,   114,   147,    67,   177,    91,   147,   205,   223,   183,
564    230,   147,   231,   193,   141,   238,   239,   147,    36,   104,
565    106,   112,   103,   107,   113,   147,    37,   206,   205,   226,
566    198,   142,   200,   207,   208,   209,    61,    13,   135,    68,
567    136,   114,   115,    13,   138,   104,    13,   140,   206,   227,
568    233,    84,   222,   224,   207,   208,   209,   -96,   227,   154,
569    157,    20,    21,    22,   161,   234,   235,   162,   236,   205,
570    237,    39,    40,    41,    42,    43,    70,    44,    45,    46,
571     47,    48,    49,    50,    51,    52,    15,    53,    77,   206,
572     18,   119,    78,   120,    80,   207,   208,   209,     1,    64,
573     65,    39,    40,    41,    42,    43,    81,    44,    45,    46,
574     47,    48,    49,    50,    51,    52,    83,    53,     2,     3,
575      4,     5,     6,     7,   101,    20,    21,    22,    19,    74,
576     76,    89,    92,    93,    20,    21,    22,    97,    20,    21,
577     22,    23,    24,    25,    26,   102,    27,    28,    19,     2,
578      3,     4,     5,     6,     7,    96,    94,    95,    20,    21,
579     22,    23,    24,    25,    26,    98,    62,    28,    39,    40,
580     41,    42,    43,   180,    44,    45,    46,    47,    48,    49,
581     50,    51,    52,    99,    53,    39,    40,    41,    42,    43,
582    105,    44,    45,    46,    47,    48,    49,    50,    51,    52,
583    108,    53,    39,   126,    41,    42,    43,   109,    44,    45,
584     46,    47,    48,    49,    50,    51,   127,   110,    53,    40,
585     41,    42,    43,   123,    44,    45,    46,    47,    48,    49,
586     50,    51,    52,   124,    53,    46,    47,    48,   133,   125,
587     73,    46,    47,    48,   101,   102,    75,   139,   137,   114,
588    112,   163,   155,   152,   158,   153,   160,   164,   -95,   159,
589    166,   168,   167,   169,   170,   171,   173,   172,   174,   178,
590    182,   185,   192,   184,   186,   204,   191,   212,   197,   213,
591    218,   202,   241,   215,   242,    14,   220,   217,   225,   151,
592    232,    63,   150,   111,   143,   122,   228,    72,   175,   181,
593      0,   100,   219
594 };
595
596 static const short yycheck[] = {   114,
597     24,   115,    24,    21,   179,    25,   171,    31,    19,   174,
598     19,   125,   187,    19,    20,   190,     4,    19,    20,    36,
599    185,    19,    19,    20,   199,   139,    22,    38,    19,    20,
600     54,    40,   197,    39,    36,    21,    19,    20,    60,   214,
601     64,    39,    48,    19,    40,    65,    48,    19,    39,   163,
602    215,    48,   217,    36,    19,   230,   231,    48,    40,    84,
603     85,    19,    84,    87,    22,    48,    40,    39,    19,    41,
604    184,    36,   186,    45,    46,    47,    40,     9,   103,    19,
605    105,    39,    40,    15,   108,   110,    18,   111,    39,   210,
606     41,    19,   207,   208,    45,    46,    47,    41,   219,   123,
607     44,    29,    30,    31,    41,   220,   221,    44,   223,    19,
608    225,     5,     6,     7,     8,     9,    19,    11,    12,    13,
609     14,    15,    16,    17,    18,    19,    10,    21,    15,    39,
610     14,    36,    15,    38,    19,    45,    46,    47,     3,    33,
611     34,     5,     6,     7,     8,     9,    43,    11,    12,    13,
612     14,    15,    16,    17,    18,    19,    19,    21,    23,    24,
613     25,    26,    27,    28,    19,    29,    30,    31,    19,    44,
614     45,    21,    19,    41,    29,    30,    31,    19,    29,    30,
615     31,    32,    33,    34,    35,    40,    37,    38,    19,    23,
616     24,    25,    26,    27,    28,    40,    42,    41,    29,    30,
617     31,    32,    33,    34,    35,    19,    37,    38,     5,     6,
618      7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
619     17,    18,    19,    40,    21,     5,     6,     7,     8,     9,
620     19,    11,    12,    13,    14,    15,    16,    17,    18,    19,
621     41,    21,     5,     6,     7,     8,     9,    19,    11,    12,
622     13,    14,    15,    16,    17,    18,    19,    19,    21,     6,
623      7,     8,     9,    19,    11,    12,    13,    14,    15,    16,
624     17,    18,    19,    19,    21,    13,    14,    15,    19,    40,
625     18,    13,    14,    15,    19,    40,    18,    40,    19,    39,
626     19,    40,    36,    38,    19,    23,    44,    19,    41,    41,
627     19,    38,    23,    23,    20,    41,    23,    41,    41,    19,
628     19,    41,    19,    40,    40,    19,    40,    23,    41,    19,
629     23,    36,     0,    41,     0,     9,    39,    41,    39,   117,
630     38,    29,   116,    91,   113,    94,   213,    39,   157,   160,
631     -1,    81,   204
632 };
633 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
634 #line 3 "/usr/lib/bison.simple"
635 /* This file comes from bison-1.28.  */
636
637 /* Skeleton output parser for bison,
638    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
639
640    This program is free software; you can redistribute it and/or modify
641    it under the terms of the GNU General Public License as published by
642    the Free Software Foundation; either version 2, or (at your option)
643    any later version.
644
645    This program is distributed in the hope that it will be useful,
646    but WITHOUT ANY WARRANTY; without even the implied warranty of
647    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
648    GNU General Public License for more details.
649
650    You should have received a copy of the GNU General Public License
651    along with this program; if not, write to the Free Software
652    Foundation, Inc., 59 Temple Place - Suite 330,
653    Boston, MA 02111-1307, USA.  */
654
655 /* As a special exception, when this file is copied by Bison into a
656    Bison output file, you may use that output file without restriction.
657    This special exception was added by the Free Software Foundation
658    in version 1.24 of Bison.  */
659
660 /* This is the parser code that is written into each bison parser
661   when the %semantic_parser declaration is not specified in the grammar.
662   It was written by Richard Stallman by simplifying the hairy parser
663   used when %semantic_parser is specified.  */
664
665 #ifndef YYSTACK_USE_ALLOCA
666 #ifdef alloca
667 #define YYSTACK_USE_ALLOCA
668 #else /* alloca not defined */
669 #ifdef __GNUC__
670 #define YYSTACK_USE_ALLOCA
671 #define alloca __builtin_alloca
672 #else /* not GNU C.  */
673 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
674 #define YYSTACK_USE_ALLOCA
675 #include <alloca.h>
676 #else /* not sparc */
677 /* We think this test detects Watcom and Microsoft C.  */
678 /* This used to test MSDOS, but that is a bad idea
679    since that symbol is in the user namespace.  */
680 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
681 #if 0 /* No need for malloc.h, which pollutes the namespace;
682          instead, just don't use alloca.  */
683 #include <malloc.h>
684 #endif
685 #else /* not MSDOS, or __TURBOC__ */
686 #if defined(_AIX)
687 /* I don't know what this was needed for, but it pollutes the namespace.
688    So I turned it off.   rms, 2 May 1997.  */
689 /* #include <malloc.h>  */
690  #pragma alloca
691 #define YYSTACK_USE_ALLOCA
692 #else /* not MSDOS, or __TURBOC__, or _AIX */
693 #if 0
694 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
695                  and on HPUX 10.  Eventually we can turn this on.  */
696 #define YYSTACK_USE_ALLOCA
697 #define alloca __builtin_alloca
698 #endif /* __hpux */
699 #endif
700 #endif /* not _AIX */
701 #endif /* not MSDOS, or __TURBOC__ */
702 #endif /* not sparc */
703 #endif /* not GNU C */
704 #endif /* alloca not defined */
705 #endif /* YYSTACK_USE_ALLOCA not defined */
706
707 #ifdef YYSTACK_USE_ALLOCA
708 #define YYSTACK_ALLOC alloca
709 #else
710 #define YYSTACK_ALLOC malloc
711 #endif
712
713 /* Note: there must be only one dollar sign in this file.
714    It is replaced by the list of actions, each action
715    as one case of the switch.  */
716
717 #define yyerrok         (yyerrstatus = 0)
718 #define yyclearin       (yychar = YYEMPTY)
719 #define YYEMPTY         -2
720 #define YYEOF           0
721 #define YYACCEPT        goto yyacceptlab
722 #define YYABORT         goto yyabortlab
723 #define YYERROR         goto yyerrlab1
724 /* Like YYERROR except do call yyerror.
725    This remains here temporarily to ease the
726    transition to the new meaning of YYERROR, for GCC.
727    Once GCC version 2 has supplanted version 1, this can go.  */
728 #define YYFAIL          goto yyerrlab
729 #define YYRECOVERING()  (!!yyerrstatus)
730 #define YYBACKUP(token, value) \
731 do                                                              \
732   if (yychar == YYEMPTY && yylen == 1)                          \
733     { yychar = (token), yylval = (value);                       \
734       yychar1 = YYTRANSLATE (yychar);                           \
735       YYPOPSTACK;                                               \
736       goto yybackup;                                            \
737     }                                                           \
738   else                                                          \
739     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
740 while (0)
741
742 #define YYTERROR        1
743 #define YYERRCODE       256
744
745 #ifndef YYPURE
746 #define YYLEX           yylex()
747 #endif
748
749 #ifdef YYPURE
750 #ifdef YYLSP_NEEDED
751 #ifdef YYLEX_PARAM
752 #define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
753 #else
754 #define YYLEX           yylex(&yylval, &yylloc)
755 #endif
756 #else /* not YYLSP_NEEDED */
757 #ifdef YYLEX_PARAM
758 #define YYLEX           yylex(&yylval, YYLEX_PARAM)
759 #else
760 #define YYLEX           yylex(&yylval)
761 #endif
762 #endif /* not YYLSP_NEEDED */
763 #endif
764
765 /* If nonreentrant, generate the variables here */
766
767 #ifndef YYPURE
768
769 int     yychar;                 /*  the lookahead symbol                */
770 YYSTYPE yylval;                 /*  the semantic value of the           */
771                                 /*  lookahead symbol                    */
772
773 #ifdef YYLSP_NEEDED
774 YYLTYPE yylloc;                 /*  location data for the lookahead     */
775                                 /*  symbol                              */
776 #endif
777
778 int yynerrs;                    /*  number of parse errors so far       */
779 #endif  /* not YYPURE */
780
781 #if YYDEBUG != 0
782 int yydebug;                    /*  nonzero means print parse trace     */
783 /* Since this is uninitialized, it does not stop multiple parsers
784    from coexisting.  */
785 #endif
786
787 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
788
789 #ifndef YYINITDEPTH
790 #define YYINITDEPTH 200
791 #endif
792
793 /*  YYMAXDEPTH is the maximum size the stacks can grow to
794     (effective only if the built-in stack extension method is used).  */
795
796 #if YYMAXDEPTH == 0
797 #undef YYMAXDEPTH
798 #endif
799
800 #ifndef YYMAXDEPTH
801 #define YYMAXDEPTH 10000
802 #endif
803 \f
804 /* Define __yy_memcpy.  Note that the size argument
805    should be passed with type unsigned int, because that is what the non-GCC
806    definitions require.  With GCC, __builtin_memcpy takes an arg
807    of type size_t, but it can handle unsigned int.  */
808
809 #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
810 #define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
811 #else                           /* not GNU C or C++ */
812 #ifndef __cplusplus
813
814 /* This is the most reliable way to avoid incompatibilities
815    in available built-in functions on various systems.  */
816 static void
817 __yy_memcpy (to, from, count)
818      char *to;
819      char *from;
820      unsigned int count;
821 {
822   register char *f = from;
823   register char *t = to;
824   register int i = count;
825
826   while (i-- > 0)
827     *t++ = *f++;
828 }
829
830 #else /* __cplusplus */
831
832 /* This is the most reliable way to avoid incompatibilities
833    in available built-in functions on various systems.  */
834 static void
835 __yy_memcpy (char *to, char *from, unsigned int count)
836 {
837   register char *t = to;
838   register char *f = from;
839   register int i = count;
840
841   while (i-- > 0)
842     *t++ = *f++;
843 }
844
845 #endif
846 #endif
847 \f
848 #line 217 "/usr/lib/bison.simple"
849
850 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
851    into yyparse.  The argument should have type void *.
852    It should actually point to an object.
853    Grammar actions can access the variable by casting it
854    to the proper pointer type.  */
855
856 #ifdef YYPARSE_PARAM
857 #ifdef __cplusplus
858 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
859 #define YYPARSE_PARAM_DECL
860 #else /* not __cplusplus */
861 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
862 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
863 #endif /* not __cplusplus */
864 #else /* not YYPARSE_PARAM */
865 #define YYPARSE_PARAM_ARG
866 #define YYPARSE_PARAM_DECL
867 #endif /* not YYPARSE_PARAM */
868
869 /* Prevent warning if -Wstrict-prototypes.  */
870 #ifdef __GNUC__
871 #ifdef YYPARSE_PARAM
872 int yyparse (void *);
873 #else
874 int yyparse (void);
875 #endif
876 #endif
877
878 int
879 yyparse(YYPARSE_PARAM_ARG)
880      YYPARSE_PARAM_DECL
881 {
882   register int yystate;
883   register int yyn;
884   register short *yyssp;
885   register YYSTYPE *yyvsp;
886   int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
887   int yychar1 = 0;              /*  lookahead token as an internal (translated) token number */
888
889   short yyssa[YYINITDEPTH];     /*  the state stack                     */
890   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
891
892   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
893   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
894
895 #ifdef YYLSP_NEEDED
896   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
897   YYLTYPE *yyls = yylsa;
898   YYLTYPE *yylsp;
899
900 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
901 #else
902 #define YYPOPSTACK   (yyvsp--, yyssp--)
903 #endif
904
905   int yystacksize = YYINITDEPTH;
906   int yyfree_stacks = 0;
907
908 #ifdef YYPURE
909   int yychar;
910   YYSTYPE yylval;
911   int yynerrs;
912 #ifdef YYLSP_NEEDED
913   YYLTYPE yylloc;
914 #endif
915 #endif
916
917   YYSTYPE yyval;                /*  the variable used to return         */
918                                 /*  semantic values from the action     */
919                                 /*  routines                            */
920
921   int yylen;
922
923 #if YYDEBUG != 0
924   if (yydebug)
925     fprintf(stderr, "Starting parse\n");
926 #endif
927
928   yystate = 0;
929   yyerrstatus = 0;
930   yynerrs = 0;
931   yychar = YYEMPTY;             /* Cause a token to be read.  */
932
933   /* Initialize stack pointers.
934      Waste one element of value and location stack
935      so that they stay on the same level as the state stack.
936      The wasted elements are never initialized.  */
937
938   yyssp = yyss - 1;
939   yyvsp = yyvs;
940 #ifdef YYLSP_NEEDED
941   yylsp = yyls;
942 #endif
943
944 /* Push a new state, which is found in  yystate  .  */
945 /* In all cases, when you get here, the value and location stacks
946    have just been pushed. so pushing a state here evens the stacks.  */
947 yynewstate:
948
949   *++yyssp = yystate;
950
951   if (yyssp >= yyss + yystacksize - 1)
952     {
953       /* Give user a chance to reallocate the stack */
954       /* Use copies of these so that the &'s don't force the real ones into memory. */
955       YYSTYPE *yyvs1 = yyvs;
956       short *yyss1 = yyss;
957 #ifdef YYLSP_NEEDED
958       YYLTYPE *yyls1 = yyls;
959 #endif
960
961       /* Get the current used size of the three stacks, in elements.  */
962       int size = yyssp - yyss + 1;
963
964 #ifdef yyoverflow
965       /* Each stack pointer address is followed by the size of
966          the data in use in that stack, in bytes.  */
967 #ifdef YYLSP_NEEDED
968       /* This used to be a conditional around just the two extra args,
969          but that might be undefined if yyoverflow is a macro.  */
970       yyoverflow("parser stack overflow",
971                  &yyss1, size * sizeof (*yyssp),
972                  &yyvs1, size * sizeof (*yyvsp),
973                  &yyls1, size * sizeof (*yylsp),
974                  &yystacksize);
975 #else
976       yyoverflow("parser stack overflow",
977                  &yyss1, size * sizeof (*yyssp),
978                  &yyvs1, size * sizeof (*yyvsp),
979                  &yystacksize);
980 #endif
981
982       yyss = yyss1; yyvs = yyvs1;
983 #ifdef YYLSP_NEEDED
984       yyls = yyls1;
985 #endif
986 #else /* no yyoverflow */
987       /* Extend the stack our own way.  */
988       if (yystacksize >= YYMAXDEPTH)
989         {
990           yyerror("parser stack overflow");
991           if (yyfree_stacks)
992             {
993               free (yyss);
994               free (yyvs);
995 #ifdef YYLSP_NEEDED
996               free (yyls);
997 #endif
998             }
999           return 2;
1000         }
1001       yystacksize *= 2;
1002       if (yystacksize > YYMAXDEPTH)
1003         yystacksize = YYMAXDEPTH;
1004 #ifndef YYSTACK_USE_ALLOCA
1005       yyfree_stacks = 1;
1006 #endif
1007       yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
1008       __yy_memcpy ((char *)yyss, (char *)yyss1,
1009                    size * (unsigned int) sizeof (*yyssp));
1010       yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
1011       __yy_memcpy ((char *)yyvs, (char *)yyvs1,
1012                    size * (unsigned int) sizeof (*yyvsp));
1013 #ifdef YYLSP_NEEDED
1014       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
1015       __yy_memcpy ((char *)yyls, (char *)yyls1,
1016                    size * (unsigned int) sizeof (*yylsp));
1017 #endif
1018 #endif /* no yyoverflow */
1019
1020       yyssp = yyss + size - 1;
1021       yyvsp = yyvs + size - 1;
1022 #ifdef YYLSP_NEEDED
1023       yylsp = yyls + size - 1;
1024 #endif
1025
1026 #if YYDEBUG != 0
1027       if (yydebug)
1028         fprintf(stderr, "Stack size increased to %d\n", yystacksize);
1029 #endif
1030
1031       if (yyssp >= yyss + yystacksize - 1)
1032         YYABORT;
1033     }
1034
1035 #if YYDEBUG != 0
1036   if (yydebug)
1037     fprintf(stderr, "Entering state %d\n", yystate);
1038 #endif
1039
1040   goto yybackup;
1041  yybackup:
1042
1043 /* Do appropriate processing given the current state.  */
1044 /* Read a lookahead token if we need one and don't already have one.  */
1045 /* yyresume: */
1046
1047   /* First try to decide what to do without reference to lookahead token.  */
1048
1049   yyn = yypact[yystate];
1050   if (yyn == YYFLAG)
1051     goto yydefault;
1052
1053   /* Not known => get a lookahead token if don't already have one.  */
1054
1055   /* yychar is either YYEMPTY or YYEOF
1056      or a valid token in external form.  */
1057
1058   if (yychar == YYEMPTY)
1059     {
1060 #if YYDEBUG != 0
1061       if (yydebug)
1062         fprintf(stderr, "Reading a token: ");
1063 #endif
1064       yychar = YYLEX;
1065     }
1066
1067   /* Convert token to internal form (in yychar1) for indexing tables with */
1068
1069   if (yychar <= 0)              /* This means end of input. */
1070     {
1071       yychar1 = 0;
1072       yychar = YYEOF;           /* Don't call YYLEX any more */
1073
1074 #if YYDEBUG != 0
1075       if (yydebug)
1076         fprintf(stderr, "Now at end of input.\n");
1077 #endif
1078     }
1079   else
1080     {
1081       yychar1 = YYTRANSLATE(yychar);
1082
1083 #if YYDEBUG != 0
1084       if (yydebug)
1085         {
1086           fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
1087           /* Give the individual parser a way to print the precise meaning
1088              of a token, for further debugging info.  */
1089 #ifdef YYPRINT
1090           YYPRINT (stderr, yychar, yylval);
1091 #endif
1092           fprintf (stderr, ")\n");
1093         }
1094 #endif
1095     }
1096
1097   yyn += yychar1;
1098   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
1099     goto yydefault;
1100
1101   yyn = yytable[yyn];
1102
1103   /* yyn is what to do for this token type in this state.
1104      Negative => reduce, -yyn is rule number.
1105      Positive => shift, yyn is new state.
1106        New state is final state => don't bother to shift,
1107        just return success.
1108      0, or most negative number => error.  */
1109
1110   if (yyn < 0)
1111     {
1112       if (yyn == YYFLAG)
1113         goto yyerrlab;
1114       yyn = -yyn;
1115       goto yyreduce;
1116     }
1117   else if (yyn == 0)
1118     goto yyerrlab;
1119
1120   if (yyn == YYFINAL)
1121     YYACCEPT;
1122
1123   /* Shift the lookahead token.  */
1124
1125 #if YYDEBUG != 0
1126   if (yydebug)
1127     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
1128 #endif
1129
1130   /* Discard the token being shifted unless it is eof.  */
1131   if (yychar != YYEOF)
1132     yychar = YYEMPTY;
1133
1134   *++yyvsp = yylval;
1135 #ifdef YYLSP_NEEDED
1136   *++yylsp = yylloc;
1137 #endif
1138
1139   /* count tokens shifted since error; after three, turn off error status.  */
1140   if (yyerrstatus) yyerrstatus--;
1141
1142   yystate = yyn;
1143   goto yynewstate;
1144
1145 /* Do the default action for the current state.  */
1146 yydefault:
1147
1148   yyn = yydefact[yystate];
1149   if (yyn == 0)
1150     goto yyerrlab;
1151
1152 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
1153 yyreduce:
1154   yylen = yyr2[yyn];
1155   if (yylen > 0)
1156     yyval = yyvsp[1-yylen]; /* implement default value of the action */
1157
1158 #if YYDEBUG != 0
1159   if (yydebug)
1160     {
1161       int i;
1162
1163       fprintf (stderr, "Reducing via rule %d (line %d), ",
1164                yyn, yyrline[yyn]);
1165
1166       /* Print the symbols being reduced, and their result.  */
1167       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
1168         fprintf (stderr, "%s ", yytname[yyrhs[i]]);
1169       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1170     }
1171 #endif
1172
1173
1174   switch (yyn) {
1175
1176 case 1:
1177 #line 295 "parse.y"
1178 { ; ;
1179     break;}
1180 case 2:
1181 #line 296 "parse.y"
1182 { ; ;
1183     break;}
1184 case 3:
1185 #line 297 "parse.y"
1186 { ; ;
1187     break;}
1188 case 4:
1189 #line 298 "parse.y"
1190 { ; ;
1191     break;}
1192 case 5:
1193 #line 301 "parse.y"
1194 {
1195                         Node *node = new_ccode(C_CCODE,(yyvsp[0].cbuf)->str,
1196                                                ccode_line);
1197                         nodes = g_list_append(nodes,node);
1198                         g_string_free(yyvsp[0].cbuf,FALSE);
1199                                         ;
1200     break;}
1201 case 6:
1202 #line 307 "parse.y"
1203 {
1204                         Node *node = new_ccode(H_CCODE,(yyvsp[0].cbuf)->str,
1205                                                ccode_line);
1206                         nodes = g_list_append(nodes,node);
1207                         g_string_free(yyvsp[0].cbuf,FALSE);
1208                                         ;
1209     break;}
1210 case 7:
1211 #line 313 "parse.y"
1212 {
1213                         Node *node = new_ccode(HT_CCODE,(yyvsp[0].cbuf)->str,
1214                                                ccode_line);
1215                         nodes = g_list_append(nodes,node);
1216                         g_string_free(yyvsp[0].cbuf,FALSE);
1217                                         ;
1218     break;}
1219 case 8:
1220 #line 319 "parse.y"
1221 {
1222                         Node *node = new_ccode(PH_CCODE,(yyvsp[0].cbuf)->str,
1223                                                ccode_line);
1224                         nodes = g_list_append(nodes,node);
1225                         g_string_free(yyvsp[0].cbuf,FALSE);
1226                                         ;
1227     break;}
1228 case 9:
1229 #line 325 "parse.y"
1230 {
1231                         Node *node = new_ccode(A_CCODE,(yyvsp[0].cbuf)->str,
1232                                                ccode_line);
1233                         nodes = g_list_append(nodes,node);
1234                         g_string_free(yyvsp[0].cbuf,FALSE);
1235                                         ;
1236     break;}
1237 case 10:
1238 #line 331 "parse.y"
1239 {
1240                         Node *node = new_ccode(AT_CCODE,(yyvsp[0].cbuf)->str,
1241                                                ccode_line);
1242                         nodes = g_list_append(nodes,node);
1243                         g_string_free(yyvsp[0].cbuf,FALSE);
1244                                         ;
1245     break;}
1246 case 11:
1247 #line 339 "parse.y"
1248 { ; ;
1249     break;}
1250 case 12:
1251 #line 340 "parse.y"
1252 { ; ;
1253     break;}
1254 case 13:
1255 #line 343 "parse.y"
1256 {
1257                         ((Class *)class)->nodes = class_nodes;
1258                         class_nodes = NULL;
1259                         nodes = g_list_append(nodes,class);
1260                                                 ;
1261     break;}
1262 case 14:
1263 #line 348 "parse.y"
1264 {
1265                         ((Class *)class)->nodes = NULL;
1266                         class_nodes = NULL;
1267                         nodes = g_list_append(nodes,class);
1268                                                 ;
1269     break;}
1270 case 15:
1271 #line 355 "parse.y"
1272 {
1273                         class = new_class(yyvsp[-2].id,yyvsp[0].id,NULL);
1274                                                 ;
1275     break;}
1276 case 16:
1277 #line 360 "parse.y"
1278 { ; ;
1279     break;}
1280 case 17:
1281 #line 361 "parse.y"
1282 { ; ;
1283     break;}
1284 case 18:
1285 #line 364 "parse.y"
1286 { ; ;
1287     break;}
1288 case 19:
1289 #line 365 "parse.y"
1290 { ; ;
1291     break;}
1292 case 20:
1293 #line 366 "parse.y"
1294 { ; ;
1295     break;}
1296 case 21:
1297 #line 367 "parse.y"
1298 { ; ;
1299     break;}
1300 case 22:
1301 #line 370 "parse.y"
1302 { the_scope = PUBLIC_SCOPE; ;
1303     break;}
1304 case 23:
1305 #line 371 "parse.y"
1306 { the_scope = PRIVATE_SCOPE; ;
1307     break;}
1308 case 24:
1309 #line 372 "parse.y"
1310 { the_scope = PROTECTED_SCOPE; ;
1311     break;}
1312 case 25:
1313 #line 375 "parse.y"
1314 {
1315                         if(strcmp(yyvsp[-1].id, "destroywith")==0) {
1316                                 g_free(yyvsp[-1].id);
1317                                 destructor = yyvsp[0].id;
1318                                 destructor_line = line_no;
1319                                 destructor_simple = TRUE;
1320                         } else {
1321                                 g_free(yyvsp[-1].id);
1322                                 g_free(yyvsp[0].id);
1323                                 yyerror(_("parse error"));
1324                                 YYERROR;
1325                         }
1326                                 ;
1327     break;}
1328 case 26:
1329 #line 388 "parse.y"
1330 {
1331                         if(strcmp(yyvsp[-2].id, "destroy")==0) {
1332                                 g_free(yyvsp[-2].id);
1333                                 destructor = (yyvsp[0].cbuf)->str;
1334                                 g_string_free(yyvsp[0].cbuf, FALSE);
1335                                 destructor_line = ccode_line;
1336                                 destructor_simple = FALSE;
1337                         } else {
1338                                 g_free(yyvsp[-2].id);
1339                                 g_string_free(yyvsp[0].cbuf, TRUE);
1340                                 yyerror(_("parse error"));
1341                                 YYERROR;
1342                         }
1343                                         ;
1344     break;}
1345 case 27:
1346 #line 404 "parse.y"
1347 {
1348                         initializer = yyvsp[0].id;
1349                         initializer_line = ccode_line;
1350                                 ;
1351     break;}
1352 case 28:
1353 #line 408 "parse.y"
1354 {
1355                         initializer = (yyvsp[0].cbuf)->str;
1356                         initializer_line = ccode_line;
1357                         g_string_free(yyvsp[0].cbuf, FALSE);
1358                                 ;
1359     break;}
1360 case 29:
1361 #line 416 "parse.y"
1362 { ; ;
1363     break;}
1364 case 30:
1365 #line 417 "parse.y"
1366 { ; ;
1367     break;}
1368 case 31:
1369 #line 418 "parse.y"
1370 { destructor = NULL; ;
1371     break;}
1372 case 32:
1373 #line 419 "parse.y"
1374 { initializer = NULL; ;
1375     break;}
1376 case 33:
1377 #line 420 "parse.y"
1378 {
1379                         destructor = NULL;
1380                         initializer = NULL;
1381                                         ;
1382     break;}
1383 case 34:
1384 #line 426 "parse.y"
1385 {
1386                         push_variable(yyvsp[-2].id, the_scope,yyvsp[-4].line, NULL);
1387                                                 ;
1388     break;}
1389 case 35:
1390 #line 429 "parse.y"
1391 {
1392                         push_variable(yyvsp[-3].id, the_scope, yyvsp[-5].line, yyvsp[-2].id);
1393                                                 ;
1394     break;}
1395 case 36:
1396 #line 433 "parse.y"
1397 {
1398                         if(strcmp(yyvsp[-6].id,"get")==0 &&
1399                            strcmp(yyvsp[-3].id,"set")==0) {
1400                                 Node *node;
1401                                 Type *type = pop_type();
1402                                 g_free(yyvsp[-6].id); g_free(yyvsp[-3].id);
1403                                 node = new_argument(yyvsp[-8].id,type,yyvsp[-9].list,yyvsp[-7].id,
1404                                                     (yyvsp[-4].cbuf)->str,yyvsp[-5].line,
1405                                                     (yyvsp[-1].cbuf)->str,yyvsp[-2].line,
1406                                                     yyvsp[-10].line);
1407                                 g_string_free(yyvsp[-4].cbuf,FALSE);
1408                                 g_string_free(yyvsp[-1].cbuf,FALSE);
1409                                 class_nodes = g_list_append(class_nodes,node);
1410                         } else if(strcmp(yyvsp[-6].id,"set")==0 &&
1411                                 strcmp(yyvsp[-3].id,"get")==0) {
1412                                 Node *node;
1413                                 Type *type = pop_type();
1414                                 g_free(yyvsp[-6].id); g_free(yyvsp[-3].id);
1415                                 node = new_argument(yyvsp[-8].id,type,yyvsp[-9].list,yyvsp[-7].id,
1416                                                     (yyvsp[-1].cbuf)->str,yyvsp[-2].line,
1417                                                     (yyvsp[-4].cbuf)->str,yyvsp[-5].line,
1418                                                     yyvsp[-10].line);
1419                                 g_string_free(yyvsp[-1].cbuf,FALSE);
1420                                 g_string_free(yyvsp[-4].cbuf,FALSE);
1421                                 class_nodes = g_list_append(class_nodes,node);
1422                         } else {
1423                                 g_free(yyvsp[-8].id); g_free(yyvsp[-7].id);
1424                                 g_free(yyvsp[-6].id); g_free(yyvsp[-3].id);
1425                                 g_list_foreach(yyvsp[-9].list,(GFunc)g_free,NULL);
1426                                 g_string_free(yyvsp[-1].cbuf,TRUE);
1427                                 g_string_free(yyvsp[-4].cbuf,TRUE);
1428                                 yyerror(_("parse error"));
1429                                 YYERROR;
1430                         }
1431                                                 ;
1432     break;}
1433 case 37:
1434 #line 468 "parse.y"
1435 {
1436                         if(strcmp(yyvsp[-3].id,"get")==0) {
1437                                 Node *node;
1438                                 Type *type = pop_type();
1439                                 g_free(yyvsp[-3].id);
1440                                 node = new_argument(yyvsp[-5].id,type,yyvsp[-6].list,yyvsp[-4].id,
1441                                                     (yyvsp[-1].cbuf)->str,yyvsp[-2].line,
1442                                                     NULL,0, yyvsp[-7].line);
1443                                 g_string_free(yyvsp[-1].cbuf,FALSE);
1444                                 class_nodes = g_list_append(class_nodes,node);
1445                         } else if(strcmp(yyvsp[-3].id,"set")==0) {
1446                                 Node *node;
1447                                 Type *type = pop_type();
1448                                 g_free(yyvsp[-3].id);
1449                                 node = new_argument(yyvsp[-5].id,type,yyvsp[-6].list,yyvsp[-4].id,
1450                                                     NULL,0,(yyvsp[-1].cbuf)->str,
1451                                                     yyvsp[-2].line, yyvsp[-7].line);
1452                                 g_string_free(yyvsp[-1].cbuf,FALSE);
1453                                 class_nodes = g_list_append(class_nodes,node);
1454                         } else {
1455                                 g_free(yyvsp[-3].id); g_free(yyvsp[-5].id);
1456                                 g_free(yyvsp[-4].id);
1457                                 g_list_foreach(yyvsp[-6].list,(GFunc)g_free,NULL);
1458                                 g_string_free(yyvsp[-1].cbuf,TRUE);
1459                                 yyerror(_("parse error"));
1460                                 YYERROR;
1461                         }
1462                                                 ;
1463     break;}
1464 case 38:
1465 #line 496 "parse.y"
1466 {
1467                         Node *node;
1468                         char *get, *set = NULL;
1469                         Variable *var;
1470                         Type *type;
1471                         char *root;
1472                         
1473                         if(strcmp(yyvsp[0].id,"link")!=0 &&
1474                            strcmp(yyvsp[0].id,"stringlink")!=0 &&
1475                            strcmp(yyvsp[0].id,"objectlink")!=0) {
1476                                 g_free(yyvsp[0].id); g_free(yyvsp[-2].id);
1477                                 g_free(yyvsp[-1].id);
1478                                 g_list_foreach(yyvsp[-3].list,(GFunc)g_free,NULL);
1479                                 yyerror(_("parse error"));
1480                                 YYERROR;
1481                         }
1482
1483                         type = pop_type();
1484
1485                         var = find_var_or_die(yyvsp[-1].id, yyvsp[-4].line);
1486                         if(var->scope == PRIVATE_SCOPE)
1487                                 root = "self->_priv";
1488                         else
1489                                 root = "self";
1490
1491                         if(strcmp(yyvsp[0].id,"link")==0) {
1492                                 set = g_strdup_printf("%s->%s = ARG;",
1493                                                       root, yyvsp[-1].id);
1494                         } else if(strcmp(yyvsp[0].id,"stringlink")==0) {
1495                                 set = g_strdup_printf("g_free(%s->%s); "
1496                                                       "%s->%s = g_strdup(ARG);",
1497                                                       root, yyvsp[-1].id,
1498                                                       root, yyvsp[-1].id);
1499                         } else if(strcmp(yyvsp[0].id,"objectlink")==0) {
1500                                 set = g_strdup_printf(
1501                                   "if(%s->%s) "
1502                                    "gtk_object_unref(GTK_OBJECT(%s->%s)); "
1503                                   "%s->%s = ARG; "
1504                                   "if(%s->%s) "
1505                                    "gtk_object_ref(GTK_OBJECT(%s->%s)); ",
1506                                   root, yyvsp[-1].id,
1507                                   root, yyvsp[-1].id,
1508                                   root, yyvsp[-1].id,
1509                                   root, yyvsp[-1].id,
1510                                   root, yyvsp[-1].id);
1511                         } else {
1512                                 g_assert_not_reached();
1513                         }
1514
1515                         /* get is the same for everything */
1516                         get = g_strdup_printf("ARG = %s->%s;", root, yyvsp[-1].id);
1517
1518                         g_free(yyvsp[0].id);
1519
1520
1521                         if(!type)
1522                                 type = copy_type(var->vtype);
1523
1524                         node = new_argument(yyvsp[-2].id, type, yyvsp[-3].list,
1525                                             yyvsp[-1].id, get, yyvsp[-4].line,
1526                                             set, yyvsp[-4].line, yyvsp[-4].line);
1527                         class_nodes = g_list_append(class_nodes,node);
1528                                                 ;
1529     break;}
1530 case 39:
1531 #line 561 "parse.y"
1532 {
1533                         if(strcmp(yyvsp[-2].id,"type")!=0) {
1534                                 g_free(yyvsp[-4].id);
1535                                 g_free(yyvsp[-2].id);
1536                                 yyerror(_("parse error"));
1537                                 YYERROR;
1538                         }
1539                         yyval.id = yyvsp[-4].id;
1540                                                 ;
1541     break;}
1542 case 40:
1543 #line 570 "parse.y"
1544 {
1545                         yyval.id = yyvsp[0].id;
1546                         typestack = g_list_prepend(typestack,NULL);
1547                                                 ;
1548     break;}
1549 case 41:
1550 #line 576 "parse.y"
1551 { yyval.list = yyvsp[-1].list; ;
1552     break;}
1553 case 42:
1554 #line 577 "parse.y"
1555 { yyval.list = NULL; ;
1556     break;}
1557 case 43:
1558 #line 580 "parse.y"
1559 {
1560                         yyval.list = g_list_append(yyvsp[0].list,yyvsp[-2].id);
1561                                                 ;
1562     break;}
1563 case 44:
1564 #line 583 "parse.y"
1565 {
1566                         yyval.list = g_list_append(NULL,yyvsp[0].id);
1567                                                 ;
1568     break;}
1569 case 45:
1570 #line 589 "parse.y"
1571 { ; ;
1572     break;}
1573 case 46:
1574 #line 590 "parse.y"
1575 {
1576                         Type *type = typestack->data;
1577                         char *oldname = type->name;
1578                         type->name = g_strconcat("const ",oldname,NULL);
1579                         g_free(oldname);
1580                                                 ;
1581     break;}
1582 case 47:
1583 #line 598 "parse.y"
1584 {
1585                         Node *node = new_type(0,yyvsp[0].id,NULL);
1586                         typestack = g_list_prepend(typestack,node);
1587                                                 ;
1588     break;}
1589 case 48:
1590 #line 602 "parse.y"
1591 {
1592                         Node *node = new_type(stars,yyvsp[-1].id,NULL);
1593                         stars = 0;
1594                         typestack = g_list_prepend(typestack,node);
1595                                                 ;
1596     break;}
1597 case 49:
1598 #line 609 "parse.y"
1599 {
1600                         yyval.id = g_strconcat("unsigned ",yyvsp[0].id,NULL);
1601                                                 ;
1602     break;}
1603 case 50:
1604 #line 612 "parse.y"
1605 {
1606                         yyval.id = g_strconcat("signed ",yyvsp[0].id,NULL);
1607                                                 ;
1608     break;}
1609 case 51:
1610 #line 615 "parse.y"
1611 {
1612                         yyval.id = g_strdup(yyvsp[0].id);
1613                                                 ;
1614     break;}
1615 case 52:
1616 #line 618 "parse.y"
1617 {
1618                         yyval.id = g_strdup("unsigned char");
1619                                                 ;
1620     break;}
1621 case 53:
1622 #line 621 "parse.y"
1623 {
1624                         yyval.id = g_strdup("signed char");
1625                                                 ;
1626     break;}
1627 case 54:
1628 #line 624 "parse.y"
1629 {
1630                         yyval.id = g_strdup("char");
1631                                                 ;
1632     break;}
1633 case 55:
1634 #line 627 "parse.y"
1635 {
1636                         yyval.id = g_strdup("double");
1637                                                 ;
1638     break;}
1639 case 56:
1640 #line 630 "parse.y"
1641 {
1642                         yyval.id = g_strdup("float");
1643                                                 ;
1644     break;}
1645 case 57:
1646 #line 633 "parse.y"
1647 {
1648                         yyval.id = yyvsp[0].id;
1649                                                 ;
1650     break;}
1651 case 58:
1652 #line 636 "parse.y"
1653 {
1654                         yyval.id = g_strconcat(yyvsp[-1].id,yyvsp[0].id,NULL);
1655                         g_free(yyvsp[0].id);
1656                                                 ;
1657     break;}
1658 case 59:
1659 #line 640 "parse.y"
1660 {
1661                         yyval.id = yyvsp[0].id;
1662                                                 ;
1663     break;}
1664 case 60:
1665 #line 643 "parse.y"
1666 {
1667                         yyval.id = g_strdup("void");
1668                                                 ;
1669     break;}
1670 case 61:
1671 #line 648 "parse.y"
1672 {
1673                         yyval.id = "long int";
1674                                                 ;
1675     break;}
1676 case 62:
1677 #line 651 "parse.y"
1678 {
1679                         yyval.id = "long";
1680                                                 ;
1681     break;}
1682 case 63:
1683 #line 654 "parse.y"
1684 {
1685                         yyval.id = "short int";
1686                                                 ;
1687     break;}
1688 case 64:
1689 #line 657 "parse.y"
1690 {
1691                         yyval.id = "short";
1692                                                 ;
1693     break;}
1694 case 65:
1695 #line 660 "parse.y"
1696 {
1697                         yyval.id = "int";
1698                                                 ;
1699     break;}
1700 case 66:
1701 #line 665 "parse.y"
1702 {
1703                         yyval.id = "enum ";
1704                                                 ;
1705     break;}
1706 case 67:
1707 #line 668 "parse.y"
1708 {
1709                         yyval.id = "union ";
1710                                                 ;
1711     break;}
1712 case 68:
1713 #line 671 "parse.y"
1714 {
1715                         yyval.id = "struct ";
1716                                                 ;
1717     break;}
1718 case 69:
1719 #line 676 "parse.y"
1720 { stars++; ;
1721     break;}
1722 case 70:
1723 #line 677 "parse.y"
1724 { stars++; ;
1725     break;}
1726 case 71:
1727 #line 681 "parse.y"
1728 {
1729                         if(strcmp(yyvsp[-1].id, "first")==0)
1730                                 yyval.sigtype = SIGNAL_FIRST_METHOD;
1731                         else if(strcmp(yyvsp[-1].id, "last")==0)
1732                                 yyval.sigtype = SIGNAL_LAST_METHOD;
1733                         else {
1734                                 yyerror(_("signal must be 'first' or 'last'"));
1735                                 g_free(yyvsp[-1].id);
1736                                 YYERROR;
1737                         }
1738                         g_free(yyvsp[-1].id);
1739                                         ;
1740     break;}
1741 case 72:
1742 #line 693 "parse.y"
1743 {
1744                         yyval.sigtype = SIGNAL_LAST_METHOD;
1745                                         ;
1746     break;}
1747 case 73:
1748 #line 699 "parse.y"
1749 {
1750                         if(strcmp(yyvsp[-1].id,"first")==0)
1751                                 yyval.sigtype = SIGNAL_FIRST_METHOD;
1752                         else if(strcmp(yyvsp[-1].id,"last")==0)
1753                                 yyval.sigtype = SIGNAL_LAST_METHOD;
1754                         else {
1755                                 yyerror(_("signal must be 'first' or 'last'"));
1756                                 g_free(yyvsp[-1].id);
1757                                 YYERROR;
1758                         }
1759                         g_free(yyvsp[-1].id);
1760                                         ;
1761     break;}
1762 case 74:
1763 #line 711 "parse.y"
1764 {
1765                         if(strcmp(yyvsp[-2].id,"first")==0)
1766                                 yyval.sigtype = SIGNAL_FIRST_METHOD;
1767                         else if(strcmp(yyvsp[-2].id,"last")==0)
1768                                 yyval.sigtype = SIGNAL_LAST_METHOD;
1769                         else {
1770                                 yyerror(_("signal must be 'first' or 'last'"));
1771                                 g_free(yyvsp[-2].id);
1772                                 YYERROR;
1773                         }
1774                         g_free(yyvsp[-2].id);
1775                                         ;
1776     break;}
1777 case 75:
1778 #line 723 "parse.y"
1779 {
1780                         yyval.sigtype = SIGNAL_LAST_METHOD;
1781                                         ;
1782     break;}
1783 case 76:
1784 #line 726 "parse.y"
1785 {
1786                         /* the_scope was default thus public */
1787                         the_scope = PUBLIC_SCOPE;
1788                                         ;
1789     break;}
1790 case 77:
1791 #line 732 "parse.y"
1792 {
1793                         gtktypes = g_list_prepend(gtktypes, yyvsp[-3].id);
1794                                                 ;
1795     break;}
1796 case 78:
1797 #line 737 "parse.y"
1798 {
1799                         gtktypes = g_list_append(gtktypes, yyvsp[0].id);
1800                                                 ;
1801     break;}
1802 case 79:
1803 #line 740 "parse.y"
1804
1805                         gtktypes = g_list_append(gtktypes, yyvsp[0].id);
1806                                                 ;
1807     break;}
1808 case 80:
1809 #line 745 "parse.y"
1810 { yyval.cbuf = yyvsp[0].cbuf; ;
1811     break;}
1812 case 81:
1813 #line 746 "parse.y"
1814 { yyval.cbuf = NULL; ;
1815     break;}
1816 case 82:
1817 #line 750 "parse.y"
1818 {
1819                         if(!has_self) {
1820                                 yyerror(_("signal without 'self' as "
1821                                           "first parameter"));
1822                                 free_all_global_state();
1823                                 YYERROR;
1824                         }
1825                         push_function(the_scope, yyvsp[-7].sigtype,NULL,
1826                                       yyvsp[-5].id, yyvsp[0].cbuf,yyvsp[-9].line,
1827                                       ccode_line, vararg, yyvsp[-8].list);
1828                                                                         ;
1829     break;}
1830 case 83:
1831 #line 761 "parse.y"
1832 {
1833                         if(!has_self) {
1834                                 yyerror(_("signal without 'self' as "
1835                                           "first parameter"));
1836                                 free_all_global_state();
1837                                 YYERROR;
1838                         }
1839                         push_function(the_scope, yyvsp[-7].sigtype, NULL,
1840                                       yyvsp[-5].id, yyvsp[0].cbuf, yyvsp[-9].line,
1841                                       ccode_line, vararg, yyvsp[-8].list);
1842                                                                         ;
1843     break;}
1844 case 84:
1845 #line 772 "parse.y"
1846 {
1847                         if(!has_self) {
1848                                 yyerror(_("virtual method without 'self' as "
1849                                           "first parameter"));
1850                                 free_all_global_state();
1851                                 YYERROR;
1852                         }
1853                         push_function(the_scope, VIRTUAL_METHOD, NULL, yyvsp[-5].id,
1854                                       yyvsp[0].cbuf, yyvsp[-8].line,
1855                                       ccode_line, vararg, NULL);
1856                                                                         ;
1857     break;}
1858 case 85:
1859 #line 783 "parse.y"
1860 {
1861                         if(!has_self) {
1862                                 yyerror(_("virtual method without 'self' as "
1863                                           "first parameter"));
1864                                 free_all_global_state();
1865                                 YYERROR;
1866                         }
1867                         push_function(the_scope, VIRTUAL_METHOD, NULL, yyvsp[-5].id,
1868                                       yyvsp[0].cbuf, yyvsp[-7].line,
1869                                       ccode_line, vararg, NULL);
1870                                                                         ;
1871     break;}
1872 case 86:
1873 #line 794 "parse.y"
1874 {
1875                         if(!has_self) {
1876                                 yyerror(_("virtual method without 'self' as "
1877                                           "first parameter"));
1878                                 free_all_global_state();
1879                                 YYERROR;
1880                         }
1881                         push_function(PUBLIC_SCOPE, VIRTUAL_METHOD, NULL,
1882                                       yyvsp[-5].id, yyvsp[0].cbuf, yyvsp[-7].line,
1883                                       ccode_line, vararg, NULL);
1884                                                                         ;
1885     break;}
1886 case 87:
1887 #line 805 "parse.y"
1888 {
1889                         push_function(NO_SCOPE, OVERRIDE_METHOD, yyvsp[-8].id,
1890                                       yyvsp[-5].id, yyvsp[0].cbuf,
1891                                       yyvsp[-10].line, ccode_line,
1892                                       vararg, NULL);
1893                                                                         ;
1894     break;}
1895 case 88:
1896 #line 811 "parse.y"
1897 {
1898                         push_function(the_scope, REGULAR_METHOD, NULL, yyvsp[-5].id,
1899                                       yyvsp[0].cbuf, yyvsp[-7].line, ccode_line,
1900                                       vararg, NULL);
1901                                                                 ;
1902     break;}
1903 case 89:
1904 #line 816 "parse.y"
1905 {
1906                         if(strcmp(yyvsp[-4].id, "init")==0) {
1907                                 push_init_arg(yyvsp[-2].id,FALSE);
1908                                 push_function(NO_SCOPE, INIT_METHOD, NULL,
1909                                               yyvsp[-4].id, yyvsp[0].cbuf, yyvsp[-3].line,
1910                                               ccode_line, FALSE, NULL);
1911                         } else if(strcmp(yyvsp[-4].id, "class_init")==0) {
1912                                 push_init_arg(yyvsp[-2].id,TRUE);
1913                                 push_function(NO_SCOPE, CLASS_INIT_METHOD, NULL,
1914                                               yyvsp[-4].id, yyvsp[0].cbuf, yyvsp[-3].line,
1915                                               ccode_line, FALSE, NULL);
1916                         } else {
1917                                 g_free(yyvsp[-4].id);
1918                                 g_free(yyvsp[-2].id);
1919                                 g_string_free(yyvsp[-2].cbuf,TRUE);
1920                                 yyerror(_("parse error"));
1921                                 YYERROR;
1922                         }
1923                                                 ;
1924     break;}
1925 case 90:
1926 #line 837 "parse.y"
1927 {
1928                         g_free(onerror); onerror = NULL;
1929                         g_free(defreturn); defreturn = NULL;
1930                         if(!set_return_value(yyvsp[-1].id, yyvsp[0].id)) {
1931                                 g_free(yyvsp[-1].id);
1932                                 g_free(yyvsp[0].id);
1933                                 yyerror(_("parse error"));
1934                                 YYERROR;
1935                         }
1936                         g_free(yyvsp[-1].id);
1937                                         ;
1938     break;}
1939 case 91:
1940 #line 848 "parse.y"
1941 {
1942                         g_free(onerror); onerror = NULL;
1943                         g_free(defreturn); defreturn = NULL;
1944                         if(!set_return_value(yyvsp[-3].id, yyvsp[-2].id)) {
1945                                 g_free(yyvsp[-3].id); g_free(yyvsp[-2].id);
1946                                 g_free(yyvsp[-1].id); g_free(yyvsp[0].id);
1947                                 yyerror(_("parse error"));
1948                                 YYERROR;
1949                         }
1950                         if(!set_return_value(yyvsp[-1].id, yyvsp[0].id)) {
1951                                 onerror = defreturn = NULL;
1952                                 g_free(yyvsp[-3].id); g_free(yyvsp[-2].id);
1953                                 g_free(yyvsp[-1].id); g_free(yyvsp[0].id);
1954                                 yyerror(_("parse error"));
1955                                 YYERROR;
1956                         }
1957                         g_free(yyvsp[-3].id);
1958                         g_free(yyvsp[-1].id);
1959                                                 ;
1960     break;}
1961 case 92:
1962 #line 867 "parse.y"
1963 {
1964                         g_free(onerror); onerror = NULL;
1965                         g_free(defreturn); defreturn = NULL;
1966                                         ;
1967     break;}
1968 case 93:
1969 #line 873 "parse.y"
1970 { yyval.id = yyvsp[0].id; ;
1971     break;}
1972 case 94:
1973 #line 874 "parse.y"
1974 {
1975                         yyval.id = (yyvsp[1].cbuf)->str;
1976                         g_string_free(yyvsp[1].cbuf, FALSE);
1977                                         ;
1978     break;}
1979 case 95:
1980 #line 880 "parse.y"
1981 { vararg = FALSE; has_self = FALSE; ;
1982     break;}
1983 case 96:
1984 #line 881 "parse.y"
1985 {
1986                         vararg = FALSE;
1987                         has_self = TRUE;
1988                         if(strcmp(yyvsp[0].id,"self")==0)
1989                                 push_self(yyvsp[0].id);
1990                         else {
1991                                 g_free(yyvsp[0].id);
1992                                 yyerror(_("parse error"));
1993                                 YYERROR;
1994                         }
1995                                         ;
1996     break;}
1997 case 97:
1998 #line 892 "parse.y"
1999 {
2000                         has_self = TRUE;
2001                         if(strcmp(yyvsp[-2].id,"self")==0)
2002                                 push_self(yyvsp[-2].id);
2003                         else {
2004                                 g_free(yyvsp[-2].id);
2005                                 yyerror(_("parse error"));
2006                                 YYERROR;
2007                         }
2008                                         ;
2009     break;}
2010 case 98:
2011 #line 902 "parse.y"
2012 { has_self = FALSE; ;
2013     break;}
2014 case 99:
2015 #line 905 "parse.y"
2016 { vararg = TRUE; ;
2017     break;}
2018 case 100:
2019 #line 906 "parse.y"
2020 { vararg = FALSE; ;
2021     break;}
2022 case 101:
2023 #line 909 "parse.y"
2024 { ; ;
2025     break;}
2026 case 102:
2027 #line 910 "parse.y"
2028 { ; ;
2029     break;}
2030 case 103:
2031 #line 913 "parse.y"
2032 {
2033                         push_funcarg(yyvsp[0].id,NULL);
2034                                                                 ;
2035     break;}
2036 case 104:
2037 #line 916 "parse.y"
2038 {
2039                         push_funcarg(yyvsp[-1].id,yyvsp[0].id);
2040                                                                 ;
2041     break;}
2042 case 105:
2043 #line 919 "parse.y"
2044 {
2045                         if(strcmp(yyvsp[-2].id,"check")!=0) {
2046                                 yyerror(_("parse error"));
2047                                 YYERROR;
2048                         }
2049                         g_free(yyvsp[-2].id);
2050                         push_funcarg(yyvsp[-4].id,NULL);
2051                                                                 ;
2052     break;}
2053 case 106:
2054 #line 927 "parse.y"
2055 {
2056                         if(strcmp(yyvsp[-2].id,"check")!=0) {
2057                                 yyerror(_("parse error"));
2058                                 YYERROR;
2059                         }
2060                         g_free(yyvsp[-2].id);
2061                         push_funcarg(yyvsp[-5].id,yyvsp[-4].id);
2062                                                                 ;
2063     break;}
2064 case 107:
2065 #line 937 "parse.y"
2066 { ; ;
2067     break;}
2068 case 108:
2069 #line 938 "parse.y"
2070 { ; ;
2071     break;}
2072 case 109:
2073 #line 941 "parse.y"
2074 {
2075                         if(strcmp(yyvsp[0].id,"type")==0) {
2076                                 Node *node = new_check(TYPE_CHECK,NULL);
2077                                 checks = g_list_append(checks,node);
2078                         } else if(strcmp(yyvsp[0].id,"null")==0) {
2079                                 Node *node = new_check(NULL_CHECK,NULL);
2080                                 checks = g_list_append(checks,node);
2081                         } else {
2082                                 yyerror(_("parse error"));
2083                                 YYERROR;
2084                         }
2085                         g_free(yyvsp[0].id);
2086                                         ;
2087     break;}
2088 case 110:
2089 #line 954 "parse.y"
2090 {
2091                         Node *node = new_check(GT_CHECK,yyvsp[0].id);
2092                         checks = g_list_append(checks,node);
2093                                         ;
2094     break;}
2095 case 111:
2096 #line 958 "parse.y"
2097 {
2098                         Node *node = new_check(LT_CHECK,yyvsp[0].id);
2099                         checks = g_list_append(checks,node);
2100                                         ;
2101     break;}
2102 case 112:
2103 #line 962 "parse.y"
2104 {
2105                         Node *node = new_check(GE_CHECK,yyvsp[0].id);
2106                         checks = g_list_append(checks,node);
2107                                         ;
2108     break;}
2109 case 113:
2110 #line 966 "parse.y"
2111 {
2112                         Node *node = new_check(LE_CHECK,yyvsp[0].id);
2113                         checks = g_list_append(checks,node);
2114                                         ;
2115     break;}
2116 case 114:
2117 #line 970 "parse.y"
2118 {
2119                         Node *node = new_check(EQ_CHECK,yyvsp[0].id);
2120                         checks = g_list_append(checks,node);
2121                                         ;
2122     break;}
2123 case 115:
2124 #line 974 "parse.y"
2125 {
2126                         Node *node = new_check(NE_CHECK,yyvsp[0].id);
2127                         checks = g_list_append(checks,node);
2128                                         ;
2129     break;}
2130 case 116:
2131 #line 980 "parse.y"
2132 { yyval.id = yyvsp[0].id; ;
2133     break;}
2134 case 117:
2135 #line 981 "parse.y"
2136 {
2137                         yyval.id = g_strconcat("-",yyvsp[0].id,NULL);
2138                         g_free(yyvsp[0].id);
2139                                         ;
2140     break;}
2141 case 118:
2142 #line 985 "parse.y"
2143 { yyval.id = yyvsp[0].id; ;
2144     break;}
2145 }
2146    /* the action file gets copied in in place of this dollarsign */
2147 #line 543 "/usr/lib/bison.simple"
2148 \f
2149   yyvsp -= yylen;
2150   yyssp -= yylen;
2151 #ifdef YYLSP_NEEDED
2152   yylsp -= yylen;
2153 #endif
2154
2155 #if YYDEBUG != 0
2156   if (yydebug)
2157     {
2158       short *ssp1 = yyss - 1;
2159       fprintf (stderr, "state stack now");
2160       while (ssp1 != yyssp)
2161         fprintf (stderr, " %d", *++ssp1);
2162       fprintf (stderr, "\n");
2163     }
2164 #endif
2165
2166   *++yyvsp = yyval;
2167
2168 #ifdef YYLSP_NEEDED
2169   yylsp++;
2170   if (yylen == 0)
2171     {
2172       yylsp->first_line = yylloc.first_line;
2173       yylsp->first_column = yylloc.first_column;
2174       yylsp->last_line = (yylsp-1)->last_line;
2175       yylsp->last_column = (yylsp-1)->last_column;
2176       yylsp->text = 0;
2177     }
2178   else
2179     {
2180       yylsp->last_line = (yylsp+yylen-1)->last_line;
2181       yylsp->last_column = (yylsp+yylen-1)->last_column;
2182     }
2183 #endif
2184
2185   /* Now "shift" the result of the reduction.
2186      Determine what state that goes to,
2187      based on the state we popped back to
2188      and the rule number reduced by.  */
2189
2190   yyn = yyr1[yyn];
2191
2192   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
2193   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2194     yystate = yytable[yystate];
2195   else
2196     yystate = yydefgoto[yyn - YYNTBASE];
2197
2198   goto yynewstate;
2199
2200 yyerrlab:   /* here on detecting error */
2201
2202   if (! yyerrstatus)
2203     /* If not already recovering from an error, report this error.  */
2204     {
2205       ++yynerrs;
2206
2207 #ifdef YYERROR_VERBOSE
2208       yyn = yypact[yystate];
2209
2210       if (yyn > YYFLAG && yyn < YYLAST)
2211         {
2212           int size = 0;
2213           char *msg;
2214           int x, count;
2215
2216           count = 0;
2217           /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
2218           for (x = (yyn < 0 ? -yyn : 0);
2219                x < (sizeof(yytname) / sizeof(char *)); x++)
2220             if (yycheck[x + yyn] == x)
2221               size += strlen(yytname[x]) + 15, count++;
2222           msg = (char *) malloc(size + 15);
2223           if (msg != 0)
2224             {
2225               strcpy(msg, "parse error");
2226
2227               if (count < 5)
2228                 {
2229                   count = 0;
2230                   for (x = (yyn < 0 ? -yyn : 0);
2231                        x < (sizeof(yytname) / sizeof(char *)); x++)
2232                     if (yycheck[x + yyn] == x)
2233                       {
2234                         strcat(msg, count == 0 ? ", expecting `" : " or `");
2235                         strcat(msg, yytname[x]);
2236                         strcat(msg, "'");
2237                         count++;
2238                       }
2239                 }
2240               yyerror(msg);
2241               free(msg);
2242             }
2243           else
2244             yyerror ("parse error; also virtual memory exceeded");
2245         }
2246       else
2247 #endif /* YYERROR_VERBOSE */
2248         yyerror("parse error");
2249     }
2250
2251   goto yyerrlab1;
2252 yyerrlab1:   /* here on error raised explicitly by an action */
2253
2254   if (yyerrstatus == 3)
2255     {
2256       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
2257
2258       /* return failure if at end of input */
2259       if (yychar == YYEOF)
2260         YYABORT;
2261
2262 #if YYDEBUG != 0
2263       if (yydebug)
2264         fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
2265 #endif
2266
2267       yychar = YYEMPTY;
2268     }
2269
2270   /* Else will try to reuse lookahead token
2271      after shifting the error token.  */
2272
2273   yyerrstatus = 3;              /* Each real token shifted decrements this */
2274
2275   goto yyerrhandle;
2276
2277 yyerrdefault:  /* current state does not do anything special for the error token. */
2278
2279 #if 0
2280   /* This is wrong; only states that explicitly want error tokens
2281      should shift them.  */
2282   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
2283   if (yyn) goto yydefault;
2284 #endif
2285
2286 yyerrpop:   /* pop the current state because it cannot handle the error token */
2287
2288   if (yyssp == yyss) YYABORT;
2289   yyvsp--;
2290   yystate = *--yyssp;
2291 #ifdef YYLSP_NEEDED
2292   yylsp--;
2293 #endif
2294
2295 #if YYDEBUG != 0
2296   if (yydebug)
2297     {
2298       short *ssp1 = yyss - 1;
2299       fprintf (stderr, "Error: state stack now");
2300       while (ssp1 != yyssp)
2301         fprintf (stderr, " %d", *++ssp1);
2302       fprintf (stderr, "\n");
2303     }
2304 #endif
2305
2306 yyerrhandle:
2307
2308   yyn = yypact[yystate];
2309   if (yyn == YYFLAG)
2310     goto yyerrdefault;
2311
2312   yyn += YYTERROR;
2313   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
2314     goto yyerrdefault;
2315
2316   yyn = yytable[yyn];
2317   if (yyn < 0)
2318     {
2319       if (yyn == YYFLAG)
2320         goto yyerrpop;
2321       yyn = -yyn;
2322       goto yyreduce;
2323     }
2324   else if (yyn == 0)
2325     goto yyerrpop;
2326
2327   if (yyn == YYFINAL)
2328     YYACCEPT;
2329
2330 #if YYDEBUG != 0
2331   if (yydebug)
2332     fprintf(stderr, "Shifting error token, ");
2333 #endif
2334
2335   *++yyvsp = yylval;
2336 #ifdef YYLSP_NEEDED
2337   *++yylsp = yylloc;
2338 #endif
2339
2340   yystate = yyn;
2341   goto yynewstate;
2342
2343  yyacceptlab:
2344   /* YYACCEPT comes here.  */
2345   if (yyfree_stacks)
2346     {
2347       free (yyss);
2348       free (yyvs);
2349 #ifdef YYLSP_NEEDED
2350       free (yyls);
2351 #endif
2352     }
2353   return 0;
2354
2355  yyabortlab:
2356   /* YYABORT comes here.  */
2357   if (yyfree_stacks)
2358     {
2359       free (yyss);
2360       free (yyvs);
2361 #ifdef YYLSP_NEEDED
2362       free (yyls);
2363 #endif
2364     }
2365   return 1;
2366 }
2367 #line 988 "parse.y"
2368