2 * Copyright (C) 1999-2000 the Free Software Foundation.
3 * Copyright (C) 2000 Eazel, Inc.
4 * Copyright (C) 2001-2004 George (Jiri) Lebl
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
31 #include "treefuncs.h"
35 /* FIXME: add gettext support */
40 static GList *class_nodes = NULL;
43 static GList *enum_vals = NULL;
44 static GList *flag_vals = NULL;
45 static GList *error_vals = NULL;
47 static char *chunk_size = NULL;
48 static char *bonobo_object_class = NULL;
49 static int glade_xml = FALSE;
50 static GList *interfaces = NULL;
51 static GList *typestack = NULL;
52 static GList *funcargs = NULL;
53 static GList *checks = NULL;
54 static int has_self = FALSE;
55 static int vararg = FALSE;
56 static Method *last_added_method = NULL;
58 /* destructor and initializer for variables */
59 static gboolean destructor_unref = FALSE;
60 static char *destructor = NULL;
61 static int destructor_line = 0;
62 static gboolean destructor_simple = TRUE;
63 static char *initializer = NULL;
64 static int initializer_line = 0;
65 static int glade_widget = FALSE;
67 static char *onerror = NULL;
68 static char *defreturn = NULL;
70 static GList *gtktypes = NULL;
72 static Property *property = NULL;
74 /* this can be a global as we will only do one function at a time
76 static int the_scope = NO_SCOPE;
81 extern int ccode_line;
83 extern gboolean for_cpp;
93 if(strcmp(yytext,"\n")==0) {
94 out=g_strconcat("Error: ",str," before newline",NULL);
95 } else if(yytext[0]=='\0') {
96 out=g_strconcat("Error: ", str, " at end of input", NULL);
98 char *tmp = g_strdup(yytext);
99 while((p=strchr(tmp, '\n')))
102 out=g_strconcat("Error: ", str, " before '", tmp, "'", NULL);
106 fprintf(stderr, "%s:%d: %s\n", filename, line_no, out);
115 Type *type = typestack->data;
116 typestack = g_list_remove(typestack,typestack->data);
121 push_variable (char *name, int scope, int line_no, char *postfix)
124 Type *type = pop_type ();
126 type->postfix = postfix;
128 var = node_new (VARIABLE_NODE,
131 "glade_widget", glade_widget,
134 "destructor_unref", destructor_unref,
135 "destructor:steal", destructor,
136 "destructor_line", destructor_line,
137 "destructor_simple", destructor_simple,
138 "initializer:steal", initializer,
139 "initializer_line", initializer_line,
140 "initializer_simple", TRUE,
142 class_nodes = g_list_append(class_nodes, var);
143 glade_widget = FALSE;
147 push_function (int scope, int method, char *oid, char *id,
148 GString *cbuf, int line_no, int ccode_line,
149 gboolean vararg, GList *flags)
155 g_assert(scope != CLASS_SCOPE);
157 if(method == INIT_METHOD || method == CLASS_INIT_METHOD) {
158 type = (Type *)node_new (TYPE_NODE,
165 /* a complicated and ugly test to figure out if we have
166 the wrong number of types for a signal */
167 if((method == SIGNAL_FIRST_METHOD ||
168 method == SIGNAL_LAST_METHOD) &&
169 g_list_length(gtktypes) != g_list_length(funcargs) &&
170 !(g_list_length(funcargs) == 1 &&
171 g_list_length(gtktypes) == 2 &&
172 strcmp(gtktypes->next->data, "NONE")==0)) {
173 error_print(GOB_WARN, line_no,
174 _("The number of GTK arguments and "
175 "function arguments for a signal "
176 "don't seem to match"));
178 if(g_list_length(gtktypes) > 2) {
180 for(li = gtktypes->next; li; li = li->next) {
181 if(strcmp(li->data, "NONE")==0) {
182 error_print(GOB_ERROR, line_no,
183 _("NONE can only appear in an "
184 "argument list by itself"));
190 c_cbuf = p = cbuf->str;
191 while(p && *p && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
198 node = node_new (METHOD_NODE,
203 "gtktypes:steal", gtktypes,
204 "flags:steal", flags,
206 "args:steal", funcargs,
207 "onerror:steal", onerror,
208 "defreturn:steal", defreturn,
209 "cbuf:steal", c_cbuf,
211 "ccode_line", ccode_line,
213 "unique_id", method_unique_id++,
216 last_added_method = (Method *)node;
220 /*only free segment if we haven't passed it
229 class_nodes = g_list_append(class_nodes, node);
233 free_all_global_state(void)
243 g_list_foreach(gtktypes, (GFunc)g_free, NULL);
244 g_list_free(gtktypes);
247 node_list_free (funcargs);
252 push_funcarg(char *name, char *postfix)
255 Type *type = pop_type();
257 type->postfix = postfix;
259 node = node_new (FUNCARG_NODE,
262 "checks:steal", checks,
266 funcargs = g_list_append(funcargs, node);
270 push_init_arg(char *name, int is_class)
277 tn = g_strconcat(((Class *)class)->otype,":Class",NULL);
279 tn = g_strdup(((Class *)class)->otype);
281 type = node_new (TYPE_NODE,
285 node = node_new (FUNCARG_NODE,
286 "atype:steal", (Type *)type,
289 funcargs = g_list_prepend(funcargs, node);
293 push_self(char *id, gboolean constant)
298 type = node_new (TYPE_NODE,
299 "name", ((Class *)class)->otype,
300 "pointer", constant ? "const *" : "*",
302 ch = g_list_append (ch, node_new (CHECK_NODE,
303 "chtype", NULL_CHECK,
305 ch = g_list_append (ch, node_new (CHECK_NODE,
306 "chtype", TYPE_CHECK,
308 node = node_new (FUNCARG_NODE,
309 "atype:steal", (Type *)type,
313 funcargs = g_list_prepend(funcargs, node);
317 find_var_or_die(const char *id, int line)
321 for(li = class_nodes; li != NULL; li = li->next) {
323 Node *node = li->data;
324 if(node->type != VARIABLE_NODE)
327 if(strcmp(var->id, id)==0)
331 error_printf(GOB_ERROR, line, _("Variable %s not defined here"), id);
333 g_assert_not_reached();
338 set_return_value(char *type, char *val)
340 if(strcmp(type, "onerror")==0) {
346 } else if(strcmp(type, "defreturn")==0) {
357 export_accessors (const char *var_name,
369 the_type = (Type *)node_copy ((Node *)type);
371 the_type = get_tree_type (gtktype, TRUE);
373 if (the_type == NULL) {
374 error_print (GOB_ERROR, line_no,
375 _("Cannot determine type of property or argument"));
380 char *get_id = g_strdup_printf ("get_%s", var_name);
381 GString *get_cbuf = g_string_new (NULL);
382 Node *node1 = node_new (TYPE_NODE,
383 "name", the_type->name,
384 "pointer", the_type->pointer,
385 "postfix", the_type->postfix,
387 Node *node3 = node_new (TYPE_NODE,
388 "name", class->class.otype,
392 g_string_sprintf (get_cbuf,
394 "g_object_get (G_OBJECT (self), \"%s\", "
398 the_type->pointer ? the_type->pointer : "",
401 typestack = g_list_prepend (typestack, node1);
402 typestack = g_list_prepend (typestack, node3);
404 push_funcarg ("self", FALSE);
406 push_function (PUBLIC_SCOPE, REGULAR_METHOD, NULL,
407 get_id, get_cbuf, get_lineno,
408 lineno, FALSE, NULL);
412 char *set_id = g_strdup_printf ("set_%s", var_name);
413 GString *set_cbuf = g_string_new (NULL);
414 Node *node1 = node_new (TYPE_NODE,
415 "name", the_type->name,
416 "pointer", the_type->pointer,
417 "postfix", the_type->postfix,
419 Node *node2 = node_new (TYPE_NODE,
422 Node *node3 = node_new (TYPE_NODE,
423 "name", class->class.otype,
427 g_string_sprintf (set_cbuf,
428 "\tg_object_set (G_OBJECT (self), "
429 "\"%s\", val, NULL);\n",
432 typestack = g_list_prepend (typestack, node2);
433 typestack = g_list_prepend (typestack, node1);
434 typestack = g_list_prepend (typestack, node3);
436 push_funcarg ("self", FALSE);
437 push_funcarg ("val", FALSE);
439 typestack = g_list_prepend (typestack, node2);
440 push_function (PUBLIC_SCOPE, REGULAR_METHOD, NULL,
441 set_id, set_cbuf, set_lineno,
442 lineno, FALSE, NULL);
445 node_free ((Node *)the_type);
449 get_prop_enum_flag_cast (Property *prop)
452 if (prop->extra_gtktype == NULL ||
453 /* HACK! just in case someone made this
454 * work with 2.0.0 by using the TYPE
456 ((strstr (prop->extra_gtktype, "_TYPE_") != NULL ||
457 strstr (prop->extra_gtktype, "TYPE_") == prop->extra_gtktype) &&
458 strchr (prop->extra_gtktype, ':') == NULL)) {
459 if (prop->ptype != NULL)
460 return get_type (prop->ptype, TRUE);
462 return g_strdup ("");
464 tmp = remove_sep (prop->extra_gtktype);
465 ret = g_strdup_printf ("(%s) ", tmp);
471 add_construct_glade (char * file, char * root, char * domain)
475 GList * flags = NULL;
478 type = (Type *)node_new (TYPE_NODE,
482 initializer = g_strdup_printf("\t{\n"
483 "\tGtkWidget * root;\n"
484 "\to->_priv->_glade_xml = glade_xml_new(%s, %s, %s);\n"
485 "\troot = glade_xml_get_widget(o->_priv->_glade_xml, %s);\n"
486 "\tgtk_widget_show(root);\n"
487 "\tgtk_container_add(GTK_CONTAINER(o), root);\n"
488 "\tglade_xml_signal_autoconnect_full(o->_priv->_glade_xml, (GladeXMLConnectFunc)___glade_xml_connect_foreach, (gpointer)o);\n"
489 "}\n", file, root, domain ? domain : "NULL", root);
491 var = node_new (VARIABLE_NODE,
492 "scope", PRIVATE_SCOPE,
494 "glade_widget", FALSE,
495 "id:steal", "_glade_xml",
496 "destructor_unref", FALSE,
497 "destructor", "g_object_unref",
498 "destructor_simple", TRUE,
499 "initializer", initializer,
500 "initializer_simple", FALSE,
502 class_nodes = g_list_prepend(class_nodes, var);
506 property_link_and_export (Node *node)
508 Property *prop = (Property *)node;
512 char *get = NULL, *set = NULL;
515 if (prop->set != NULL ||
517 error_print (GOB_ERROR, prop->line_no,
518 _("Property linking requested, but "
519 "getters and setters exist"));
522 var = find_var_or_die (prop->name, prop->line_no);
523 if(var->scope == PRIVATE_SCOPE) {
524 root = "self->_priv";
525 } else if (var->scope == CLASS_SCOPE) {
526 root = "SELF_GET_CLASS(self)";
528 error_print (GOB_ERROR, prop->line_no,
529 _("Self aliases needed when autolinking to a classwide member"));
534 if (strcmp (prop->gtktype, "STRING") == 0) {
535 set = g_strdup_printf("{ char *old = %s->%s; "
536 "%s->%s = g_value_dup_string (VAL); g_free (old); }",
539 get = g_strdup_printf("g_value_set_string (VAL, %s->%s);",
541 } else if (strcmp (prop->gtktype, "OBJECT") == 0) {
543 if (prop->extra_gtktype != NULL) {
544 cast = remove_sep (prop->extra_gtktype);
546 cast = g_strdup ("void");
548 set = g_strdup_printf("{ GObject *___old = (GObject *)%s->%s; "
549 "%s->%s = (%s *)g_value_dup_object (VAL); "
550 "if (___old != NULL) { "
551 "g_object_unref (G_OBJECT (___old)); "
557 get = g_strdup_printf ("g_value_set_object (VAL, "
558 "(gpointer)%s->%s);",
561 } else if (strcmp (prop->gtktype, "BOXED") == 0) {
562 char *type = make_me_type (prop->extra_gtktype,
564 if (prop->extra_gtktype == NULL) {
565 error_print (GOB_ERROR, prop->line_no,
566 _("Property linking requested for BOXED, but "
567 "boxed_type not set"));
569 set = g_strdup_printf("{ gpointer ___old = (gpointer)%s->%s; "
570 "gpointer ___new = (gpointer)g_value_get_boxed (VAL); "
571 "if (___new != ___old) { "
572 "if (___old != NULL) g_boxed_free (%s, ___old); "
573 "if (___new != NULL) %s->%s = g_boxed_copy (%s, ___new); "
574 "else %s->%s = NULL;"
582 get = g_strdup_printf("g_value_set_boxed (VAL, %s->%s);",
588 const char *getcast = "";
589 const char *setcast = "";
590 char *to_free = NULL;
591 set_func = g_strdup_printf ("g_value_set_%s", prop->gtktype);
592 g_strdown (set_func);
593 get_func = g_strdup_printf ("g_value_get_%s", prop->gtktype);
594 g_strdown (get_func);
597 if (strcmp (prop->gtktype, "FLAGS") == 0) {
598 setcast = "(guint) ";
600 get_prop_enum_flag_cast (prop);
601 } else if (strcmp (prop->gtktype, "ENUM") == 0) {
604 get_prop_enum_flag_cast (prop);
605 } else if (strcmp (prop->gtktype, "POINTER") == 0) {
606 setcast = "(gpointer) ";
607 getcast = g_strdup_printf ("(%s%s) ",
609 prop->ptype->pointer ? prop->ptype->pointer : "");
613 set = g_strdup_printf("%s->%s = %s%s (VAL);",
617 get = g_strdup_printf("%s (VAL, %s%s->%s);",
629 "get_line", prop->line_no,
631 "set_line", prop->line_no,
636 export_accessors (prop->name,
637 prop->get != NULL, prop->get_line,
638 prop->set != NULL, prop->set_line,
649 if (strcmp (s, "BOOL") == 0) {
650 error_print (GOB_WARN, line_no,
651 _("BOOL type is deprecated, please use BOOLEAN"));
653 return g_strdup ("BOOLEAN");
660 ensure_property (void)
662 if (property == NULL)
663 property = (Property *)node_new (PROPERTY_NODE, NULL);
677 %token CONST VOID STRUCT UNION ENUM THREEDOTS
678 %token SIGNED UNSIGNED LONG SHORT INT FLOAT DOUBLE CHAR
680 %token <id> TOKEN NUMBER TYPETOKEN ARRAY_DIM SINGLE_CHAR
681 %token <cbuf> CCODE HTCODE PHCODE HCODE ACODE ATCODE STRING
682 %token <line> PUBLIC PRIVATE PROTECTED CLASSWIDE PROPERTY ARGUMENT
683 %token <line> VIRTUAL SIGNAL OVERRIDE
684 %token <line> NICK BLURB MAXIMUM MINIMUM DEFAULT_VALUE ERROR FLAGS TYPE
685 %token <line> FLAGS_TYPE ENUM_TYPE PARAM_TYPE BOXED_TYPE OBJECT_TYPE
689 prog: ccodes class ccodes { ; }
696 Node *node = node_new (CCODE_NODE,
698 "cbuf:steal", ($<cbuf>1)->str,
699 "line_no", ccode_line,
701 nodes = g_list_append(nodes,node);
702 g_string_free($<cbuf>1,FALSE);
705 Node *node = node_new (CCODE_NODE,
707 "cbuf:steal", ($<cbuf>1)->str,
708 "line_no", ccode_line,
710 nodes = g_list_append(nodes,node);
711 g_string_free($<cbuf>1,FALSE);
714 Node *node = node_new (CCODE_NODE,
716 "cbuf:steal", ($<cbuf>1)->str,
717 "line_no", ccode_line,
719 nodes = g_list_append(nodes,node);
720 g_string_free($<cbuf>1,FALSE);
723 Node *node = node_new (CCODE_NODE,
725 "cbuf:steal", ($<cbuf>1)->str,
726 "line_no", ccode_line,
728 nodes = g_list_append(nodes,node);
729 g_string_free($<cbuf>1,FALSE);
732 Node *node = node_new (CCODE_NODE,
734 "cbuf:steal", ($<cbuf>1)->str,
735 "line_no", ccode_line,
737 nodes = g_list_append(nodes,node);
738 g_string_free($<cbuf>1,FALSE);
741 Node *node = node_new (CCODE_NODE,
743 "cbuf:steal", ($<cbuf>1)->str,
744 "line_no", ccode_line,
746 nodes = g_list_append(nodes,node);
747 g_string_free($<cbuf>1,FALSE);
751 ccodes: ccodes ccode { ; }
752 | ccodes enumcode { ; }
753 | ccodes flagcode { ; }
754 | ccodes errorcode { ; }
761 class: classdec '{' classcode '}' {
762 ((Class *)class)->nodes = class_nodes;
764 nodes = g_list_append(nodes,class);
767 ((Class *)class)->nodes = NULL;
769 nodes = g_list_append(nodes,class);
773 classdec: CLASS TYPETOKEN FROM TYPETOKEN classflags {
774 class = node_new (CLASS_NODE,
775 "otype:steal", $<id>2,
776 "ptype:steal", $<id>4,
777 "bonobo_object_class:steal", bonobo_object_class,
778 "glade_xml", glade_xml,
779 "interfaces:steal", interfaces,
780 "chunk_size:steal", chunk_size,
782 bonobo_object_class = NULL;
790 | '(' TOKEN TOKEN ')' classflags {
791 if(strcmp($<id>2,"chunks") == 0) {
793 chunk_size = g_strdup($<id>3);
794 } else if(strcmp($<id>2,"BonoboObject") == 0) {
795 g_free (bonobo_object_class);
796 bonobo_object_class = g_strdup($<id>3);
798 yyerror(_("parse error"));
802 | '(' TOKEN TYPETOKEN ')' classflags {
803 if (strcmp ($<id>2, "interface") == 0) {
804 interfaces = g_list_append (interfaces,
807 yyerror(_("parse error"));
811 | '(' TOKEN NUMBER ')' classflags {
812 if(strcmp($<id>2,"chunks") == 0) {
814 if(atoi($<id>3) != 0)
815 chunk_size = g_strdup($<id>3);
819 yyerror(_("parse error"));
823 | '(' TOKEN STRING STRING ')' classflags {
824 if (strcmp ($<id>2, "GladeXML") == 0) {
826 add_construct_glade($<id>3, $<id>4, NULL);
828 yyerror(_("parse error"));
832 | '(' TOKEN STRING STRING STRING ')' classflags {
833 if (strcmp ($<id>2, "GladeXML") == 0) {
835 add_construct_glade($<id>3, $<id>4, $<id>5);
837 yyerror(_("parse error"));
841 | '(' TOKEN TOKEN STRING ')' classflags {
842 if (strcmp ($<id>2, "GladeXML") == 0) {
844 add_construct_glade($<id>3, $<id>4, NULL);
846 yyerror(_("parse error"));
850 | '(' TOKEN TOKEN STRING STRING ')' classflags {
851 if (strcmp ($<id>2, "GladeXML") == 0) {
853 add_construct_glade($<id>3, $<id>4, $<id>5);
855 yyerror(_("parse error"));
861 classcode: classcode thing { ; }
867 if (strcmp ($<id>1, "BonoboObject") != 0) {
869 yyerror (_("parse error"));
873 last_added_method->bonobo_object_func = TRUE;
875 | TOKEN TYPETOKEN method {
876 if (strcmp ($<id>1, "interface") != 0) {
879 yyerror (_("parse error"));
883 node_set ((Node *)last_added_method,
884 "interface:steal", $<id>2,
893 scope: PUBLIC { the_scope = PUBLIC_SCOPE; }
894 | PRIVATE { the_scope = PRIVATE_SCOPE; }
895 | PROTECTED { the_scope = PROTECTED_SCOPE; }
896 | CLASSWIDE { the_scope = CLASS_SCOPE; }
899 destructor: TOKEN TOKEN {
900 if (strcmp ($<id>1, "destroywith") == 0) {
902 destructor_unref = FALSE;
904 destructor_line = line_no;
905 destructor_simple = TRUE;
906 } else if (strcmp ($<id>1, "unrefwith") == 0) {
908 destructor_unref = TRUE;
910 destructor_line = line_no;
911 destructor_simple = TRUE;
915 yyerror (_("parse error"));
920 if (strcmp ($<id>1, "destroy") == 0) {
922 destructor_unref = FALSE;
923 destructor = ($<cbuf>3)->str;
924 g_string_free($<cbuf>3, FALSE);
925 destructor_line = ccode_line;
926 destructor_simple = FALSE;
927 } else if (strcmp ($<id>1, "unref") == 0) {
929 destructor_unref = TRUE;
930 destructor = ($<cbuf>3)->str;
931 g_string_free ($<cbuf>3, FALSE);
932 destructor_line = ccode_line;
933 destructor_simple = FALSE;
936 g_string_free ($<cbuf>3, TRUE);
937 yyerror (_("parse error"));
943 initializer: '=' numtok {
944 initializer = $<id>2;
945 initializer_line = ccode_line;
948 initializer = ($<cbuf>3)->str;
949 initializer_line = ccode_line;
950 g_string_free($<cbuf>3, FALSE);
955 varoptions: destructor initializer { ; }
956 | initializer destructor { ; }
957 | initializer { destructor = NULL; }
958 | destructor { initializer = NULL; }
960 if (strcmp ($<id>1, "GladeXML") == 0) {
963 yyerror(_("parse error"));
973 variable: scope type TOKEN varoptions ';' {
974 push_variable($<id>3, the_scope,$<line>1, NULL);
976 | scope type TOKEN ARRAY_DIM varoptions ';' {
977 push_variable($<id>3, the_scope, $<line>1, $<id>4);
981 argument: ARGUMENT flags argtype TOKEN export TOKEN '{' CCODE TOKEN '{' CCODE ';' {
983 if(strcmp($<id>6,"get")==0 &&
984 strcmp($<id>9,"set")==0) {
985 Type *type = pop_type();
988 node = node_new (ARGUMENT_NODE,
989 "gtktype:steal", $<id>3,
991 "flags:steal", $<list>2,
992 "name:steal", $<id>4,
993 "get:steal", ($<cbuf>8)->str,
994 "get_line", $<line>7,
995 "set:steal", ($<cbuf>11)->str,
996 "set_line", $<line>10,
1000 class_nodes = g_list_append(class_nodes,node);
1002 g_string_free ($<cbuf>8, FALSE);
1003 g_string_free ($<cbuf>11, FALSE);
1005 } else if(strcmp($<id>6,"set")==0 &&
1006 strcmp($<id>9,"get")==0) {
1007 Type *type = pop_type();
1010 node = node_new (ARGUMENT_NODE,
1011 "gtktype:steal", $<id>3,
1012 "atype:steal", type,
1013 "flags:steal", $<list>2,
1014 "name:steal", $<id>4,
1015 "get:steal", ($<cbuf>11)->str,
1016 "get_line", $<line>10,
1017 "set:steal", ($<cbuf>8)->str,
1018 "set_line", $<line>7,
1019 "line_no", $<line>1,
1021 g_string_free ($<cbuf>11, FALSE);
1022 g_string_free ($<cbuf>8, FALSE);
1023 class_nodes = g_list_append(class_nodes,node);
1029 g_list_foreach ($<list>2, (GFunc)g_free, NULL);
1030 g_list_free ($<list>2);
1031 g_string_free ($<cbuf>11, TRUE);
1032 g_string_free ($<cbuf>8, TRUE);
1033 yyerror (_("parse error"));
1037 if ($<id>5 != NULL) {
1038 Argument *arg = (Argument *)node;
1039 export_accessors (arg->name,
1040 arg->get != NULL, arg->get_line,
1041 arg->set != NULL, arg->set_line,
1049 | ARGUMENT flags argtype TOKEN export TOKEN '{' CCODE ';' {
1051 if(strcmp($<id>6, "get") == 0) {
1052 Type *type = pop_type();
1054 node = node_new (ARGUMENT_NODE,
1055 "gtktype:steal", $<id>3,
1056 "atype:steal", type,
1057 "flags:steal", $<list>2,
1058 "name:steal", $<id>4,
1059 "get:steal", ($<cbuf>8)->str,
1060 "get_line", $<line>7,
1061 "line_no", $<line>1,
1064 g_string_free ($<cbuf>8, FALSE);
1065 class_nodes = g_list_append(class_nodes, node);
1066 } else if(strcmp($<id>6, "set") == 0) {
1067 Type *type = pop_type();
1069 node = node_new (ARGUMENT_NODE,
1070 "gtktype:steal", $<id>3,
1071 "atype:steal", type,
1072 "flags:steal", $<list>2,
1073 "name:steal", $<id>4,
1074 "set:steal", ($<cbuf>8)->str,
1075 "set_line", $<line>7,
1076 "line_no", $<line>1,
1079 g_string_free ($<cbuf>8, FALSE);
1080 class_nodes = g_list_append (class_nodes, node);
1085 g_list_foreach ($<list>2, (GFunc)g_free, NULL);
1086 g_list_free ($<list>2);
1087 g_string_free ($<cbuf>8, TRUE);
1088 yyerror(_("parse error"));
1092 if ($<id>5 != NULL) {
1093 Argument *arg = (Argument *)node;
1094 export_accessors (arg->name,
1095 arg->get != NULL, arg->get_line,
1096 arg->set != NULL, arg->set_line,
1103 | ARGUMENT flags argtype TOKEN export TOKEN {
1105 char *get, *set = NULL;
1110 if(strcmp($<id>6, "link")!=0 &&
1111 strcmp($<id>6, "stringlink")!=0 &&
1112 strcmp($<id>6, "objectlink")!=0) {
1116 g_list_foreach($<list>2,(GFunc)g_free,NULL);
1117 g_list_free($<list>2);
1118 yyerror(_("parse error"));
1124 var = find_var_or_die($<id>4, $<line>1);
1125 if(var->scope == PRIVATE_SCOPE) {
1126 root = "self->_priv";
1127 } else if(var->scope == CLASS_SCOPE) {
1128 root = "SELF_GET_CLASS(self)";
1130 error_print(GOB_ERROR, $<line>1,
1131 _("Self aliases needed when autolinking to a classwide member"));
1136 if(strcmp($<id>6, "link")==0) {
1137 set = g_strdup_printf("%s->%s = ARG;",
1139 } else if(strcmp($<id>6, "stringlink")==0) {
1140 set = g_strdup_printf("g_free (%s->%s); "
1141 "%s->%s = g_strdup (ARG);",
1144 } else if(strcmp($<id>6, "objectlink")==0) {
1145 set = g_strdup_printf(
1147 "g_object_ref (G_OBJECT (ARG)); "
1148 "if (%s->%s != NULL) "
1149 "g_object_unref (G_OBJECT (%s->%s)); "
1155 g_assert_not_reached();
1158 get = g_strdup_printf("ARG = %s->%s;", root, $<id>4);
1163 type = (Type *)node_copy ((Node *)var->vtype);
1165 node = node_new (ARGUMENT_NODE,
1166 "gtktype:steal", $<id>3,
1167 "atype:steal", type,
1168 "flags:steal", $<list>2,
1169 "name:steal", $<id>4,
1171 "get_line", $<line>1,
1173 "set_line", $<line>1,
1174 "line_no", $<line>1,
1177 if ($<id>5 != NULL) {
1178 Argument *arg = (Argument *)node;
1179 export_accessors (arg->name,
1180 arg->get != NULL, arg->get_line,
1181 arg->set != NULL, arg->set_line,
1188 class_nodes = g_list_append (class_nodes, node);
1192 export: '(' TOKEN ')' {
1193 if (strcmp ($<id>2, "export")!=0) {
1195 yyerror (_("parse error"));
1205 property: PROPERTY TOKEN TOKEN param_spec TOKEN '{' CCODE TOKEN '{' CCODE ';' {
1207 node_set ((Node *)property,
1208 "line_no", $<line>1,
1209 "gtktype:steal", debool ($<id>2),
1210 "name:steal", $<id>3,
1212 if (strcmp ($<id>5, "get") == 0 &&
1213 strcmp ($<id>8, "set") == 0) {
1214 node_set ((Node *)property,
1215 "get:steal", ($<cbuf>7)->str,
1216 "get_line", $<line>6,
1217 "set:steal", ($<cbuf>10)->str,
1218 "set_line", $<line>9,
1220 g_string_free ($<cbuf>7, FALSE);
1221 g_string_free ($<cbuf>10, FALSE);
1224 } else if (strcmp ($<id>5, "set") == 0 &&
1225 strcmp ($<id>8, "get") == 0) {
1226 node_set ((Node *)property,
1227 "get:steal", ($<cbuf>10)->str,
1228 "get_line", $<line>9,
1229 "set:steal", ($<cbuf>7)->str,
1230 "set_line", $<line>6,
1232 g_string_free ($<cbuf>7, FALSE);
1233 g_string_free ($<cbuf>10, FALSE);
1237 g_string_free ($<cbuf>7, TRUE);
1238 g_string_free ($<cbuf>10, TRUE);
1241 node_free ((Node *)property);
1243 yyerror (_("parse error"));
1246 property_link_and_export ((Node *)property);
1247 if (property != NULL) {
1248 class_nodes = g_list_append (class_nodes,
1253 | PROPERTY TOKEN TOKEN param_spec TOKEN '{' CCODE ';' {
1255 node_set ((Node *)property,
1256 "line_no", $<line>1,
1257 "gtktype:steal", debool ($<id>2),
1258 "name:steal", $<id>3,
1260 if (strcmp ($<id>5, "get") == 0) {
1261 node_set ((Node *)property,
1262 "get:steal", ($<cbuf>7)->str,
1263 "get_line", $<line>6,
1265 g_string_free ($<cbuf>7, FALSE);
1267 } else if (strcmp ($<id>5, "set") == 0) {
1268 node_set ((Node *)property,
1269 "set:steal", ($<cbuf>7)->str,
1270 "set_line", $<line>6,
1272 g_string_free ($<cbuf>7, FALSE);
1275 g_string_free ($<cbuf>7, TRUE);
1277 node_free ((Node *)property);
1279 yyerror (_("parse error"));
1282 property_link_and_export ((Node *)property);
1283 if (property != NULL) {
1284 class_nodes = g_list_append (class_nodes,
1289 | PROPERTY TOKEN TOKEN param_spec ';' {
1291 node_set ((Node *)property,
1292 "line_no", $<line>1,
1293 "gtktype:steal", debool ($<id>2),
1294 "name:steal", $<id>3,
1296 property_link_and_export ((Node *)property);
1297 if (property != NULL) {
1298 class_nodes = g_list_append (class_nodes,
1305 param_spec: '(' param_spec_list ')' { ; }
1309 param_spec_list: param_spec_list ',' param_spec_value { ; }
1310 | param_spec_value { ; }
1313 string: STRING { $<id>$ = $<id>1; }
1314 | TOKEN '(' STRING ')' {
1315 if (strcmp ($<id>1, "_") != 0) {
1317 yyerror(_("parse error"));
1321 $<id>$ = g_strconcat ("_(", $<id>3, ")", NULL);
1326 anyval: numtok { $<id>$ = $<id>1; }
1327 | string { $<id>$ = $<id>1; }
1330 param_spec_value: NICK '=' string {
1332 node_set ((Node *)property,
1333 "nick:steal", $<id>3,
1336 | BLURB '=' string {
1338 node_set ((Node *)property,
1339 "blurb:steal", $<id>3,
1342 | MAXIMUM '=' numtok {
1344 node_set ((Node *)property,
1345 "maximum:steal", $<id>3,
1348 | MINIMUM '=' numtok {
1350 node_set ((Node *)property,
1351 "minimum:steal", $<id>3,
1354 | DEFAULT_VALUE '=' anyval {
1356 node_set ((Node *)property,
1357 "default_value:steal", $<id>3,
1360 | FLAGS '=' flaglist {
1362 node_set ((Node *)property,
1363 "flags:steal", $<list>3,
1367 Type *type = pop_type ();
1369 node_set ((Node *)property,
1370 "ptype:steal", type,
1373 | FLAGS_TYPE '=' TYPETOKEN {
1375 node_set ((Node *)property,
1376 "extra_gtktype:steal", $<id>3,
1379 | FLAGS_TYPE '=' TOKEN {
1381 node_set ((Node *)property,
1382 "extra_gtktype:steal", $<id>3,
1385 | ENUM_TYPE '=' TYPETOKEN {
1387 node_set ((Node *)property,
1388 "extra_gtktype:steal", $<id>3,
1391 | ENUM_TYPE '=' TOKEN {
1393 node_set ((Node *)property,
1394 "extra_gtktype:steal", $<id>3,
1397 | PARAM_TYPE '=' TYPETOKEN {
1399 node_set ((Node *)property,
1400 "extra_gtktype:steal", $<id>3,
1403 | PARAM_TYPE '=' TOKEN {
1405 node_set ((Node *)property,
1406 "extra_gtktype:steal", $<id>3,
1409 | BOXED_TYPE '=' TYPETOKEN {
1411 node_set ((Node *)property,
1412 "extra_gtktype:steal", $<id>3,
1415 | BOXED_TYPE '=' TOKEN {
1417 node_set ((Node *)property,
1418 "extra_gtktype:steal", $<id>3,
1421 | OBJECT_TYPE '=' TYPETOKEN {
1423 node_set ((Node *)property,
1424 "extra_gtktype:steal", $<id>3,
1427 | OBJECT_TYPE '=' TOKEN {
1429 node_set ((Node *)property,
1430 "extra_gtktype:steal", $<id>3,
1435 if (strcmp ($<id>1, "override") == 0) {
1437 node_set ((Node *)property,
1440 } else if (strcmp ($<id>1, "link") == 0) {
1442 node_set ((Node *)property,
1445 } else if (strcmp ($<id>1, "export") == 0) {
1447 node_set ((Node *)property,
1452 yyerror(_("parse error"));
1458 argtype: TOKEN '(' TOKEN type ')' {
1459 if(strcmp($<id>3,"type")!=0) {
1462 yyerror(_("parse error"));
1465 $<id>$ = debool ($<id>1);
1468 $<id>$ = debool ($<id>1);
1469 typestack = g_list_prepend(typestack,NULL);
1473 flags: '(' flaglist ')' { $<list>$ = $<list>2; }
1474 | { $<list>$ = NULL; }
1477 flaglist: TOKEN '|' flaglist {
1478 $<list>$ = g_list_append($<list>3,$<id>1);
1481 $<list>$ = g_list_append(NULL,$<id>1);
1486 type: specifier_list pointer {
1487 Node *node = node_new (TYPE_NODE,
1488 "name:steal", $<id>1,
1489 "pointer:steal", $<id>2,
1491 typestack = g_list_prepend(typestack,node);
1494 Node *node = node_new (TYPE_NODE,
1495 "name:steal", $<id>1,
1497 typestack = g_list_prepend(typestack,node);
1501 /* The special cases are neccessary to avoid conflicts */
1502 specifier_list: spec_list {
1509 $<id>$ = g_strconcat("const ", $<id>2, NULL);
1513 $<id>$ = g_strconcat($<id>1, " const", NULL);
1516 | strunionenum TOKEN {
1517 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
1520 | CONST strunionenum TOKEN {
1521 $<id>$ = g_strconcat("const ", $<id>2, " ",
1525 | strunionenum TOKEN CONST {
1526 $<id>$ = g_strconcat($<id>1, " ",
1527 $<id>2, " const", NULL);
1532 /* The special const cases take care of conflicts ! */
1533 spec_list: specifier spec_list {
1534 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
1537 | TYPETOKEN spec_list {
1538 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
1543 $<id>$ = g_strconcat("const ", $<id>2, NULL);
1550 $<id>$ = g_strconcat($<id>1, " const", NULL);
1554 $<id>$ = g_strdup($<id>1);
1557 $<id>$ = g_strconcat($<id>1, " const", NULL);
1561 specifier: VOID { $<id>$ = "void"; }
1562 | CHAR { $<id>$ = "char"; }
1563 | SHORT { $<id>$ = "short"; }
1564 | INT { $<id>$ = "int"; }
1565 | LONG { $<id>$ = "long"; }
1566 | FLOAT { $<id>$ = "float"; }
1567 | DOUBLE { $<id>$ = "double"; }
1568 | SIGNED { $<id>$ = "signed"; }
1569 | UNSIGNED { $<id>$ = "unsigned"; }
1572 strunionenum: STRUCT { $<id>$ = "struct"; }
1573 | UNION { $<id>$ = "union"; }
1574 | ENUM { $<id>$ = "enum"; }
1577 pointer: '*' { $<id>$ = g_strdup("*"); }
1578 | '*' CONST { $<id>$ = g_strdup("* const"); }
1580 $<id>$ = g_strconcat("*", $<id>2, NULL);
1583 | '*' CONST pointer {
1584 $<id>$ = g_strconcat("* const", $<id>3, NULL);
1589 /* this never sets the_scope */
1590 simplesigtype: TOKEN sigtype {
1591 if(strcmp($<id>1, "first")==0)
1592 $<sigtype>$ = SIGNAL_FIRST_METHOD;
1593 else if(strcmp($<id>1, "last")==0)
1594 $<sigtype>$ = SIGNAL_LAST_METHOD;
1596 yyerror(_("signal must be 'first' or 'last'"));
1603 $<sigtype>$ = SIGNAL_LAST_METHOD;
1607 /* this always sets the_scope */
1608 fullsigtype: scope TOKEN sigtype {
1609 if(strcmp($<id>2,"first")==0)
1610 $<sigtype>$ = SIGNAL_FIRST_METHOD;
1611 else if(strcmp($<id>2,"last")==0)
1612 $<sigtype>$ = SIGNAL_LAST_METHOD;
1614 yyerror(_("signal must be 'first' or 'last'"));
1620 | TOKEN scope sigtype {
1621 if(strcmp($<id>1,"first")==0)
1622 $<sigtype>$ = SIGNAL_FIRST_METHOD;
1623 else if(strcmp($<id>1,"last")==0)
1624 $<sigtype>$ = SIGNAL_LAST_METHOD;
1626 yyerror(_("signal must be 'first' or 'last'"));
1633 $<sigtype>$ = SIGNAL_LAST_METHOD;
1636 /* the_scope was default thus public */
1637 the_scope = PUBLIC_SCOPE;
1641 sigtype: TOKEN '(' tokenlist ')' {
1642 gtktypes = g_list_prepend(gtktypes, debool ($<id>1));
1646 tokenlist: tokenlist ',' TOKEN {
1647 gtktypes = g_list_append(gtktypes, debool ($<id>3));
1650 gtktypes = g_list_append(gtktypes, debool ($<id>1));
1654 codenocode: '{' CCODE { $<cbuf>$ = $<cbuf>2; }
1655 | ';' { $<cbuf>$ = NULL; }
1658 /*here CCODE will include the ending '}' */
1659 method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' returnvals codenocode {
1661 yyerror(_("signal without 'self' as "
1662 "first parameter"));
1663 free_all_global_state();
1666 if(the_scope == CLASS_SCOPE) {
1667 yyerror(_("a method cannot be of class scope"));
1668 free_all_global_state();
1671 push_function(the_scope, $<sigtype>3,NULL,
1672 $<id>5, $<cbuf>10,$<line>1,
1673 ccode_line, vararg, $<list>2);
1675 | scope SIGNAL flags simplesigtype type TOKEN '(' funcargs ')' returnvals codenocode {
1677 yyerror(_("signal without 'self' as "
1678 "first parameter"));
1679 free_all_global_state();
1682 if(the_scope == CLASS_SCOPE) {
1683 yyerror(_("a method cannot be of class scope"));
1684 free_all_global_state();
1687 push_function(the_scope, $<sigtype>4, NULL,
1688 $<id>6, $<cbuf>11, $<line>2,
1689 ccode_line, vararg, $<list>3);
1691 | VIRTUAL scope type TOKEN '(' funcargs ')' returnvals codenocode {
1693 yyerror(_("virtual method without 'self' as "
1694 "first parameter"));
1695 free_all_global_state();
1698 if(the_scope == CLASS_SCOPE) {
1699 yyerror(_("a method cannot be of class scope"));
1700 free_all_global_state();
1703 push_function(the_scope, VIRTUAL_METHOD, NULL, $<id>4,
1705 ccode_line, vararg, NULL);
1707 | scope VIRTUAL type TOKEN '(' funcargs ')' returnvals codenocode {
1709 yyerror(_("virtual method without 'self' as "
1710 "first parameter"));
1711 free_all_global_state();
1714 if(the_scope == CLASS_SCOPE) {
1715 yyerror(_("a method cannot be of class scope"));
1716 free_all_global_state();
1719 push_function(the_scope, VIRTUAL_METHOD, NULL, $<id>4,
1721 ccode_line, vararg, NULL);
1723 | VIRTUAL type TOKEN '(' funcargs ')' returnvals codenocode {
1725 yyerror(_("virtual method without 'self' as "
1726 "first parameter"));
1727 free_all_global_state();
1730 push_function(PUBLIC_SCOPE, VIRTUAL_METHOD, NULL,
1731 $<id>3, $<cbuf>8, $<line>1,
1732 ccode_line, vararg, NULL);
1734 | OVERRIDE '(' TYPETOKEN ')' type TOKEN '(' funcargs ')' returnvals codenocode {
1735 push_function(NO_SCOPE, OVERRIDE_METHOD, $<id>3,
1737 $<line>1, ccode_line,
1740 | scope type TOKEN '(' funcargs ')' returnvals codenocode {
1741 if(the_scope == CLASS_SCOPE) {
1742 yyerror(_("a method cannot be of class scope"));
1743 free_all_global_state();
1746 push_function(the_scope, REGULAR_METHOD, NULL, $<id>3,
1747 $<cbuf>8, $<line>1, ccode_line,
1750 | TOKEN '(' TOKEN ')' codenocode {
1751 if(strcmp($<id>1, "init")==0) {
1752 push_init_arg($<id>3,FALSE);
1753 push_function(NO_SCOPE, INIT_METHOD, NULL,
1754 $<id>1, $<cbuf>5, $<line>2,
1755 ccode_line, FALSE, NULL);
1756 } else if(strcmp($<id>1, "class_init")==0) {
1757 push_init_arg($<id>3,TRUE);
1758 push_function(NO_SCOPE, CLASS_INIT_METHOD, NULL,
1759 $<id>1, $<cbuf>5, $<line>2,
1760 ccode_line, FALSE, NULL);
1764 g_string_free($<cbuf>5,TRUE);
1765 yyerror(_("parse error "
1766 "(untyped blocks must be init or "
1773 returnvals: TOKEN retcode {
1774 g_free(onerror); onerror = NULL;
1775 g_free(defreturn); defreturn = NULL;
1776 if(!set_return_value($<id>1, $<id>2)) {
1779 yyerror(_("parse error"));
1784 | TOKEN retcode TOKEN retcode {
1785 g_free(onerror); onerror = NULL;
1786 g_free(defreturn); defreturn = NULL;
1787 if(!set_return_value($<id>1, $<id>2)) {
1788 g_free($<id>1); g_free($<id>2);
1789 g_free($<id>3); g_free($<id>4);
1790 yyerror(_("parse error"));
1793 if(!set_return_value($<id>3, $<id>4)) {
1794 onerror = defreturn = NULL;
1795 g_free($<id>1); g_free($<id>2);
1796 g_free($<id>3); g_free($<id>4);
1797 yyerror(_("parse error"));
1804 g_free(onerror); onerror = NULL;
1805 g_free(defreturn); defreturn = NULL;
1809 retcode: numtok { $<id>$ = $<id>1; }
1811 $<id>$ = ($<cbuf>2)->str;
1812 g_string_free($<cbuf>2, FALSE);
1816 funcargs: VOID { vararg = FALSE; has_self = FALSE; }
1820 if(strcmp($<id>1,"self")==0)
1821 push_self($<id>1, FALSE);
1824 yyerror(_("parse error"));
1831 if(strcmp($<id>1,"self")==0)
1832 push_self($<id>1, TRUE);
1835 yyerror(_("parse error"));
1842 if(strcmp($<id>2,"self")==0)
1843 push_self($<id>2, TRUE);
1846 yyerror(_("parse error"));
1850 | TOKEN ',' arglist {
1852 if(strcmp($<id>1,"self")==0)
1853 push_self($<id>1, FALSE);
1856 yyerror(_("parse error"));
1860 | TOKEN CONST ',' arglist {
1862 if(strcmp($<id>1,"self")==0)
1863 push_self($<id>1, TRUE);
1866 yyerror(_("parse error"));
1870 | CONST TOKEN ',' arglist {
1872 if(strcmp($<id>2,"self")==0)
1873 push_self($<id>2, TRUE);
1876 yyerror(_("parse error"));
1880 | arglist { has_self = FALSE; }
1883 arglist: arglist1 ',' THREEDOTS { vararg = TRUE; }
1884 | arglist1 { vararg = FALSE; }
1887 arglist1: arglist1 ',' arg { ; }
1892 push_funcarg($<id>2,NULL);
1894 | type TOKEN ARRAY_DIM {
1895 push_funcarg($<id>2,$<id>3);
1897 | type TOKEN '(' TOKEN checklist ')' {
1898 if(strcmp($<id>4,"check")!=0) {
1899 yyerror(_("parse error"));
1903 push_funcarg($<id>2,NULL);
1905 | type TOKEN ARRAY_DIM '(' TOKEN checklist ')' {
1906 if(strcmp($<id>5,"check")!=0) {
1907 yyerror(_("parse error"));
1911 push_funcarg($<id>2,$<id>3);
1915 checklist: checklist check { ; }
1920 if(strcmp($<id>1,"type")==0) {
1921 Node *node = node_new (CHECK_NODE,
1922 "chtype", TYPE_CHECK,
1924 checks = g_list_append(checks,node);
1925 } else if(strcmp($<id>1,"null")==0) {
1926 Node *node = node_new (CHECK_NODE,
1927 "chtype", NULL_CHECK,
1929 checks = g_list_append(checks,node);
1931 yyerror(_("parse error"));
1937 Node *node = node_new (CHECK_NODE,
1939 "number:steal", $<id>2,
1941 checks = g_list_append(checks,node);
1944 Node *node = node_new (CHECK_NODE,
1946 "number:steal", $<id>2,
1948 checks = g_list_append(checks,node);
1951 Node *node = node_new (CHECK_NODE,
1953 "number:steal", $<id>3,
1955 checks = g_list_append(checks,node);
1958 Node *node = node_new (CHECK_NODE,
1960 "number:steal", $<id>3,
1962 checks = g_list_append(checks,node);
1965 Node *node = node_new (CHECK_NODE,
1967 "number:steal", $<id>3,
1969 checks = g_list_append(checks,node);
1972 Node *node = node_new (CHECK_NODE,
1974 "number:steal", $<id>3,
1976 checks = g_list_append(checks,node);
1980 enumcode: ENUM TOKEN '{' enumvals '}' TYPETOKEN ';' {
1981 Node *node = node_new (ENUMDEF_NODE,
1982 "etype:steal", $<id>6,
1983 "prefix:steal", $<id>2,
1984 "values:steal", enum_vals,
1987 nodes = g_list_append (nodes, node);
1989 | ENUM TOKEN '{' enumvals ',' '}' TYPETOKEN ';' {
1990 Node *node = node_new (ENUMDEF_NODE,
1991 "etype:steal", $<id>7,
1992 "prefix:steal", $<id>2,
1993 "values:steal", enum_vals,
1996 nodes = g_list_append (nodes, node);
2000 enumvals: enumvals ',' enumval {;}
2004 enumval: TOKEN '=' numtok {
2008 /* A float value, that's a bad enum */
2009 if (num[0] >= '0' &&
2011 strchr (num, '.') != NULL) {
2014 yyerror(_("parse error (enumerator value not integer constant)"));
2018 node = node_new (ENUMVALUE_NODE,
2019 "name:steal", $<id>1,
2022 enum_vals = g_list_append (enum_vals, node);
2027 node = node_new (ENUMVALUE_NODE,
2028 "name:steal", $<id>1,
2030 enum_vals = g_list_append (enum_vals, node);
2034 flagcode: FLAGS TOKEN '{' flagvals '}' TYPETOKEN ';' {
2035 Node *node = node_new (FLAGS_NODE,
2036 "ftype:steal", $<id>6,
2037 "prefix:steal", $<id>2,
2038 "values:steal", flag_vals,
2041 nodes = g_list_append (nodes, node);
2043 | FLAGS TOKEN '{' flagvals ',' '}' TYPETOKEN ';' {
2044 Node *node = node_new (FLAGS_NODE,
2045 "ftype:steal", $<id>7,
2046 "prefix:steal", $<id>2,
2047 "values:steal", flag_vals,
2050 nodes = g_list_append (nodes, node);
2054 flagvals: flagvals ',' TOKEN {
2055 flag_vals = g_list_append (flag_vals, $<id>3);
2058 flag_vals = g_list_append (flag_vals, $<id>1);
2062 errorcode: ERROR TOKEN '{' errorvals '}' TYPETOKEN ';' {
2063 Node *node = node_new (ERROR_NODE,
2064 "etype:steal", $<id>6,
2065 "prefix:steal", $<id>2,
2066 "values:steal", error_vals,
2069 nodes = g_list_append (nodes, node);
2071 | ERROR TOKEN '{' errorvals ',' '}' TYPETOKEN ';' {
2072 Node *node = node_new (ERROR_NODE,
2073 "etype:steal", $<id>7,
2074 "prefix:steal", $<id>2,
2075 "values:steal", error_vals,
2078 nodes = g_list_append (nodes, node);
2082 errorvals: errorvals ',' TOKEN {
2083 error_vals = g_list_append (error_vals, $<id>3);
2086 error_vals = g_list_append (error_vals, $<id>1);
2091 numtok: NUMBER { $<id>$ = $<id>1; }
2093 $<id>$ = g_strconcat("-",$<id>2,NULL);
2096 | SINGLE_CHAR { $<id>$ = $<id>1; }
2097 | TOKEN { $<id>$ = $<id>1; }