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 gboolean abstract = FALSE;
48 static char *chunk_size = NULL;
49 static char *bonobo_object_class = NULL;
50 static int glade_xml = FALSE;
51 static GList *interfaces = NULL;
52 static GList *typestack = NULL;
53 static GList *funcargs = NULL;
54 static GList *checks = NULL;
55 static int has_self = FALSE;
56 static int vararg = FALSE;
57 static Method *last_added_method = NULL;
59 /* destructor and initializer for variables */
60 static gboolean destructor_unref = FALSE;
61 static char *destructor = NULL;
62 static int destructor_line = 0;
63 static gboolean destructor_simple = TRUE;
64 static char *initializer = NULL;
65 static int initializer_line = 0;
66 static int glade_widget = FALSE;
68 static char *onerror = NULL;
69 static char *defreturn = NULL;
71 static GList *gtktypes = NULL;
73 static Property *property = NULL;
75 /* this can be a global as we will only do one function at a time
77 static int the_scope = NO_SCOPE;
82 extern int ccode_line;
84 extern gboolean for_cpp;
94 if(strcmp(yytext,"\n")==0) {
95 out=g_strconcat("Error: ",str," before newline",NULL);
96 } else if(yytext[0]=='\0') {
97 out=g_strconcat("Error: ", str, " at end of input", NULL);
99 char *tmp = g_strdup(yytext);
100 while((p=strchr(tmp, '\n')))
103 out=g_strconcat("Error: ", str, " before '", tmp, "'", NULL);
107 fprintf(stderr, "%s:%d: %s\n", filename, line_no, out);
116 Type *type = typestack->data;
117 typestack = g_list_remove(typestack,typestack->data);
122 push_variable (char *name, int scope, int line_no, char *postfix)
125 Type *type = pop_type ();
127 type->postfix = postfix;
129 var = node_new (VARIABLE_NODE,
132 "glade_widget", glade_widget,
135 "destructor_unref", destructor_unref,
136 "destructor:steal", destructor,
137 "destructor_line", destructor_line,
138 "destructor_simple", destructor_simple,
139 "initializer:steal", initializer,
140 "initializer_line", initializer_line,
141 "initializer_simple", TRUE,
143 class_nodes = g_list_append(class_nodes, var);
144 glade_widget = FALSE;
148 push_function (int scope, int method, char *oid, char *id,
149 GString *cbuf, int line_no, int ccode_line,
150 gboolean vararg, GList *flags)
156 g_assert(scope != CLASS_SCOPE);
158 if(method == INIT_METHOD || method == CLASS_INIT_METHOD) {
159 type = (Type *)node_new (TYPE_NODE,
166 /* a complicated and ugly test to figure out if we have
167 the wrong number of types for a signal */
168 if((method == SIGNAL_FIRST_METHOD ||
169 method == SIGNAL_LAST_METHOD) &&
170 g_list_length(gtktypes) != g_list_length(funcargs) &&
171 !(g_list_length(funcargs) == 1 &&
172 g_list_length(gtktypes) == 2 &&
173 strcmp(gtktypes->next->data, "NONE")==0)) {
174 error_print(GOB_WARN, line_no,
175 _("The number of GTK arguments and "
176 "function arguments for a signal "
177 "don't seem to match"));
179 if(g_list_length(gtktypes) > 2) {
181 for(li = gtktypes->next; li; li = li->next) {
182 if(strcmp(li->data, "NONE")==0) {
183 error_print(GOB_ERROR, line_no,
184 _("NONE can only appear in an "
185 "argument list by itself"));
191 c_cbuf = p = cbuf->str;
192 while(p && *p && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
199 node = node_new (METHOD_NODE,
204 "gtktypes:steal", gtktypes,
205 "flags:steal", flags,
207 "args:steal", funcargs,
208 "onerror:steal", onerror,
209 "defreturn:steal", defreturn,
210 "cbuf:steal", c_cbuf,
212 "ccode_line", ccode_line,
214 "unique_id", method_unique_id++,
217 last_added_method = (Method *)node;
221 /*only free segment if we haven't passed it
230 class_nodes = g_list_append(class_nodes, node);
234 free_all_global_state(void)
244 g_list_foreach(gtktypes, (GFunc)g_free, NULL);
245 g_list_free(gtktypes);
248 node_list_free (funcargs);
253 push_funcarg(char *name, char *postfix)
256 Type *type = pop_type();
258 type->postfix = postfix;
260 node = node_new (FUNCARG_NODE,
263 "checks:steal", checks,
267 funcargs = g_list_append(funcargs, node);
271 push_init_arg(char *name, int is_class)
278 tn = g_strconcat(((Class *)class)->otype,":Class",NULL);
280 tn = g_strdup(((Class *)class)->otype);
282 type = node_new (TYPE_NODE,
286 node = node_new (FUNCARG_NODE,
287 "atype:steal", (Type *)type,
290 funcargs = g_list_prepend(funcargs, node);
294 push_self(char *id, gboolean constant)
299 type = node_new (TYPE_NODE,
300 "name", ((Class *)class)->otype,
301 "pointer", constant ? "const *" : "*",
303 ch = g_list_append (ch, node_new (CHECK_NODE,
304 "chtype", NULL_CHECK,
306 ch = g_list_append (ch, node_new (CHECK_NODE,
307 "chtype", TYPE_CHECK,
309 node = node_new (FUNCARG_NODE,
310 "atype:steal", (Type *)type,
314 funcargs = g_list_prepend(funcargs, node);
318 find_var_or_die(const char *id, int line)
322 for(li = class_nodes; li != NULL; li = li->next) {
324 Node *node = li->data;
325 if(node->type != VARIABLE_NODE)
328 if(strcmp(var->id, id)==0)
332 error_printf(GOB_ERROR, line, _("Variable %s not defined here"), id);
334 g_assert_not_reached();
339 set_return_value(char *type, char *val)
341 if(strcmp(type, "onerror")==0) {
347 } else if(strcmp(type, "defreturn")==0) {
358 export_accessors (const char *var_name,
370 the_type = (Type *)node_copy ((Node *)type);
372 the_type = get_tree_type (gtktype, TRUE);
374 if (the_type == NULL) {
375 error_print (GOB_ERROR, line_no,
376 _("Cannot determine type of property or argument"));
381 char *get_id = g_strdup_printf ("get_%s", var_name);
382 GString *get_cbuf = g_string_new (NULL);
383 Node *node1 = node_new (TYPE_NODE,
384 "name", the_type->name,
385 "pointer", the_type->pointer,
386 "postfix", the_type->postfix,
388 Node *node3 = node_new (TYPE_NODE,
389 "name", class->class.otype,
393 g_string_sprintf (get_cbuf,
395 "g_object_get (G_OBJECT (self), \"%s\", "
399 the_type->pointer ? the_type->pointer : "",
402 typestack = g_list_prepend (typestack, node1);
403 typestack = g_list_prepend (typestack, node3);
405 push_funcarg ("self", FALSE);
407 push_function (PUBLIC_SCOPE, REGULAR_METHOD, NULL,
408 get_id, get_cbuf, get_lineno,
409 lineno, FALSE, NULL);
413 char *set_id = g_strdup_printf ("set_%s", var_name);
414 GString *set_cbuf = g_string_new (NULL);
415 Node *node1 = node_new (TYPE_NODE,
416 "name", the_type->name,
417 "pointer", the_type->pointer,
418 "postfix", the_type->postfix,
420 Node *node2 = node_new (TYPE_NODE,
423 Node *node3 = node_new (TYPE_NODE,
424 "name", class->class.otype,
428 g_string_sprintf (set_cbuf,
429 "\tg_object_set (G_OBJECT (self), "
430 "\"%s\", val, NULL);\n",
433 typestack = g_list_prepend (typestack, node2);
434 typestack = g_list_prepend (typestack, node1);
435 typestack = g_list_prepend (typestack, node3);
437 push_funcarg ("self", FALSE);
438 push_funcarg ("val", FALSE);
440 typestack = g_list_prepend (typestack, node2);
441 push_function (PUBLIC_SCOPE, REGULAR_METHOD, NULL,
442 set_id, set_cbuf, set_lineno,
443 lineno, FALSE, NULL);
446 node_free ((Node *)the_type);
450 get_prop_enum_flag_cast (Property *prop)
453 if (prop->extra_gtktype == NULL ||
454 /* HACK! just in case someone made this
455 * work with 2.0.0 by using the TYPE
457 ((strstr (prop->extra_gtktype, "_TYPE_") != NULL ||
458 strstr (prop->extra_gtktype, "TYPE_") == prop->extra_gtktype) &&
459 strchr (prop->extra_gtktype, ':') == NULL)) {
460 if (prop->ptype != NULL)
461 return get_type (prop->ptype, TRUE);
463 return g_strdup ("");
465 tmp = remove_sep (prop->extra_gtktype);
466 ret = g_strdup_printf ("(%s) ", tmp);
472 add_construct_glade (char * file, char * root, char * domain)
476 GList * flags = NULL;
478 type = (Type *)node_new (TYPE_NODE,
482 initializer = g_strdup_printf("\t{\n"
483 "\tGtkWidget * root;\n"
484 "\t%%1$s->_priv->_glade_xml = glade_xml_new(%s, %s, %s);\n"
485 "\troot = glade_xml_get_widget(%%1$s->_priv->_glade_xml, %s);\n"
486 "\tgtk_widget_show(root);\n"
487 "\tgtk_container_add(GTK_CONTAINER(%%1$s), root);\n"
488 "\tglade_xml_signal_autoconnect_full(%%1$s->_priv->_glade_xml, (GladeXMLConnectFunc)___glade_xml_connect_foreach, (gpointer)%%1$s);\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,
781 "abstract", abstract,
783 bonobo_object_class = NULL;
791 | '(' TOKEN ')' classflags {
792 if(strcmp($<id>2,"abstract") == 0) {
795 yyerror(_("parse error"));
799 | '(' TOKEN TOKEN ')' classflags {
800 if(strcmp($<id>2,"chunks") == 0) {
802 chunk_size = g_strdup($<id>3);
803 } else if(strcmp($<id>2,"BonoboObject") == 0) {
804 g_free (bonobo_object_class);
805 bonobo_object_class = g_strdup($<id>3);
807 yyerror(_("parse error"));
811 | '(' TOKEN TYPETOKEN ')' classflags {
812 if (strcmp ($<id>2, "interface") == 0) {
813 interfaces = g_list_append (interfaces,
816 yyerror(_("parse error"));
820 | '(' TOKEN NUMBER ')' classflags {
821 if(strcmp($<id>2,"chunks") == 0) {
823 if(atoi($<id>3) != 0)
824 chunk_size = g_strdup($<id>3);
828 yyerror(_("parse error"));
832 | '(' TOKEN STRING STRING ')' classflags {
833 if (strcmp ($<id>2, "GladeXML") == 0) {
835 add_construct_glade($<id>3, $<id>4, NULL);
837 yyerror(_("parse error"));
841 | '(' TOKEN STRING STRING STRING ')' classflags {
842 if (strcmp ($<id>2, "GladeXML") == 0) {
844 add_construct_glade($<id>3, $<id>4, $<id>5);
846 yyerror(_("parse error"));
850 | '(' TOKEN TOKEN STRING ')' classflags {
851 if (strcmp ($<id>2, "GladeXML") == 0) {
853 add_construct_glade($<id>3, $<id>4, NULL);
855 yyerror(_("parse error"));
859 | '(' TOKEN TOKEN STRING STRING ')' classflags {
860 if (strcmp ($<id>2, "GladeXML") == 0) {
862 add_construct_glade($<id>3, $<id>4, $<id>5);
864 yyerror(_("parse error"));
870 classcode: classcode thing { ; }
876 if (strcmp ($<id>1, "BonoboObject") != 0) {
878 yyerror (_("parse error"));
882 last_added_method->bonobo_object_func = TRUE;
884 | TOKEN TYPETOKEN method {
885 if (strcmp ($<id>1, "interface") != 0) {
888 yyerror (_("parse error"));
892 node_set ((Node *)last_added_method,
893 "interface:steal", $<id>2,
902 scope: PUBLIC { the_scope = PUBLIC_SCOPE; }
903 | PRIVATE { the_scope = PRIVATE_SCOPE; }
904 | PROTECTED { the_scope = PROTECTED_SCOPE; }
905 | CLASSWIDE { the_scope = CLASS_SCOPE; }
908 destructor: TOKEN TOKEN {
909 if (strcmp ($<id>1, "destroywith") == 0) {
911 destructor_unref = FALSE;
913 destructor_line = line_no;
914 destructor_simple = TRUE;
915 } else if (strcmp ($<id>1, "unrefwith") == 0) {
917 destructor_unref = TRUE;
919 destructor_line = line_no;
920 destructor_simple = TRUE;
924 yyerror (_("parse error"));
929 if (strcmp ($<id>1, "destroy") == 0) {
931 destructor_unref = FALSE;
932 destructor = ($<cbuf>3)->str;
933 g_string_free($<cbuf>3, FALSE);
934 destructor_line = ccode_line;
935 destructor_simple = FALSE;
936 } else if (strcmp ($<id>1, "unref") == 0) {
938 destructor_unref = TRUE;
939 destructor = ($<cbuf>3)->str;
940 g_string_free ($<cbuf>3, FALSE);
941 destructor_line = ccode_line;
942 destructor_simple = FALSE;
945 g_string_free ($<cbuf>3, TRUE);
946 yyerror (_("parse error"));
952 initializer: '=' numtok {
953 initializer = $<id>2;
954 initializer_line = ccode_line;
957 initializer = ($<cbuf>3)->str;
958 initializer_line = ccode_line;
959 g_string_free($<cbuf>3, FALSE);
964 varoptions: destructor initializer { ; }
965 | initializer destructor { ; }
966 | initializer { destructor = NULL; }
967 | destructor { initializer = NULL; }
969 if (strcmp ($<id>1, "GladeXML") == 0) {
972 yyerror(_("parse error"));
982 variable: scope type TOKEN varoptions ';' {
983 push_variable($<id>3, the_scope,$<line>1, NULL);
985 | scope type TOKEN ARRAY_DIM varoptions ';' {
986 push_variable($<id>3, the_scope, $<line>1, $<id>4);
990 argument: ARGUMENT flags argtype TOKEN export TOKEN '{' CCODE TOKEN '{' CCODE ';' {
992 if(strcmp($<id>6,"get")==0 &&
993 strcmp($<id>9,"set")==0) {
994 Type *type = pop_type();
997 node = node_new (ARGUMENT_NODE,
998 "gtktype:steal", $<id>3,
1000 "flags:steal", $<list>2,
1001 "name:steal", $<id>4,
1002 "get:steal", ($<cbuf>8)->str,
1003 "get_line", $<line>7,
1004 "set:steal", ($<cbuf>11)->str,
1005 "set_line", $<line>10,
1006 "line_no", $<line>1,
1009 class_nodes = g_list_append(class_nodes,node);
1011 g_string_free ($<cbuf>8, FALSE);
1012 g_string_free ($<cbuf>11, FALSE);
1014 } else if(strcmp($<id>6,"set")==0 &&
1015 strcmp($<id>9,"get")==0) {
1016 Type *type = pop_type();
1019 node = node_new (ARGUMENT_NODE,
1020 "gtktype:steal", $<id>3,
1021 "atype:steal", type,
1022 "flags:steal", $<list>2,
1023 "name:steal", $<id>4,
1024 "get:steal", ($<cbuf>11)->str,
1025 "get_line", $<line>10,
1026 "set:steal", ($<cbuf>8)->str,
1027 "set_line", $<line>7,
1028 "line_no", $<line>1,
1030 g_string_free ($<cbuf>11, FALSE);
1031 g_string_free ($<cbuf>8, FALSE);
1032 class_nodes = g_list_append(class_nodes,node);
1038 g_list_foreach ($<list>2, (GFunc)g_free, NULL);
1039 g_list_free ($<list>2);
1040 g_string_free ($<cbuf>11, TRUE);
1041 g_string_free ($<cbuf>8, TRUE);
1042 yyerror (_("parse error"));
1046 if ($<id>5 != NULL) {
1047 Argument *arg = (Argument *)node;
1048 export_accessors (arg->name,
1049 arg->get != NULL, arg->get_line,
1050 arg->set != NULL, arg->set_line,
1058 | ARGUMENT flags argtype TOKEN export TOKEN '{' CCODE ';' {
1060 if(strcmp($<id>6, "get") == 0) {
1061 Type *type = pop_type();
1063 node = node_new (ARGUMENT_NODE,
1064 "gtktype:steal", $<id>3,
1065 "atype:steal", type,
1066 "flags:steal", $<list>2,
1067 "name:steal", $<id>4,
1068 "get:steal", ($<cbuf>8)->str,
1069 "get_line", $<line>7,
1070 "line_no", $<line>1,
1073 g_string_free ($<cbuf>8, FALSE);
1074 class_nodes = g_list_append(class_nodes, node);
1075 } else if(strcmp($<id>6, "set") == 0) {
1076 Type *type = pop_type();
1078 node = node_new (ARGUMENT_NODE,
1079 "gtktype:steal", $<id>3,
1080 "atype:steal", type,
1081 "flags:steal", $<list>2,
1082 "name:steal", $<id>4,
1083 "set:steal", ($<cbuf>8)->str,
1084 "set_line", $<line>7,
1085 "line_no", $<line>1,
1088 g_string_free ($<cbuf>8, FALSE);
1089 class_nodes = g_list_append (class_nodes, node);
1094 g_list_foreach ($<list>2, (GFunc)g_free, NULL);
1095 g_list_free ($<list>2);
1096 g_string_free ($<cbuf>8, TRUE);
1097 yyerror(_("parse error"));
1101 if ($<id>5 != NULL) {
1102 Argument *arg = (Argument *)node;
1103 export_accessors (arg->name,
1104 arg->get != NULL, arg->get_line,
1105 arg->set != NULL, arg->set_line,
1112 | ARGUMENT flags argtype TOKEN export TOKEN {
1114 char *get, *set = NULL;
1119 if(strcmp($<id>6, "link")!=0 &&
1120 strcmp($<id>6, "stringlink")!=0 &&
1121 strcmp($<id>6, "objectlink")!=0) {
1125 g_list_foreach($<list>2,(GFunc)g_free,NULL);
1126 g_list_free($<list>2);
1127 yyerror(_("parse error"));
1133 var = find_var_or_die($<id>4, $<line>1);
1134 if(var->scope == PRIVATE_SCOPE) {
1135 root = "self->_priv";
1136 } else if(var->scope == CLASS_SCOPE) {
1137 root = "SELF_GET_CLASS(self)";
1139 error_print(GOB_ERROR, $<line>1,
1140 _("Self aliases needed when autolinking to a classwide member"));
1145 if(strcmp($<id>6, "link")==0) {
1146 set = g_strdup_printf("%s->%s = ARG;",
1148 } else if(strcmp($<id>6, "stringlink")==0) {
1149 set = g_strdup_printf("g_free (%s->%s); "
1150 "%s->%s = g_strdup (ARG);",
1153 } else if(strcmp($<id>6, "objectlink")==0) {
1154 set = g_strdup_printf(
1156 "g_object_ref (G_OBJECT (ARG)); "
1157 "if (%s->%s != NULL) "
1158 "g_object_unref (G_OBJECT (%s->%s)); "
1164 g_assert_not_reached();
1167 get = g_strdup_printf("ARG = %s->%s;", root, $<id>4);
1172 type = (Type *)node_copy ((Node *)var->vtype);
1174 node = node_new (ARGUMENT_NODE,
1175 "gtktype:steal", $<id>3,
1176 "atype:steal", type,
1177 "flags:steal", $<list>2,
1178 "name:steal", $<id>4,
1180 "get_line", $<line>1,
1182 "set_line", $<line>1,
1183 "line_no", $<line>1,
1186 if ($<id>5 != NULL) {
1187 Argument *arg = (Argument *)node;
1188 export_accessors (arg->name,
1189 arg->get != NULL, arg->get_line,
1190 arg->set != NULL, arg->set_line,
1197 class_nodes = g_list_append (class_nodes, node);
1201 export: '(' TOKEN ')' {
1202 if (strcmp ($<id>2, "export")!=0) {
1204 yyerror (_("parse error"));
1214 property: PROPERTY TOKEN TOKEN param_spec TOKEN '{' CCODE TOKEN '{' CCODE ';' {
1216 node_set ((Node *)property,
1217 "line_no", $<line>1,
1218 "gtktype:steal", debool ($<id>2),
1219 "name:steal", $<id>3,
1221 if (strcmp ($<id>5, "get") == 0 &&
1222 strcmp ($<id>8, "set") == 0) {
1223 node_set ((Node *)property,
1224 "get:steal", ($<cbuf>7)->str,
1225 "get_line", $<line>6,
1226 "set:steal", ($<cbuf>10)->str,
1227 "set_line", $<line>9,
1229 g_string_free ($<cbuf>7, FALSE);
1230 g_string_free ($<cbuf>10, FALSE);
1233 } else if (strcmp ($<id>5, "set") == 0 &&
1234 strcmp ($<id>8, "get") == 0) {
1235 node_set ((Node *)property,
1236 "get:steal", ($<cbuf>10)->str,
1237 "get_line", $<line>9,
1238 "set:steal", ($<cbuf>7)->str,
1239 "set_line", $<line>6,
1241 g_string_free ($<cbuf>7, FALSE);
1242 g_string_free ($<cbuf>10, FALSE);
1246 g_string_free ($<cbuf>7, TRUE);
1247 g_string_free ($<cbuf>10, TRUE);
1250 node_free ((Node *)property);
1252 yyerror (_("parse error"));
1255 property_link_and_export ((Node *)property);
1256 if (property != NULL) {
1257 class_nodes = g_list_append (class_nodes,
1262 | PROPERTY TOKEN TOKEN param_spec TOKEN '{' CCODE ';' {
1264 node_set ((Node *)property,
1265 "line_no", $<line>1,
1266 "gtktype:steal", debool ($<id>2),
1267 "name:steal", $<id>3,
1269 if (strcmp ($<id>5, "get") == 0) {
1270 node_set ((Node *)property,
1271 "get:steal", ($<cbuf>7)->str,
1272 "get_line", $<line>6,
1274 g_string_free ($<cbuf>7, FALSE);
1276 } else if (strcmp ($<id>5, "set") == 0) {
1277 node_set ((Node *)property,
1278 "set:steal", ($<cbuf>7)->str,
1279 "set_line", $<line>6,
1281 g_string_free ($<cbuf>7, FALSE);
1284 g_string_free ($<cbuf>7, TRUE);
1286 node_free ((Node *)property);
1288 yyerror (_("parse error"));
1291 property_link_and_export ((Node *)property);
1292 if (property != NULL) {
1293 class_nodes = g_list_append (class_nodes,
1298 | PROPERTY TOKEN TOKEN param_spec ';' {
1300 node_set ((Node *)property,
1301 "line_no", $<line>1,
1302 "gtktype:steal", debool ($<id>2),
1303 "name:steal", $<id>3,
1305 property_link_and_export ((Node *)property);
1306 if (property != NULL) {
1307 class_nodes = g_list_append (class_nodes,
1314 param_spec: '(' param_spec_list ')' { ; }
1318 param_spec_list: param_spec_list ',' param_spec_value { ; }
1319 | param_spec_value { ; }
1322 string: STRING { $<id>$ = $<id>1; }
1323 | TOKEN '(' STRING ')' {
1324 if (strcmp ($<id>1, "_") != 0) {
1326 yyerror(_("parse error"));
1330 $<id>$ = g_strconcat ("_(", $<id>3, ")", NULL);
1335 anyval: numtok { $<id>$ = $<id>1; }
1336 | string { $<id>$ = $<id>1; }
1339 param_spec_value: NICK '=' string {
1341 node_set ((Node *)property,
1342 "nick:steal", $<id>3,
1345 | BLURB '=' string {
1347 node_set ((Node *)property,
1348 "blurb:steal", $<id>3,
1351 | MAXIMUM '=' numtok {
1353 node_set ((Node *)property,
1354 "maximum:steal", $<id>3,
1357 | MINIMUM '=' numtok {
1359 node_set ((Node *)property,
1360 "minimum:steal", $<id>3,
1363 | DEFAULT_VALUE '=' anyval {
1365 node_set ((Node *)property,
1366 "default_value:steal", $<id>3,
1369 | FLAGS '=' flaglist {
1371 node_set ((Node *)property,
1372 "flags:steal", $<list>3,
1376 Type *type = pop_type ();
1378 node_set ((Node *)property,
1379 "ptype:steal", type,
1382 | FLAGS_TYPE '=' TYPETOKEN {
1384 node_set ((Node *)property,
1385 "extra_gtktype:steal", $<id>3,
1388 | FLAGS_TYPE '=' TOKEN {
1390 node_set ((Node *)property,
1391 "extra_gtktype:steal", $<id>3,
1394 | ENUM_TYPE '=' TYPETOKEN {
1396 node_set ((Node *)property,
1397 "extra_gtktype:steal", $<id>3,
1400 | ENUM_TYPE '=' TOKEN {
1402 node_set ((Node *)property,
1403 "extra_gtktype:steal", $<id>3,
1406 | PARAM_TYPE '=' TYPETOKEN {
1408 node_set ((Node *)property,
1409 "extra_gtktype:steal", $<id>3,
1412 | PARAM_TYPE '=' TOKEN {
1414 node_set ((Node *)property,
1415 "extra_gtktype:steal", $<id>3,
1418 | BOXED_TYPE '=' TYPETOKEN {
1420 node_set ((Node *)property,
1421 "extra_gtktype:steal", $<id>3,
1424 | BOXED_TYPE '=' TOKEN {
1426 node_set ((Node *)property,
1427 "extra_gtktype:steal", $<id>3,
1430 | OBJECT_TYPE '=' TYPETOKEN {
1432 node_set ((Node *)property,
1433 "extra_gtktype:steal", $<id>3,
1436 | OBJECT_TYPE '=' TOKEN {
1438 node_set ((Node *)property,
1439 "extra_gtktype:steal", $<id>3,
1444 if (strcmp ($<id>1, "override") == 0) {
1446 node_set ((Node *)property,
1449 } else if (strcmp ($<id>1, "link") == 0) {
1451 node_set ((Node *)property,
1454 } else if (strcmp ($<id>1, "export") == 0) {
1456 node_set ((Node *)property,
1461 yyerror(_("parse error"));
1467 argtype: TOKEN '(' TOKEN type ')' {
1468 if(strcmp($<id>3,"type")!=0) {
1471 yyerror(_("parse error"));
1474 $<id>$ = debool ($<id>1);
1477 $<id>$ = debool ($<id>1);
1478 typestack = g_list_prepend(typestack,NULL);
1482 flags: '(' flaglist ')' { $<list>$ = $<list>2; }
1483 | { $<list>$ = NULL; }
1486 flaglist: TOKEN '|' flaglist {
1487 $<list>$ = g_list_append($<list>3,$<id>1);
1490 $<list>$ = g_list_append(NULL,$<id>1);
1495 type: specifier_list pointer {
1496 Node *node = node_new (TYPE_NODE,
1497 "name:steal", $<id>1,
1498 "pointer:steal", $<id>2,
1500 typestack = g_list_prepend(typestack,node);
1503 Node *node = node_new (TYPE_NODE,
1504 "name:steal", $<id>1,
1506 typestack = g_list_prepend(typestack,node);
1510 /* The special cases are neccessary to avoid conflicts */
1511 specifier_list: spec_list {
1518 $<id>$ = g_strconcat("const ", $<id>2, NULL);
1522 $<id>$ = g_strconcat($<id>1, " const", NULL);
1525 | strunionenum TOKEN {
1526 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
1529 | CONST strunionenum TOKEN {
1530 $<id>$ = g_strconcat("const ", $<id>2, " ",
1534 | strunionenum TOKEN CONST {
1535 $<id>$ = g_strconcat($<id>1, " ",
1536 $<id>2, " const", NULL);
1541 /* The special const cases take care of conflicts ! */
1542 spec_list: specifier spec_list {
1543 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
1546 | TYPETOKEN spec_list {
1547 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
1552 $<id>$ = g_strconcat("const ", $<id>2, NULL);
1559 $<id>$ = g_strconcat($<id>1, " const", NULL);
1563 $<id>$ = g_strdup($<id>1);
1566 $<id>$ = g_strconcat($<id>1, " const", NULL);
1570 specifier: VOID { $<id>$ = "void"; }
1571 | CHAR { $<id>$ = "char"; }
1572 | SHORT { $<id>$ = "short"; }
1573 | INT { $<id>$ = "int"; }
1574 | LONG { $<id>$ = "long"; }
1575 | FLOAT { $<id>$ = "float"; }
1576 | DOUBLE { $<id>$ = "double"; }
1577 | SIGNED { $<id>$ = "signed"; }
1578 | UNSIGNED { $<id>$ = "unsigned"; }
1581 strunionenum: STRUCT { $<id>$ = "struct"; }
1582 | UNION { $<id>$ = "union"; }
1583 | ENUM { $<id>$ = "enum"; }
1586 pointer: '*' { $<id>$ = g_strdup("*"); }
1587 | '*' CONST { $<id>$ = g_strdup("* const"); }
1589 $<id>$ = g_strconcat("*", $<id>2, NULL);
1592 | '*' CONST pointer {
1593 $<id>$ = g_strconcat("* const", $<id>3, NULL);
1598 /* this never sets the_scope */
1599 simplesigtype: TOKEN sigtype {
1600 if(strcmp($<id>1, "first")==0)
1601 $<sigtype>$ = SIGNAL_FIRST_METHOD;
1602 else if(strcmp($<id>1, "last")==0)
1603 $<sigtype>$ = SIGNAL_LAST_METHOD;
1605 yyerror(_("signal must be 'first' or 'last'"));
1612 $<sigtype>$ = SIGNAL_LAST_METHOD;
1616 /* this always sets the_scope */
1617 fullsigtype: scope TOKEN sigtype {
1618 if(strcmp($<id>2,"first")==0)
1619 $<sigtype>$ = SIGNAL_FIRST_METHOD;
1620 else if(strcmp($<id>2,"last")==0)
1621 $<sigtype>$ = SIGNAL_LAST_METHOD;
1623 yyerror(_("signal must be 'first' or 'last'"));
1629 | TOKEN scope sigtype {
1630 if(strcmp($<id>1,"first")==0)
1631 $<sigtype>$ = SIGNAL_FIRST_METHOD;
1632 else if(strcmp($<id>1,"last")==0)
1633 $<sigtype>$ = SIGNAL_LAST_METHOD;
1635 yyerror(_("signal must be 'first' or 'last'"));
1642 $<sigtype>$ = SIGNAL_LAST_METHOD;
1645 /* the_scope was default thus public */
1646 the_scope = PUBLIC_SCOPE;
1650 sigtype: TOKEN '(' tokenlist ')' {
1651 gtktypes = g_list_prepend(gtktypes, debool ($<id>1));
1655 tokenlist: tokenlist ',' TOKEN {
1656 gtktypes = g_list_append(gtktypes, debool ($<id>3));
1659 gtktypes = g_list_append(gtktypes, debool ($<id>1));
1663 codenocode: '{' CCODE { $<cbuf>$ = $<cbuf>2; }
1664 | ';' { $<cbuf>$ = NULL; }
1667 /*here CCODE will include the ending '}' */
1668 method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' returnvals codenocode {
1670 yyerror(_("signal without 'self' as "
1671 "first parameter"));
1672 free_all_global_state();
1675 if(the_scope == CLASS_SCOPE) {
1676 yyerror(_("a method cannot be of class scope"));
1677 free_all_global_state();
1680 push_function(the_scope, $<sigtype>3,NULL,
1681 $<id>5, $<cbuf>10,$<line>1,
1682 ccode_line, vararg, $<list>2);
1684 | scope SIGNAL flags simplesigtype type TOKEN '(' funcargs ')' returnvals codenocode {
1686 yyerror(_("signal without 'self' as "
1687 "first parameter"));
1688 free_all_global_state();
1691 if(the_scope == CLASS_SCOPE) {
1692 yyerror(_("a method cannot be of class scope"));
1693 free_all_global_state();
1696 push_function(the_scope, $<sigtype>4, NULL,
1697 $<id>6, $<cbuf>11, $<line>2,
1698 ccode_line, vararg, $<list>3);
1700 | VIRTUAL scope type TOKEN '(' funcargs ')' returnvals codenocode {
1702 yyerror(_("virtual method without 'self' as "
1703 "first parameter"));
1704 free_all_global_state();
1707 if(the_scope == CLASS_SCOPE) {
1708 yyerror(_("a method cannot be of class scope"));
1709 free_all_global_state();
1712 push_function(the_scope, VIRTUAL_METHOD, NULL, $<id>4,
1714 ccode_line, vararg, NULL);
1716 | scope VIRTUAL type TOKEN '(' funcargs ')' returnvals codenocode {
1718 yyerror(_("virtual method without 'self' as "
1719 "first parameter"));
1720 free_all_global_state();
1723 if(the_scope == CLASS_SCOPE) {
1724 yyerror(_("a method cannot be of class scope"));
1725 free_all_global_state();
1728 push_function(the_scope, VIRTUAL_METHOD, NULL, $<id>4,
1730 ccode_line, vararg, NULL);
1732 | VIRTUAL type TOKEN '(' funcargs ')' returnvals codenocode {
1734 yyerror(_("virtual method without 'self' as "
1735 "first parameter"));
1736 free_all_global_state();
1739 push_function(PUBLIC_SCOPE, VIRTUAL_METHOD, NULL,
1740 $<id>3, $<cbuf>8, $<line>1,
1741 ccode_line, vararg, NULL);
1743 | OVERRIDE '(' TYPETOKEN ')' type TOKEN '(' funcargs ')' returnvals codenocode {
1744 push_function(NO_SCOPE, OVERRIDE_METHOD, $<id>3,
1746 $<line>1, ccode_line,
1749 | scope type TOKEN '(' funcargs ')' returnvals codenocode {
1750 if(the_scope == CLASS_SCOPE) {
1751 yyerror(_("a method cannot be of class scope"));
1752 free_all_global_state();
1755 push_function(the_scope, REGULAR_METHOD, NULL, $<id>3,
1756 $<cbuf>8, $<line>1, ccode_line,
1759 | TOKEN '(' TOKEN ')' codenocode {
1760 if(strcmp($<id>1, "init")==0) {
1761 push_init_arg($<id>3,FALSE);
1762 push_function(NO_SCOPE, INIT_METHOD, NULL,
1763 $<id>1, $<cbuf>5, $<line>2,
1764 ccode_line, FALSE, NULL);
1765 } else if(strcmp($<id>1, "class_init")==0) {
1766 push_init_arg($<id>3,TRUE);
1767 push_function(NO_SCOPE, CLASS_INIT_METHOD, NULL,
1768 $<id>1, $<cbuf>5, $<line>2,
1769 ccode_line, FALSE, NULL);
1773 g_string_free($<cbuf>5,TRUE);
1774 yyerror(_("parse error "
1775 "(untyped blocks must be init or "
1782 returnvals: TOKEN retcode {
1783 g_free(onerror); onerror = NULL;
1784 g_free(defreturn); defreturn = NULL;
1785 if(!set_return_value($<id>1, $<id>2)) {
1788 yyerror(_("parse error"));
1793 | TOKEN retcode TOKEN retcode {
1794 g_free(onerror); onerror = NULL;
1795 g_free(defreturn); defreturn = NULL;
1796 if(!set_return_value($<id>1, $<id>2)) {
1797 g_free($<id>1); g_free($<id>2);
1798 g_free($<id>3); g_free($<id>4);
1799 yyerror(_("parse error"));
1802 if(!set_return_value($<id>3, $<id>4)) {
1803 onerror = defreturn = NULL;
1804 g_free($<id>1); g_free($<id>2);
1805 g_free($<id>3); g_free($<id>4);
1806 yyerror(_("parse error"));
1813 g_free(onerror); onerror = NULL;
1814 g_free(defreturn); defreturn = NULL;
1818 retcode: numtok { $<id>$ = $<id>1; }
1820 $<id>$ = ($<cbuf>2)->str;
1821 g_string_free($<cbuf>2, FALSE);
1825 funcargs: VOID { vararg = FALSE; has_self = FALSE; }
1829 if(strcmp($<id>1,"self")==0)
1830 push_self($<id>1, FALSE);
1833 yyerror(_("parse error"));
1840 if(strcmp($<id>1,"self")==0)
1841 push_self($<id>1, TRUE);
1844 yyerror(_("parse error"));
1851 if(strcmp($<id>2,"self")==0)
1852 push_self($<id>2, TRUE);
1855 yyerror(_("parse error"));
1859 | TOKEN ',' arglist {
1861 if(strcmp($<id>1,"self")==0)
1862 push_self($<id>1, FALSE);
1865 yyerror(_("parse error"));
1869 | TOKEN CONST ',' arglist {
1871 if(strcmp($<id>1,"self")==0)
1872 push_self($<id>1, TRUE);
1875 yyerror(_("parse error"));
1879 | CONST TOKEN ',' arglist {
1881 if(strcmp($<id>2,"self")==0)
1882 push_self($<id>2, TRUE);
1885 yyerror(_("parse error"));
1889 | arglist { has_self = FALSE; }
1892 arglist: arglist1 ',' THREEDOTS { vararg = TRUE; }
1893 | arglist1 { vararg = FALSE; }
1896 arglist1: arglist1 ',' arg { ; }
1901 push_funcarg($<id>2,NULL);
1903 | type TOKEN ARRAY_DIM {
1904 push_funcarg($<id>2,$<id>3);
1906 | type TOKEN '(' TOKEN checklist ')' {
1907 if(strcmp($<id>4,"check")!=0) {
1908 yyerror(_("parse error"));
1912 push_funcarg($<id>2,NULL);
1914 | type TOKEN ARRAY_DIM '(' TOKEN checklist ')' {
1915 if(strcmp($<id>5,"check")!=0) {
1916 yyerror(_("parse error"));
1920 push_funcarg($<id>2,$<id>3);
1924 checklist: checklist check { ; }
1929 if(strcmp($<id>1,"type")==0) {
1930 Node *node = node_new (CHECK_NODE,
1931 "chtype", TYPE_CHECK,
1933 checks = g_list_append(checks,node);
1934 } else if(strcmp($<id>1,"null")==0) {
1935 Node *node = node_new (CHECK_NODE,
1936 "chtype", NULL_CHECK,
1938 checks = g_list_append(checks,node);
1940 yyerror(_("parse error"));
1946 Node *node = node_new (CHECK_NODE,
1948 "number:steal", $<id>2,
1950 checks = g_list_append(checks,node);
1953 Node *node = node_new (CHECK_NODE,
1955 "number:steal", $<id>2,
1957 checks = g_list_append(checks,node);
1960 Node *node = node_new (CHECK_NODE,
1962 "number:steal", $<id>3,
1964 checks = g_list_append(checks,node);
1967 Node *node = node_new (CHECK_NODE,
1969 "number:steal", $<id>3,
1971 checks = g_list_append(checks,node);
1974 Node *node = node_new (CHECK_NODE,
1976 "number:steal", $<id>3,
1978 checks = g_list_append(checks,node);
1981 Node *node = node_new (CHECK_NODE,
1983 "number:steal", $<id>3,
1985 checks = g_list_append(checks,node);
1989 enumcode: ENUM TOKEN '{' enumvals '}' TYPETOKEN ';' {
1990 Node *node = node_new (ENUMDEF_NODE,
1991 "etype:steal", $<id>6,
1992 "prefix:steal", $<id>2,
1993 "values:steal", enum_vals,
1996 nodes = g_list_append (nodes, node);
1998 | ENUM TOKEN '{' enumvals ',' '}' TYPETOKEN ';' {
1999 Node *node = node_new (ENUMDEF_NODE,
2000 "etype:steal", $<id>7,
2001 "prefix:steal", $<id>2,
2002 "values:steal", enum_vals,
2005 nodes = g_list_append (nodes, node);
2009 enumvals: enumvals ',' enumval {;}
2013 enumval: TOKEN '=' numtok {
2017 /* A float value, that's a bad enum */
2018 if (num[0] >= '0' &&
2020 strchr (num, '.') != NULL) {
2023 yyerror(_("parse error (enumerator value not integer constant)"));
2027 node = node_new (ENUMVALUE_NODE,
2028 "name:steal", $<id>1,
2031 enum_vals = g_list_append (enum_vals, node);
2036 node = node_new (ENUMVALUE_NODE,
2037 "name:steal", $<id>1,
2039 enum_vals = g_list_append (enum_vals, node);
2043 flagcode: FLAGS TOKEN '{' flagvals '}' TYPETOKEN ';' {
2044 Node *node = node_new (FLAGS_NODE,
2045 "ftype:steal", $<id>6,
2046 "prefix:steal", $<id>2,
2047 "values:steal", flag_vals,
2050 nodes = g_list_append (nodes, node);
2052 | FLAGS TOKEN '{' flagvals ',' '}' TYPETOKEN ';' {
2053 Node *node = node_new (FLAGS_NODE,
2054 "ftype:steal", $<id>7,
2055 "prefix:steal", $<id>2,
2056 "values:steal", flag_vals,
2059 nodes = g_list_append (nodes, node);
2063 flagvals: flagvals ',' TOKEN {
2064 flag_vals = g_list_append (flag_vals, $<id>3);
2067 flag_vals = g_list_append (flag_vals, $<id>1);
2071 errorcode: ERROR TOKEN '{' errorvals '}' TYPETOKEN ';' {
2072 Node *node = node_new (ERROR_NODE,
2073 "etype:steal", $<id>6,
2074 "prefix:steal", $<id>2,
2075 "values:steal", error_vals,
2078 nodes = g_list_append (nodes, node);
2080 | ERROR TOKEN '{' errorvals ',' '}' TYPETOKEN ';' {
2081 Node *node = node_new (ERROR_NODE,
2082 "etype:steal", $<id>7,
2083 "prefix:steal", $<id>2,
2084 "values:steal", error_vals,
2087 nodes = g_list_append (nodes, node);
2091 errorvals: errorvals ',' TOKEN {
2092 error_vals = g_list_append (error_vals, $<id>3);
2095 error_vals = g_list_append (error_vals, $<id>1);
2100 numtok: NUMBER { $<id>$ = $<id>1; }
2102 $<id>$ = g_strconcat("-",$<id>2,NULL);
2105 | SINGLE_CHAR { $<id>$ = $<id>1; }
2106 | TOKEN { $<id>$ = $<id>1; }