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;
39 char *chunk_size = NULL;
41 static GList *typestack = NULL;
42 static GList *funcargs = NULL;
43 static GList *checks = NULL;
44 static int has_self = FALSE;
45 static int vararg = FALSE;
47 /* destructor and initializer for variables */
48 static char *destructor = NULL;
49 static int destructor_line = 0;
50 static gboolean destructor_simple = TRUE;
51 static char *initializer = NULL;
52 static int initializer_line = 0;
54 static char *onerror = NULL;
55 static char *defreturn = NULL;
57 static GList *gtktypes = NULL;
59 /* this can be a global as we will only do one function at a time
61 static int the_scope = NO_SCOPE;
66 extern int ccode_line;
77 if(strcmp(yytext,"\n")==0) {
78 out=g_strconcat("Error: ",str," before newline",NULL);
79 } else if(yytext[0]=='\0') {
80 out=g_strconcat("Error: ", str, " at end of input", NULL);
82 char *tmp = g_strdup(yytext);
83 while((p=strchr(tmp, '\n')))
86 out=g_strconcat("Error: ", str, " before '", tmp, "'", NULL);
90 fprintf(stderr, "%s:%d: %s\n", filename, line_no, out);
99 Type *type = typestack->data;
100 typestack = g_list_remove(typestack,typestack->data);
105 push_variable(char *name, int scope, int line_no, char *postfix)
108 Type *type = pop_type();
110 type->postfix = postfix;
112 var = new_variable(scope, type, name, line_no,
113 destructor, destructor_line,
115 initializer, initializer_line);
116 class_nodes = g_list_append(class_nodes, var);
120 push_function(int scope, int method, char *oid, char *id,
121 GString *cbuf, int line_no, int ccode_line,
122 gboolean vararg, GList *flags)
128 g_assert(scope != CLASS_SCOPE);
130 if(method == INIT_METHOD || method == CLASS_INIT_METHOD) {
131 type = (Type *)new_type(g_strdup("void"), NULL, NULL);
136 /* a complicated and ugly test to figure out if we have
137 the wrong number of types for a signal */
138 if((method == SIGNAL_FIRST_METHOD ||
139 method == SIGNAL_LAST_METHOD) &&
140 g_list_length(gtktypes) != g_list_length(funcargs) &&
141 !(g_list_length(funcargs) == 1 &&
142 g_list_length(gtktypes) == 2 &&
143 strcmp(gtktypes->next->data, "NONE")==0)) {
144 print_error(TRUE, _("The number of GTK arguments and "
145 "function arguments for a signal "
146 "don't seem to match"), line_no);
148 if(g_list_length(gtktypes) > 2) {
150 for(li = gtktypes->next; li; li = li->next) {
151 if(strcmp(li->data, "NONE")==0) {
153 _("NONE can only appear in an "
154 "argument list by itself"),
161 c_cbuf = p = cbuf->str;
162 while(p && *p && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
169 node = new_method(scope, method, type, oid, gtktypes, flags,
170 id, funcargs, onerror, defreturn, c_cbuf, line_no,
171 ccode_line, vararg, method_unique_id++);
175 /*only free segment if we haven't passed it
184 class_nodes = g_list_append(class_nodes, node);
188 free_all_global_state(void)
198 g_list_foreach(gtktypes, (GFunc)g_free, NULL);
199 g_list_free(gtktypes);
202 free_node_list(funcargs);
207 push_funcarg(char *name, char *postfix)
210 Type *type = pop_type();
212 type->postfix = postfix;
214 node = new_funcarg(type, name, checks);
217 funcargs = g_list_append(funcargs, node);
221 push_init_arg(char *name, int is_class)
228 tn = g_strconcat(((Class *)class)->otype,":Class",NULL);
230 tn = g_strdup(((Class *)class)->otype);
232 type = new_type(tn, g_strdup("*"), NULL);
233 node = new_funcarg((Type *)type,name,NULL);
234 funcargs = g_list_prepend(funcargs, node);
238 push_self(char *id, gboolean constant)
243 type = new_type(g_strdup(((Class *)class)->otype),
244 g_strdup(constant ? "const *" : "*"), NULL);
245 ch = g_list_append(ch,new_check(NULL_CHECK,NULL));
246 ch = g_list_append(ch,new_check(TYPE_CHECK,NULL));
247 node = new_funcarg((Type *)type,id,ch);
248 funcargs = g_list_prepend(funcargs, node);
252 find_var_or_die(const char *id, int line)
257 for(li = class_nodes; li != NULL; li = li->next) {
259 Node *node = li->data;
260 if(node->type != VARIABLE_NODE)
263 if(strcmp(var->id, id)==0)
267 s = g_strdup_printf(_("Variable %s not defined here"), id);
268 print_error(FALSE, s, line);
270 g_assert_not_reached();
275 set_return_value(char *type, char *val)
277 if(strcmp(type, "onerror")==0) {
283 } else if(strcmp(type, "defreturn")==0) {
304 %token CONST VOID STRUCT UNION ENUM THREEDOTS
305 %token SIGNED UNSIGNED LONG SHORT INT FLOAT DOUBLE CHAR
307 %token <id> TOKEN NUMBER TYPETOKEN ARRAY_DIM
308 %token <cbuf> CCODE HTCODE PHCODE HCODE ACODE ATCODE
309 %token <line> PUBLIC PRIVATE PROTECTED CLASSWIDE ARGUMENT VIRTUAL SIGNAL OVERRIDE
313 prog: ccodes class ccodes { ; }
320 Node *node = new_ccode(C_CCODE,($<cbuf>1)->str,
322 nodes = g_list_append(nodes,node);
323 g_string_free($<cbuf>1,FALSE);
326 Node *node = new_ccode(H_CCODE,($<cbuf>1)->str,
328 nodes = g_list_append(nodes,node);
329 g_string_free($<cbuf>1,FALSE);
332 Node *node = new_ccode(HT_CCODE,($<cbuf>1)->str,
334 nodes = g_list_append(nodes,node);
335 g_string_free($<cbuf>1,FALSE);
338 Node *node = new_ccode(PH_CCODE,($<cbuf>1)->str,
340 nodes = g_list_append(nodes,node);
341 g_string_free($<cbuf>1,FALSE);
344 Node *node = new_ccode(A_CCODE,($<cbuf>1)->str,
346 nodes = g_list_append(nodes,node);
347 g_string_free($<cbuf>1,FALSE);
350 Node *node = new_ccode(AT_CCODE,($<cbuf>1)->str,
352 nodes = g_list_append(nodes,node);
353 g_string_free($<cbuf>1,FALSE);
357 ccodes: ccodes ccode { ; }
361 class: classdec '{' classcode '}' {
362 ((Class *)class)->nodes = class_nodes;
364 nodes = g_list_append(nodes,class);
367 ((Class *)class)->nodes = NULL;
369 nodes = g_list_append(nodes,class);
373 classdec: CLASS TYPETOKEN FROM TYPETOKEN chunk {
374 class = new_class($<id>2,$<id>4,chunk_size,NULL);
379 | '(' TOKEN TOKEN ')' {
380 if(strcmp($<id>2,"chunks") == 0) {
381 chunk_size = g_strdup($<id>4);
383 yyerror(_("parse error"));
387 | '(' TOKEN NUMBER ')' {
388 if(strcmp($<id>2,"chunks") == 0) {
389 if(atoi($<id>4) != 0)
390 chunk_size = g_strdup($<id>4);
392 yyerror(_("parse error"));
398 classcode: classcode thing { ; }
408 scope: PUBLIC { the_scope = PUBLIC_SCOPE; }
409 | PRIVATE { the_scope = PRIVATE_SCOPE; }
410 | PROTECTED { the_scope = PROTECTED_SCOPE; }
411 | CLASSWIDE { the_scope = CLASS_SCOPE; }
414 destructor: TOKEN TOKEN {
415 if(strcmp($<id>1, "destroywith")==0) {
418 destructor_line = line_no;
419 destructor_simple = TRUE;
423 yyerror(_("parse error"));
428 if(strcmp($<id>1, "destroy")==0) {
430 destructor = ($<cbuf>3)->str;
431 g_string_free($<cbuf>3, FALSE);
432 destructor_line = ccode_line;
433 destructor_simple = FALSE;
436 g_string_free($<cbuf>3, TRUE);
437 yyerror(_("parse error"));
443 initializer: '=' numtok {
444 initializer = $<id>2;
445 initializer_line = ccode_line;
448 initializer = ($<cbuf>3)->str;
449 initializer_line = ccode_line;
450 g_string_free($<cbuf>3, FALSE);
455 varoptions: destructor initializer { ; }
456 | initializer destructor { ; }
457 | initializer { destructor = NULL; }
458 | destructor { initializer = NULL; }
465 variable: scope type TOKEN varoptions ';' {
466 push_variable($<id>3, the_scope,$<line>1, NULL);
468 | scope type TOKEN ARRAY_DIM varoptions ';' {
469 push_variable($<id>3, the_scope, $<line>1, $<id>4);
472 argument: ARGUMENT flags argtype TOKEN TOKEN '{' CCODE TOKEN '{' CCODE ';' {
473 if(strcmp($<id>5,"get")==0 &&
474 strcmp($<id>8,"set")==0) {
476 Type *type = pop_type();
477 g_free($<id>5); g_free($<id>8);
478 node = new_argument($<id>3,type,$<list>2,$<id>4,
479 ($<cbuf>7)->str,$<line>6,
480 ($<cbuf>10)->str,$<line>9,
482 g_string_free($<cbuf>7,FALSE);
483 g_string_free($<cbuf>10,FALSE);
484 class_nodes = g_list_append(class_nodes,node);
485 } else if(strcmp($<id>5,"set")==0 &&
486 strcmp($<id>8,"get")==0) {
488 Type *type = pop_type();
489 g_free($<id>5); g_free($<id>8);
490 node = new_argument($<id>3,type,$<list>2,$<id>4,
491 ($<cbuf>10)->str,$<line>9,
492 ($<cbuf>7)->str,$<line>6,
494 g_string_free($<cbuf>10,FALSE);
495 g_string_free($<cbuf>7,FALSE);
496 class_nodes = g_list_append(class_nodes,node);
498 g_free($<id>3); g_free($<id>4);
499 g_free($<id>5); g_free($<id>8);
500 g_list_foreach($<list>2,(GFunc)g_free,NULL);
501 g_list_free($<list>2);
502 g_string_free($<cbuf>10,TRUE);
503 g_string_free($<cbuf>7,TRUE);
504 yyerror(_("parse error"));
508 | ARGUMENT flags argtype TOKEN TOKEN '{' CCODE ';' {
509 if(strcmp($<id>5, "get") == 0) {
511 Type *type = pop_type();
513 node = new_argument($<id>3, type, $<list>2, $<id>4,
514 ($<cbuf>7)->str, $<line>6,
516 g_string_free($<cbuf>7, FALSE);
517 class_nodes = g_list_append(class_nodes, node);
518 } else if(strcmp($<id>5, "set") == 0) {
520 Type *type = pop_type();
522 node = new_argument($<id>3, type, $<list>2, $<id>4,
523 NULL, 0, ($<cbuf>7)->str,
525 g_string_free($<cbuf>7, FALSE);
526 class_nodes = g_list_append(class_nodes, node);
528 g_free($<id>5); g_free($<id>3);
530 g_list_foreach($<list>2, (GFunc)g_free, NULL);
531 g_list_free($<list>2);
532 g_string_free($<cbuf>7, TRUE);
533 yyerror(_("parse error"));
537 | ARGUMENT flags argtype TOKEN TOKEN {
539 char *get, *set = NULL;
544 if(strcmp($<id>5, "link")!=0 &&
545 strcmp($<id>5, "stringlink")!=0 &&
546 strcmp($<id>5, "objectlink")!=0) {
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 yyerror(_("parse error"));
557 var = find_var_or_die($<id>4, $<line>1);
558 if(var->scope == PRIVATE_SCOPE)
559 root = "self->_priv";
560 else if(var->scope == CLASS_SCOPE) {
561 root = "SELF_GET_CLASS(self)";
564 _("Self aliases needed when autolinking to a classwide member"),
569 if(strcmp($<id>5, "link")==0) {
570 set = g_strdup_printf("%s->%s = ARG;",
572 } else if(strcmp($<id>5, "stringlink")==0) {
573 set = g_strdup_printf("g_free(%s->%s); "
574 "%s->%s = g_strdup(ARG);",
577 } else if(strcmp($<id>5, "objectlink")==0) {
578 set = g_strdup_printf(
580 "gtk_object_unref(GTK_OBJECT(%s->%s)); "
583 "gtk_object_ref(GTK_OBJECT(%s->%s));",
590 g_assert_not_reached();
593 if(strcmp($<id>5, "stringlink")==0) {
594 get = g_strdup_printf("ARG = g_strdup(%s->%s);", root, $<id>4);
596 /* For everything else, get is just straight assignment */
597 get = g_strdup_printf("ARG = %s->%s;", root, $<id>4);
603 type = copy_type(var->vtype);
605 node = new_argument($<id>3, type, $<list>2,
606 $<id>4, get, $<line>1,
607 set, $<line>1, $<line>1);
608 class_nodes = g_list_append(class_nodes,node);
612 argtype: TOKEN '(' TOKEN type ')' {
613 if(strcmp($<id>3,"type")!=0) {
616 yyerror(_("parse error"));
623 typestack = g_list_prepend(typestack,NULL);
627 flags: '(' flaglist ')' { $<list>$ = $<list>2; }
628 | { $<list>$ = NULL; }
631 flaglist: TOKEN '|' flaglist {
632 $<list>$ = g_list_append($<list>3,$<id>1);
635 $<list>$ = g_list_append(NULL,$<id>1);
640 type: specifier_list pointer {
641 Node *node = new_type($<id>1, $<id>2, NULL);
642 typestack = g_list_prepend(typestack,node);
645 Node *node = new_type($<id>1, NULL, NULL);
646 typestack = g_list_prepend(typestack,node);
650 /* The special cases are neccessary to avoid conflicts */
651 specifier_list: spec_list {
658 $<id>$ = g_strconcat("const ", $<id>2, NULL);
662 $<id>$ = g_strconcat($<id>1, " const", NULL);
665 | strunionenum TOKEN {
666 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
669 | CONST strunionenum TOKEN {
670 $<id>$ = g_strconcat("const ", $<id>2, " ",
674 | strunionenum TOKEN CONST {
675 $<id>$ = g_strconcat($<id>1, " ",
676 $<id>2, " const", NULL);
681 /* The special const cases take care of conflicts ! */
682 spec_list: specifier spec_list {
683 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
686 | TYPETOKEN spec_list {
687 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
692 $<id>$ = g_strconcat("const ", $<id>2, NULL);
699 $<id>$ = g_strconcat($<id>1, " const", NULL);
703 $<id>$ = g_strdup($<id>1);
706 $<id>$ = g_strconcat($<id>1, " const", NULL);
710 specifier: VOID { $<id>$ = "void"; }
711 | CHAR { $<id>$ = "char"; }
712 | SHORT { $<id>$ = "short"; }
713 | INT { $<id>$ = "int"; }
714 | LONG { $<id>$ = "long"; }
715 | FLOAT { $<id>$ = "float"; }
716 | DOUBLE { $<id>$ = "double"; }
717 | SIGNED { $<id>$ = "signed"; }
718 | UNSIGNED { $<id>$ = "unsigned"; }
721 strunionenum: STRUCT { $<id>$ = "struct"; }
722 | UNION { $<id>$ = "union"; }
723 | ENUM { $<id>$ = "enum"; }
726 pointer: '*' { $<id>$ = g_strdup("*"); }
727 | '*' CONST { $<id>$ = g_strdup("* const"); }
729 $<id>$ = g_strconcat("*", $<id>2, NULL);
732 | '*' CONST pointer {
733 $<id>$ = g_strconcat("* const", $<id>3, NULL);
738 /* this never sets the_scope */
739 simplesigtype: TOKEN sigtype {
740 if(strcmp($<id>1, "first")==0)
741 $<sigtype>$ = SIGNAL_FIRST_METHOD;
742 else if(strcmp($<id>1, "last")==0)
743 $<sigtype>$ = SIGNAL_LAST_METHOD;
745 yyerror(_("signal must be 'first' or 'last'"));
752 $<sigtype>$ = SIGNAL_LAST_METHOD;
756 /* this always sets the_scope */
757 fullsigtype: scope TOKEN sigtype {
758 if(strcmp($<id>2,"first")==0)
759 $<sigtype>$ = SIGNAL_FIRST_METHOD;
760 else if(strcmp($<id>2,"last")==0)
761 $<sigtype>$ = SIGNAL_LAST_METHOD;
763 yyerror(_("signal must be 'first' or 'last'"));
769 | TOKEN scope sigtype {
770 if(strcmp($<id>1,"first")==0)
771 $<sigtype>$ = SIGNAL_FIRST_METHOD;
772 else if(strcmp($<id>1,"last")==0)
773 $<sigtype>$ = SIGNAL_LAST_METHOD;
775 yyerror(_("signal must be 'first' or 'last'"));
782 $<sigtype>$ = SIGNAL_LAST_METHOD;
785 /* the_scope was default thus public */
786 the_scope = PUBLIC_SCOPE;
790 sigtype: TOKEN '(' tokenlist ')' {
791 gtktypes = g_list_prepend(gtktypes, $<id>1);
795 tokenlist: tokenlist ',' TOKEN {
796 gtktypes = g_list_append(gtktypes, $<id>3);
799 gtktypes = g_list_append(gtktypes, $<id>1);
803 codenocode: '{' CCODE { $<cbuf>$ = $<cbuf>2; }
804 | ';' { $<cbuf>$ = NULL; }
807 /*here CCODE will include the ending '}' */
808 method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' returnvals codenocode {
810 yyerror(_("signal without 'self' as "
812 free_all_global_state();
815 if(the_scope == CLASS_SCOPE) {
816 yyerror(_("a method cannot be of class scope"));
817 free_all_global_state();
820 push_function(the_scope, $<sigtype>3,NULL,
821 $<id>5, $<cbuf>10,$<line>1,
822 ccode_line, vararg, $<list>2);
824 | scope SIGNAL flags simplesigtype 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>4, NULL,
837 $<id>6, $<cbuf>11, $<line>2,
838 ccode_line, vararg, $<list>3);
840 | VIRTUAL scope type TOKEN '(' funcargs ')' returnvals codenocode {
842 yyerror(_("virtual method 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, VIRTUAL_METHOD, NULL, $<id>4,
854 ccode_line, vararg, NULL);
856 | scope VIRTUAL 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 | VIRTUAL type TOKEN '(' funcargs ')' returnvals codenocode {
874 yyerror(_("virtual method without 'self' as "
876 free_all_global_state();
879 push_function(PUBLIC_SCOPE, VIRTUAL_METHOD, NULL,
880 $<id>3, $<cbuf>8, $<line>1,
881 ccode_line, vararg, NULL);
883 | OVERRIDE '(' TYPETOKEN ')' type TOKEN '(' funcargs ')' returnvals codenocode {
884 push_function(NO_SCOPE, OVERRIDE_METHOD, $<id>3,
886 $<line>1, ccode_line,
889 | scope type TOKEN '(' funcargs ')' returnvals codenocode {
890 if(the_scope == CLASS_SCOPE) {
891 yyerror(_("a method cannot be of class scope"));
892 free_all_global_state();
895 push_function(the_scope, REGULAR_METHOD, NULL, $<id>3,
896 $<cbuf>8, $<line>1, ccode_line,
899 | TOKEN '(' TOKEN ')' codenocode {
900 if(strcmp($<id>1, "init")==0) {
901 push_init_arg($<id>3,FALSE);
902 push_function(NO_SCOPE, INIT_METHOD, NULL,
903 $<id>1, $<cbuf>5, $<line>2,
904 ccode_line, FALSE, NULL);
905 } else if(strcmp($<id>1, "class_init")==0) {
906 push_init_arg($<id>3,TRUE);
907 push_function(NO_SCOPE, CLASS_INIT_METHOD, NULL,
908 $<id>1, $<cbuf>5, $<line>2,
909 ccode_line, FALSE, NULL);
913 g_string_free($<cbuf>5,TRUE);
914 yyerror(_("parse error "
915 "(untyped blocks must be init or "
922 returnvals: TOKEN retcode {
923 g_free(onerror); onerror = NULL;
924 g_free(defreturn); defreturn = NULL;
925 if(!set_return_value($<id>1, $<id>2)) {
928 yyerror(_("parse error"));
933 | TOKEN retcode TOKEN retcode {
934 g_free(onerror); onerror = NULL;
935 g_free(defreturn); defreturn = NULL;
936 if(!set_return_value($<id>1, $<id>2)) {
937 g_free($<id>1); g_free($<id>2);
938 g_free($<id>3); g_free($<id>4);
939 yyerror(_("parse error"));
942 if(!set_return_value($<id>3, $<id>4)) {
943 onerror = defreturn = NULL;
944 g_free($<id>1); g_free($<id>2);
945 g_free($<id>3); g_free($<id>4);
946 yyerror(_("parse error"));
953 g_free(onerror); onerror = NULL;
954 g_free(defreturn); defreturn = NULL;
958 retcode: numtok { $<id>$ = $<id>1; }
960 $<id>$ = ($<cbuf>3)->str;
961 g_string_free($<cbuf>3, FALSE);
965 funcargs: VOID { vararg = FALSE; has_self = FALSE; }
969 if(strcmp($<id>1,"self")==0)
970 push_self($<id>1, FALSE);
973 yyerror(_("parse error"));
980 if(strcmp($<id>1,"self")==0)
981 push_self($<id>1, TRUE);
984 yyerror(_("parse error"));
991 if(strcmp($<id>2,"self")==0)
992 push_self($<id>2, TRUE);
995 yyerror(_("parse error"));
999 | TOKEN ',' arglist {
1001 if(strcmp($<id>1,"self")==0)
1002 push_self($<id>1, FALSE);
1005 yyerror(_("parse error"));
1009 | TOKEN CONST ',' arglist {
1011 if(strcmp($<id>1,"self")==0)
1012 push_self($<id>1, TRUE);
1015 yyerror(_("parse error"));
1019 | CONST TOKEN ',' arglist {
1021 if(strcmp($<id>2,"self")==0)
1022 push_self($<id>2, TRUE);
1025 yyerror(_("parse error"));
1029 | arglist { has_self = FALSE; }
1032 arglist: arglist1 ',' THREEDOTS { vararg = TRUE; }
1033 | arglist1 { vararg = FALSE; }
1036 arglist1: arglist1 ',' arg { ; }
1041 push_funcarg($<id>2,NULL);
1043 | type TOKEN ARRAY_DIM {
1044 push_funcarg($<id>2,$<id>3);
1046 | type TOKEN '(' TOKEN checklist ')' {
1047 if(strcmp($<id>4,"check")!=0) {
1048 yyerror(_("parse error"));
1052 push_funcarg($<id>2,NULL);
1054 | type TOKEN ARRAY_DIM '(' TOKEN checklist ')' {
1055 if(strcmp($<id>5,"check")!=0) {
1056 yyerror(_("parse error"));
1060 push_funcarg($<id>2,$<id>3);
1064 checklist: checklist check { ; }
1069 if(strcmp($<id>1,"type")==0) {
1070 Node *node = new_check(TYPE_CHECK,NULL);
1071 checks = g_list_append(checks,node);
1072 } else if(strcmp($<id>1,"null")==0) {
1073 Node *node = new_check(NULL_CHECK,NULL);
1074 checks = g_list_append(checks,node);
1076 yyerror(_("parse error"));
1082 Node *node = new_check(GT_CHECK,$<id>2);
1083 checks = g_list_append(checks,node);
1086 Node *node = new_check(LT_CHECK,$<id>2);
1087 checks = g_list_append(checks,node);
1090 Node *node = new_check(GE_CHECK,$<id>3);
1091 checks = g_list_append(checks,node);
1094 Node *node = new_check(LE_CHECK,$<id>3);
1095 checks = g_list_append(checks,node);
1098 Node *node = new_check(EQ_CHECK,$<id>3);
1099 checks = g_list_append(checks,node);
1102 Node *node = new_check(NE_CHECK,$<id>3);
1103 checks = g_list_append(checks,node);
1107 numtok: NUMBER { $<id>$ = $<id>1; }
1109 $<id>$ = g_strconcat("-",$<id>2,NULL);
1112 | TOKEN { $<id>$ = $<id>1; }