2 * Copyright (C) 1999 the Free Software Foundation.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
29 #include "treefuncs.h"
37 static GList *class_nodes = NULL;
40 static char *chunk_size = NULL;
41 static char *bonobo_x_class = NULL;
42 static GList *typestack = NULL;
43 static GList *funcargs = NULL;
44 static GList *checks = NULL;
45 static int has_self = FALSE;
46 static int vararg = FALSE;
47 static Method *last_added_method = NULL;
49 /* destructor and initializer for variables */
50 static char *destructor = NULL;
51 static int destructor_line = 0;
52 static gboolean destructor_simple = TRUE;
53 static char *initializer = NULL;
54 static int initializer_line = 0;
56 static char *onerror = NULL;
57 static char *defreturn = NULL;
59 static GList *gtktypes = NULL;
61 /* this can be a global as we will only do one function at a time
63 static int the_scope = NO_SCOPE;
68 extern int ccode_line;
79 if(strcmp(yytext,"\n")==0) {
80 out=g_strconcat("Error: ",str," before newline",NULL);
81 } else if(yytext[0]=='\0') {
82 out=g_strconcat("Error: ", str, " at end of input", NULL);
84 char *tmp = g_strdup(yytext);
85 while((p=strchr(tmp, '\n')))
88 out=g_strconcat("Error: ", str, " before '", tmp, "'", NULL);
92 fprintf(stderr, "%s:%d: %s\n", filename, line_no, out);
101 Type *type = typestack->data;
102 typestack = g_list_remove(typestack,typestack->data);
107 push_variable(char *name, int scope, int line_no, char *postfix)
110 Type *type = pop_type();
112 type->postfix = postfix;
114 var = new_variable(scope, type, name, line_no,
115 destructor, destructor_line,
117 initializer, initializer_line);
118 class_nodes = g_list_append(class_nodes, var);
122 push_function(int scope, int method, char *oid, char *id,
123 GString *cbuf, int line_no, int ccode_line,
124 gboolean vararg, GList *flags)
130 g_assert(scope != CLASS_SCOPE);
132 if(method == INIT_METHOD || method == CLASS_INIT_METHOD) {
133 type = (Type *)new_type(g_strdup("void"), NULL, NULL);
138 /* a complicated and ugly test to figure out if we have
139 the wrong number of types for a signal */
140 if((method == SIGNAL_FIRST_METHOD ||
141 method == SIGNAL_LAST_METHOD) &&
142 g_list_length(gtktypes) != g_list_length(funcargs) &&
143 !(g_list_length(funcargs) == 1 &&
144 g_list_length(gtktypes) == 2 &&
145 strcmp(gtktypes->next->data, "NONE")==0)) {
146 error_print(GOB_WARN, line_no,
147 _("The number of GTK arguments and "
148 "function arguments for a signal "
149 "don't seem to match"));
151 if(g_list_length(gtktypes) > 2) {
153 for(li = gtktypes->next; li; li = li->next) {
154 if(strcmp(li->data, "NONE")==0) {
155 error_print(GOB_ERROR, line_no,
156 _("NONE can only appear in an "
157 "argument list by itself"));
163 c_cbuf = p = cbuf->str;
164 while(p && *p && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
171 node = new_method(scope, method, type, oid, gtktypes, flags,
172 id, funcargs, onerror, defreturn, c_cbuf, line_no,
173 ccode_line, vararg, method_unique_id++,
176 last_added_method = (Method *)node;
180 /*only free segment if we haven't passed it
189 class_nodes = g_list_append(class_nodes, node);
193 free_all_global_state(void)
203 g_list_foreach(gtktypes, (GFunc)g_free, NULL);
204 g_list_free(gtktypes);
207 free_node_list(funcargs);
212 push_funcarg(char *name, char *postfix)
215 Type *type = pop_type();
217 type->postfix = postfix;
219 node = new_funcarg(type, name, checks);
222 funcargs = g_list_append(funcargs, node);
226 push_init_arg(char *name, int is_class)
233 tn = g_strconcat(((Class *)class)->otype,":Class",NULL);
235 tn = g_strdup(((Class *)class)->otype);
237 type = new_type(tn, g_strdup("*"), NULL);
238 node = new_funcarg((Type *)type,name,NULL);
239 funcargs = g_list_prepend(funcargs, node);
243 push_self(char *id, gboolean constant)
248 type = new_type(g_strdup(((Class *)class)->otype),
249 g_strdup(constant ? "const *" : "*"), NULL);
250 ch = g_list_append(ch,new_check(NULL_CHECK,NULL));
251 ch = g_list_append(ch,new_check(TYPE_CHECK,NULL));
252 node = new_funcarg((Type *)type,id,ch);
253 funcargs = g_list_prepend(funcargs, node);
257 find_var_or_die(const char *id, int line)
261 for(li = class_nodes; li != NULL; li = li->next) {
263 Node *node = li->data;
264 if(node->type != VARIABLE_NODE)
267 if(strcmp(var->id, id)==0)
271 error_printf(GOB_ERROR, line, _("Variable %s not defined here"), id);
273 g_assert_not_reached();
278 set_return_value(char *type, char *val)
280 if(strcmp(type, "onerror")==0) {
286 } else if(strcmp(type, "defreturn")==0) {
307 %token CONST VOID STRUCT UNION ENUM THREEDOTS
308 %token SIGNED UNSIGNED LONG SHORT INT FLOAT DOUBLE CHAR
310 %token <id> TOKEN NUMBER TYPETOKEN ARRAY_DIM
311 %token <cbuf> CCODE HTCODE PHCODE HCODE ACODE ATCODE
312 %token <line> PUBLIC PRIVATE PROTECTED CLASSWIDE ARGUMENT VIRTUAL SIGNAL OVERRIDE
316 prog: ccodes class ccodes { ; }
323 Node *node = new_ccode(C_CCODE,($<cbuf>1)->str,
325 nodes = g_list_append(nodes,node);
326 g_string_free($<cbuf>1,FALSE);
329 Node *node = new_ccode(H_CCODE,($<cbuf>1)->str,
331 nodes = g_list_append(nodes,node);
332 g_string_free($<cbuf>1,FALSE);
335 Node *node = new_ccode(HT_CCODE,($<cbuf>1)->str,
337 nodes = g_list_append(nodes,node);
338 g_string_free($<cbuf>1,FALSE);
341 Node *node = new_ccode(PH_CCODE,($<cbuf>1)->str,
343 nodes = g_list_append(nodes,node);
344 g_string_free($<cbuf>1,FALSE);
347 Node *node = new_ccode(A_CCODE,($<cbuf>1)->str,
349 nodes = g_list_append(nodes,node);
350 g_string_free($<cbuf>1,FALSE);
353 Node *node = new_ccode(AT_CCODE,($<cbuf>1)->str,
355 nodes = g_list_append(nodes,node);
356 g_string_free($<cbuf>1,FALSE);
360 ccodes: ccodes ccode { ; }
364 class: classdec '{' classcode '}' {
365 ((Class *)class)->nodes = class_nodes;
367 nodes = g_list_append(nodes,class);
370 ((Class *)class)->nodes = NULL;
372 nodes = g_list_append(nodes,class);
376 classdec: CLASS TYPETOKEN FROM TYPETOKEN classflags {
377 class = new_class ($<id>2, $<id>4,
378 bonobo_x_class, chunk_size, NULL);
383 | '(' TOKEN TOKEN ')' classflags {
384 if(strcmp($<id>2,"chunks") == 0) {
386 chunk_size = g_strdup($<id>3);
387 } else if(strcmp($<id>2,"BonoboX") == 0) {
388 g_free (bonobo_x_class);
389 bonobo_x_class = g_strdup($<id>3);
391 yyerror(_("parse error"));
395 | '(' TOKEN NUMBER ')' classflags {
396 if(strcmp($<id>2,"chunks") == 0) {
398 if(atoi($<id>3) != 0)
399 chunk_size = g_strdup($<id>3);
403 yyerror(_("parse error"));
409 classcode: classcode thing { ; }
415 if (strcmp ($<id>1, "BonoboX") != 0) {
417 yyerror(_("parse error"));
420 last_added_method->bonobo_x_func = TRUE;
427 scope: PUBLIC { the_scope = PUBLIC_SCOPE; }
428 | PRIVATE { the_scope = PRIVATE_SCOPE; }
429 | PROTECTED { the_scope = PROTECTED_SCOPE; }
430 | CLASSWIDE { the_scope = CLASS_SCOPE; }
433 destructor: TOKEN TOKEN {
434 if(strcmp($<id>1, "destroywith")==0) {
437 destructor_line = line_no;
438 destructor_simple = TRUE;
442 yyerror(_("parse error"));
447 if(strcmp($<id>1, "destroy")==0) {
449 destructor = ($<cbuf>3)->str;
450 g_string_free($<cbuf>3, FALSE);
451 destructor_line = ccode_line;
452 destructor_simple = FALSE;
455 g_string_free($<cbuf>3, TRUE);
456 yyerror(_("parse error"));
462 initializer: '=' numtok {
463 initializer = $<id>2;
464 initializer_line = ccode_line;
467 initializer = ($<cbuf>3)->str;
468 initializer_line = ccode_line;
469 g_string_free($<cbuf>3, FALSE);
474 varoptions: destructor initializer { ; }
475 | initializer destructor { ; }
476 | initializer { destructor = NULL; }
477 | destructor { initializer = NULL; }
484 variable: scope type TOKEN varoptions ';' {
485 push_variable($<id>3, the_scope,$<line>1, NULL);
487 | scope type TOKEN ARRAY_DIM varoptions ';' {
488 push_variable($<id>3, the_scope, $<line>1, $<id>4);
491 argument: ARGUMENT flags argtype TOKEN TOKEN '{' CCODE TOKEN '{' CCODE ';' {
492 if(strcmp($<id>5,"get")==0 &&
493 strcmp($<id>8,"set")==0) {
495 Type *type = pop_type();
496 g_free($<id>5); g_free($<id>8);
497 node = new_argument($<id>3,type,$<list>2,$<id>4,
498 ($<cbuf>7)->str,$<line>6,
499 ($<cbuf>10)->str,$<line>9,
501 g_string_free($<cbuf>7,FALSE);
502 g_string_free($<cbuf>10,FALSE);
503 class_nodes = g_list_append(class_nodes,node);
504 } else if(strcmp($<id>5,"set")==0 &&
505 strcmp($<id>8,"get")==0) {
507 Type *type = pop_type();
508 g_free($<id>5); g_free($<id>8);
509 node = new_argument($<id>3,type,$<list>2,$<id>4,
510 ($<cbuf>10)->str,$<line>9,
511 ($<cbuf>7)->str,$<line>6,
513 g_string_free($<cbuf>10,FALSE);
514 g_string_free($<cbuf>7,FALSE);
515 class_nodes = g_list_append(class_nodes,node);
517 g_free($<id>3); g_free($<id>4);
518 g_free($<id>5); g_free($<id>8);
519 g_list_foreach($<list>2,(GFunc)g_free,NULL);
520 g_list_free($<list>2);
521 g_string_free($<cbuf>10,TRUE);
522 g_string_free($<cbuf>7,TRUE);
523 yyerror(_("parse error"));
527 | ARGUMENT flags argtype TOKEN TOKEN '{' CCODE ';' {
528 if(strcmp($<id>5, "get") == 0) {
530 Type *type = pop_type();
532 node = new_argument($<id>3, type, $<list>2, $<id>4,
533 ($<cbuf>7)->str, $<line>6,
535 g_string_free($<cbuf>7, FALSE);
536 class_nodes = g_list_append(class_nodes, node);
537 } else if(strcmp($<id>5, "set") == 0) {
539 Type *type = pop_type();
541 node = new_argument($<id>3, type, $<list>2, $<id>4,
542 NULL, 0, ($<cbuf>7)->str,
544 g_string_free($<cbuf>7, FALSE);
545 class_nodes = g_list_append(class_nodes, node);
547 g_free($<id>5); g_free($<id>3);
549 g_list_foreach($<list>2, (GFunc)g_free, NULL);
550 g_list_free($<list>2);
551 g_string_free($<cbuf>7, TRUE);
552 yyerror(_("parse error"));
556 | ARGUMENT flags argtype TOKEN TOKEN {
558 char *get, *set = NULL;
563 if(strcmp($<id>5, "link")!=0 &&
564 strcmp($<id>5, "stringlink")!=0 &&
565 strcmp($<id>5, "objectlink")!=0) {
566 g_free($<id>5); g_free($<id>3);
568 g_list_foreach($<list>2,(GFunc)g_free,NULL);
569 g_list_free($<list>2);
570 yyerror(_("parse error"));
576 var = find_var_or_die($<id>4, $<line>1);
577 if(var->scope == PRIVATE_SCOPE)
578 root = "self->_priv";
579 else if(var->scope == CLASS_SCOPE) {
580 root = "SELF_GET_CLASS(self)";
582 error_print(GOB_ERROR, $<line>1,
583 _("Self aliases needed when autolinking to a classwide member"));
587 if(strcmp($<id>5, "link")==0) {
588 set = g_strdup_printf("%s->%s = ARG;",
590 } else if(strcmp($<id>5, "stringlink")==0) {
591 set = g_strdup_printf("g_free(%s->%s); "
592 "%s->%s = g_strdup(ARG);",
595 } else if(strcmp($<id>5, "objectlink")==0) {
596 set = g_strdup_printf(
598 "gtk_object_ref (GTK_OBJECT (ARG)); "
599 "if (%s->%s != NULL) "
600 "gtk_object_unref (GTK_OBJECT (%s->%s)); "
606 g_assert_not_reached();
609 if(strcmp($<id>5, "stringlink")==0) {
610 get = g_strdup_printf("ARG = g_strdup(%s->%s);", root, $<id>4);
612 /* For everything else, get is just straight assignment */
613 get = g_strdup_printf("ARG = %s->%s;", root, $<id>4);
619 type = copy_type(var->vtype);
621 node = new_argument($<id>3, type, $<list>2,
622 $<id>4, get, $<line>1,
623 set, $<line>1, $<line>1);
624 class_nodes = g_list_append(class_nodes,node);
628 argtype: TOKEN '(' TOKEN type ')' {
629 if(strcmp($<id>3,"type")!=0) {
632 yyerror(_("parse error"));
639 typestack = g_list_prepend(typestack,NULL);
643 flags: '(' flaglist ')' { $<list>$ = $<list>2; }
644 | { $<list>$ = NULL; }
647 flaglist: TOKEN '|' flaglist {
648 $<list>$ = g_list_append($<list>3,$<id>1);
651 $<list>$ = g_list_append(NULL,$<id>1);
656 type: specifier_list pointer {
657 Node *node = new_type($<id>1, $<id>2, NULL);
658 typestack = g_list_prepend(typestack,node);
661 Node *node = new_type($<id>1, NULL, NULL);
662 typestack = g_list_prepend(typestack,node);
666 /* The special cases are neccessary to avoid conflicts */
667 specifier_list: spec_list {
674 $<id>$ = g_strconcat("const ", $<id>2, NULL);
678 $<id>$ = g_strconcat($<id>1, " const", NULL);
681 | strunionenum TOKEN {
682 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
685 | CONST strunionenum TOKEN {
686 $<id>$ = g_strconcat("const ", $<id>2, " ",
690 | strunionenum TOKEN CONST {
691 $<id>$ = g_strconcat($<id>1, " ",
692 $<id>2, " const", NULL);
697 /* The special const cases take care of conflicts ! */
698 spec_list: specifier spec_list {
699 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
702 | TYPETOKEN spec_list {
703 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
708 $<id>$ = g_strconcat("const ", $<id>2, NULL);
715 $<id>$ = g_strconcat($<id>1, " const", NULL);
719 $<id>$ = g_strdup($<id>1);
722 $<id>$ = g_strconcat($<id>1, " const", NULL);
726 specifier: VOID { $<id>$ = "void"; }
727 | CHAR { $<id>$ = "char"; }
728 | SHORT { $<id>$ = "short"; }
729 | INT { $<id>$ = "int"; }
730 | LONG { $<id>$ = "long"; }
731 | FLOAT { $<id>$ = "float"; }
732 | DOUBLE { $<id>$ = "double"; }
733 | SIGNED { $<id>$ = "signed"; }
734 | UNSIGNED { $<id>$ = "unsigned"; }
737 strunionenum: STRUCT { $<id>$ = "struct"; }
738 | UNION { $<id>$ = "union"; }
739 | ENUM { $<id>$ = "enum"; }
742 pointer: '*' { $<id>$ = g_strdup("*"); }
743 | '*' CONST { $<id>$ = g_strdup("* const"); }
745 $<id>$ = g_strconcat("*", $<id>2, NULL);
748 | '*' CONST pointer {
749 $<id>$ = g_strconcat("* const", $<id>3, NULL);
754 /* this never sets the_scope */
755 simplesigtype: TOKEN sigtype {
756 if(strcmp($<id>1, "first")==0)
757 $<sigtype>$ = SIGNAL_FIRST_METHOD;
758 else if(strcmp($<id>1, "last")==0)
759 $<sigtype>$ = SIGNAL_LAST_METHOD;
761 yyerror(_("signal must be 'first' or 'last'"));
768 $<sigtype>$ = SIGNAL_LAST_METHOD;
772 /* this always sets the_scope */
773 fullsigtype: scope TOKEN sigtype {
774 if(strcmp($<id>2,"first")==0)
775 $<sigtype>$ = SIGNAL_FIRST_METHOD;
776 else if(strcmp($<id>2,"last")==0)
777 $<sigtype>$ = SIGNAL_LAST_METHOD;
779 yyerror(_("signal must be 'first' or 'last'"));
785 | TOKEN scope sigtype {
786 if(strcmp($<id>1,"first")==0)
787 $<sigtype>$ = SIGNAL_FIRST_METHOD;
788 else if(strcmp($<id>1,"last")==0)
789 $<sigtype>$ = SIGNAL_LAST_METHOD;
791 yyerror(_("signal must be 'first' or 'last'"));
798 $<sigtype>$ = SIGNAL_LAST_METHOD;
801 /* the_scope was default thus public */
802 the_scope = PUBLIC_SCOPE;
806 sigtype: TOKEN '(' tokenlist ')' {
807 gtktypes = g_list_prepend(gtktypes, $<id>1);
811 tokenlist: tokenlist ',' TOKEN {
812 gtktypes = g_list_append(gtktypes, $<id>3);
815 gtktypes = g_list_append(gtktypes, $<id>1);
819 codenocode: '{' CCODE { $<cbuf>$ = $<cbuf>2; }
820 | ';' { $<cbuf>$ = NULL; }
823 /*here CCODE will include the ending '}' */
824 method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' returnvals codenocode {
826 yyerror(_("signal without 'self' as "
828 free_all_global_state();
831 if(the_scope == CLASS_SCOPE) {
832 yyerror(_("a method cannot be of class scope"));
833 free_all_global_state();
836 push_function(the_scope, $<sigtype>3,NULL,
837 $<id>5, $<cbuf>10,$<line>1,
838 ccode_line, vararg, $<list>2);
840 | scope SIGNAL flags simplesigtype type TOKEN '(' funcargs ')' returnvals codenocode {
842 yyerror(_("signal without 'self' as "
844 free_all_global_state();
847 if(the_scope == CLASS_SCOPE) {
848 yyerror(_("a method cannot be of class scope"));
849 free_all_global_state();
852 push_function(the_scope, $<sigtype>4, NULL,
853 $<id>6, $<cbuf>11, $<line>2,
854 ccode_line, vararg, $<list>3);
856 | VIRTUAL scope type TOKEN '(' funcargs ')' returnvals codenocode {
858 yyerror(_("virtual method without 'self' as "
860 free_all_global_state();
863 if(the_scope == CLASS_SCOPE) {
864 yyerror(_("a method cannot be of class scope"));
865 free_all_global_state();
868 push_function(the_scope, VIRTUAL_METHOD, NULL, $<id>4,
870 ccode_line, vararg, NULL);
872 | scope VIRTUAL type TOKEN '(' funcargs ')' returnvals codenocode {
874 yyerror(_("virtual method without 'self' as "
876 free_all_global_state();
879 if(the_scope == CLASS_SCOPE) {
880 yyerror(_("a method cannot be of class scope"));
881 free_all_global_state();
884 push_function(the_scope, VIRTUAL_METHOD, NULL, $<id>4,
886 ccode_line, vararg, NULL);
888 | VIRTUAL type TOKEN '(' funcargs ')' returnvals codenocode {
890 yyerror(_("virtual method without 'self' as "
892 free_all_global_state();
895 push_function(PUBLIC_SCOPE, VIRTUAL_METHOD, NULL,
896 $<id>3, $<cbuf>8, $<line>1,
897 ccode_line, vararg, NULL);
899 | OVERRIDE '(' TYPETOKEN ')' type TOKEN '(' funcargs ')' returnvals codenocode {
900 push_function(NO_SCOPE, OVERRIDE_METHOD, $<id>3,
902 $<line>1, ccode_line,
905 | scope type TOKEN '(' funcargs ')' returnvals codenocode {
906 if(the_scope == CLASS_SCOPE) {
907 yyerror(_("a method cannot be of class scope"));
908 free_all_global_state();
911 push_function(the_scope, REGULAR_METHOD, NULL, $<id>3,
912 $<cbuf>8, $<line>1, ccode_line,
915 | TOKEN '(' TOKEN ')' codenocode {
916 if(strcmp($<id>1, "init")==0) {
917 push_init_arg($<id>3,FALSE);
918 push_function(NO_SCOPE, INIT_METHOD, NULL,
919 $<id>1, $<cbuf>5, $<line>2,
920 ccode_line, FALSE, NULL);
921 } else if(strcmp($<id>1, "class_init")==0) {
922 push_init_arg($<id>3,TRUE);
923 push_function(NO_SCOPE, CLASS_INIT_METHOD, NULL,
924 $<id>1, $<cbuf>5, $<line>2,
925 ccode_line, FALSE, NULL);
929 g_string_free($<cbuf>5,TRUE);
930 yyerror(_("parse error "
931 "(untyped blocks must be init or "
938 returnvals: TOKEN retcode {
939 g_free(onerror); onerror = NULL;
940 g_free(defreturn); defreturn = NULL;
941 if(!set_return_value($<id>1, $<id>2)) {
944 yyerror(_("parse error"));
949 | TOKEN retcode TOKEN retcode {
950 g_free(onerror); onerror = NULL;
951 g_free(defreturn); defreturn = NULL;
952 if(!set_return_value($<id>1, $<id>2)) {
953 g_free($<id>1); g_free($<id>2);
954 g_free($<id>3); g_free($<id>4);
955 yyerror(_("parse error"));
958 if(!set_return_value($<id>3, $<id>4)) {
959 onerror = defreturn = NULL;
960 g_free($<id>1); g_free($<id>2);
961 g_free($<id>3); g_free($<id>4);
962 yyerror(_("parse error"));
969 g_free(onerror); onerror = NULL;
970 g_free(defreturn); defreturn = NULL;
974 retcode: numtok { $<id>$ = $<id>1; }
976 $<id>$ = ($<cbuf>3)->str;
977 g_string_free($<cbuf>3, FALSE);
981 funcargs: VOID { vararg = FALSE; has_self = FALSE; }
985 if(strcmp($<id>1,"self")==0)
986 push_self($<id>1, FALSE);
989 yyerror(_("parse error"));
996 if(strcmp($<id>1,"self")==0)
997 push_self($<id>1, TRUE);
1000 yyerror(_("parse error"));
1007 if(strcmp($<id>2,"self")==0)
1008 push_self($<id>2, TRUE);
1011 yyerror(_("parse error"));
1015 | TOKEN ',' arglist {
1017 if(strcmp($<id>1,"self")==0)
1018 push_self($<id>1, FALSE);
1021 yyerror(_("parse error"));
1025 | TOKEN CONST ',' arglist {
1027 if(strcmp($<id>1,"self")==0)
1028 push_self($<id>1, TRUE);
1031 yyerror(_("parse error"));
1035 | CONST TOKEN ',' arglist {
1037 if(strcmp($<id>2,"self")==0)
1038 push_self($<id>2, TRUE);
1041 yyerror(_("parse error"));
1045 | arglist { has_self = FALSE; }
1048 arglist: arglist1 ',' THREEDOTS { vararg = TRUE; }
1049 | arglist1 { vararg = FALSE; }
1052 arglist1: arglist1 ',' arg { ; }
1057 push_funcarg($<id>2,NULL);
1059 | type TOKEN ARRAY_DIM {
1060 push_funcarg($<id>2,$<id>3);
1062 | type TOKEN '(' TOKEN checklist ')' {
1063 if(strcmp($<id>4,"check")!=0) {
1064 yyerror(_("parse error"));
1068 push_funcarg($<id>2,NULL);
1070 | type TOKEN ARRAY_DIM '(' TOKEN checklist ')' {
1071 if(strcmp($<id>5,"check")!=0) {
1072 yyerror(_("parse error"));
1076 push_funcarg($<id>2,$<id>3);
1080 checklist: checklist check { ; }
1085 if(strcmp($<id>1,"type")==0) {
1086 Node *node = new_check(TYPE_CHECK,NULL);
1087 checks = g_list_append(checks,node);
1088 } else if(strcmp($<id>1,"null")==0) {
1089 Node *node = new_check(NULL_CHECK,NULL);
1090 checks = g_list_append(checks,node);
1092 yyerror(_("parse error"));
1098 Node *node = new_check(GT_CHECK,$<id>2);
1099 checks = g_list_append(checks,node);
1102 Node *node = new_check(LT_CHECK,$<id>2);
1103 checks = g_list_append(checks,node);
1106 Node *node = new_check(GE_CHECK,$<id>3);
1107 checks = g_list_append(checks,node);
1110 Node *node = new_check(LE_CHECK,$<id>3);
1111 checks = g_list_append(checks,node);
1114 Node *node = new_check(EQ_CHECK,$<id>3);
1115 checks = g_list_append(checks,node);
1118 Node *node = new_check(NE_CHECK,$<id>3);
1119 checks = g_list_append(checks,node);
1123 numtok: NUMBER { $<id>$ = $<id>1; }
1125 $<id>$ = g_strconcat("-",$<id>2,NULL);
1128 | TOKEN { $<id>$ = $<id>1; }