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 error_print(GOB_WARN, line_no,
145 _("The number of GTK arguments and "
146 "function arguments for a signal "
147 "don't seem to match"));
149 if(g_list_length(gtktypes) > 2) {
151 for(li = gtktypes->next; li; li = li->next) {
152 if(strcmp(li->data, "NONE")==0) {
153 error_print(GOB_ERROR, line_no,
154 _("NONE can only appear in an "
155 "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)
256 for(li = class_nodes; li != NULL; li = li->next) {
258 Node *node = li->data;
259 if(node->type != VARIABLE_NODE)
262 if(strcmp(var->id, id)==0)
266 error_printf(GOB_ERROR, line, _("Variable %s not defined here"), id);
268 g_assert_not_reached();
273 set_return_value(char *type, char *val)
275 if(strcmp(type, "onerror")==0) {
281 } else if(strcmp(type, "defreturn")==0) {
302 %token CONST VOID STRUCT UNION ENUM THREEDOTS
303 %token SIGNED UNSIGNED LONG SHORT INT FLOAT DOUBLE CHAR
305 %token <id> TOKEN NUMBER TYPETOKEN ARRAY_DIM
306 %token <cbuf> CCODE HTCODE PHCODE HCODE ACODE ATCODE
307 %token <line> PUBLIC PRIVATE PROTECTED CLASSWIDE ARGUMENT VIRTUAL SIGNAL OVERRIDE
311 prog: ccodes class ccodes { ; }
318 Node *node = new_ccode(C_CCODE,($<cbuf>1)->str,
320 nodes = g_list_append(nodes,node);
321 g_string_free($<cbuf>1,FALSE);
324 Node *node = new_ccode(H_CCODE,($<cbuf>1)->str,
326 nodes = g_list_append(nodes,node);
327 g_string_free($<cbuf>1,FALSE);
330 Node *node = new_ccode(HT_CCODE,($<cbuf>1)->str,
332 nodes = g_list_append(nodes,node);
333 g_string_free($<cbuf>1,FALSE);
336 Node *node = new_ccode(PH_CCODE,($<cbuf>1)->str,
338 nodes = g_list_append(nodes,node);
339 g_string_free($<cbuf>1,FALSE);
342 Node *node = new_ccode(A_CCODE,($<cbuf>1)->str,
344 nodes = g_list_append(nodes,node);
345 g_string_free($<cbuf>1,FALSE);
348 Node *node = new_ccode(AT_CCODE,($<cbuf>1)->str,
350 nodes = g_list_append(nodes,node);
351 g_string_free($<cbuf>1,FALSE);
355 ccodes: ccodes ccode { ; }
359 class: classdec '{' classcode '}' {
360 ((Class *)class)->nodes = class_nodes;
362 nodes = g_list_append(nodes,class);
365 ((Class *)class)->nodes = NULL;
367 nodes = g_list_append(nodes,class);
371 classdec: CLASS TYPETOKEN FROM TYPETOKEN chunk {
372 class = new_class($<id>2,$<id>4,chunk_size,NULL);
377 | '(' TOKEN TOKEN ')' {
378 if(strcmp($<id>2,"chunks") == 0) {
379 chunk_size = g_strdup($<id>4);
381 yyerror(_("parse error"));
385 | '(' TOKEN NUMBER ')' {
386 if(strcmp($<id>2,"chunks") == 0) {
387 if(atoi($<id>4) != 0)
388 chunk_size = g_strdup($<id>4);
390 yyerror(_("parse error"));
396 classcode: classcode thing { ; }
406 scope: PUBLIC { the_scope = PUBLIC_SCOPE; }
407 | PRIVATE { the_scope = PRIVATE_SCOPE; }
408 | PROTECTED { the_scope = PROTECTED_SCOPE; }
409 | CLASSWIDE { the_scope = CLASS_SCOPE; }
412 destructor: TOKEN TOKEN {
413 if(strcmp($<id>1, "destroywith")==0) {
416 destructor_line = line_no;
417 destructor_simple = TRUE;
421 yyerror(_("parse error"));
426 if(strcmp($<id>1, "destroy")==0) {
428 destructor = ($<cbuf>3)->str;
429 g_string_free($<cbuf>3, FALSE);
430 destructor_line = ccode_line;
431 destructor_simple = FALSE;
434 g_string_free($<cbuf>3, TRUE);
435 yyerror(_("parse error"));
441 initializer: '=' numtok {
442 initializer = $<id>2;
443 initializer_line = ccode_line;
446 initializer = ($<cbuf>3)->str;
447 initializer_line = ccode_line;
448 g_string_free($<cbuf>3, FALSE);
453 varoptions: destructor initializer { ; }
454 | initializer destructor { ; }
455 | initializer { destructor = NULL; }
456 | destructor { initializer = NULL; }
463 variable: scope type TOKEN varoptions ';' {
464 push_variable($<id>3, the_scope,$<line>1, NULL);
466 | scope type TOKEN ARRAY_DIM varoptions ';' {
467 push_variable($<id>3, the_scope, $<line>1, $<id>4);
470 argument: ARGUMENT flags argtype TOKEN TOKEN '{' CCODE TOKEN '{' CCODE ';' {
471 if(strcmp($<id>5,"get")==0 &&
472 strcmp($<id>8,"set")==0) {
474 Type *type = pop_type();
475 g_free($<id>5); g_free($<id>8);
476 node = new_argument($<id>3,type,$<list>2,$<id>4,
477 ($<cbuf>7)->str,$<line>6,
478 ($<cbuf>10)->str,$<line>9,
480 g_string_free($<cbuf>7,FALSE);
481 g_string_free($<cbuf>10,FALSE);
482 class_nodes = g_list_append(class_nodes,node);
483 } else if(strcmp($<id>5,"set")==0 &&
484 strcmp($<id>8,"get")==0) {
486 Type *type = pop_type();
487 g_free($<id>5); g_free($<id>8);
488 node = new_argument($<id>3,type,$<list>2,$<id>4,
489 ($<cbuf>10)->str,$<line>9,
490 ($<cbuf>7)->str,$<line>6,
492 g_string_free($<cbuf>10,FALSE);
493 g_string_free($<cbuf>7,FALSE);
494 class_nodes = g_list_append(class_nodes,node);
496 g_free($<id>3); g_free($<id>4);
497 g_free($<id>5); g_free($<id>8);
498 g_list_foreach($<list>2,(GFunc)g_free,NULL);
499 g_list_free($<list>2);
500 g_string_free($<cbuf>10,TRUE);
501 g_string_free($<cbuf>7,TRUE);
502 yyerror(_("parse error"));
506 | ARGUMENT flags argtype TOKEN TOKEN '{' CCODE ';' {
507 if(strcmp($<id>5, "get") == 0) {
509 Type *type = pop_type();
511 node = new_argument($<id>3, type, $<list>2, $<id>4,
512 ($<cbuf>7)->str, $<line>6,
514 g_string_free($<cbuf>7, FALSE);
515 class_nodes = g_list_append(class_nodes, node);
516 } else if(strcmp($<id>5, "set") == 0) {
518 Type *type = pop_type();
520 node = new_argument($<id>3, type, $<list>2, $<id>4,
521 NULL, 0, ($<cbuf>7)->str,
523 g_string_free($<cbuf>7, FALSE);
524 class_nodes = g_list_append(class_nodes, node);
526 g_free($<id>5); g_free($<id>3);
528 g_list_foreach($<list>2, (GFunc)g_free, NULL);
529 g_list_free($<list>2);
530 g_string_free($<cbuf>7, TRUE);
531 yyerror(_("parse error"));
535 | ARGUMENT flags argtype TOKEN TOKEN {
537 char *get, *set = NULL;
542 if(strcmp($<id>5, "link")!=0 &&
543 strcmp($<id>5, "stringlink")!=0 &&
544 strcmp($<id>5, "objectlink")!=0) {
545 g_free($<id>5); g_free($<id>3);
547 g_list_foreach($<list>2,(GFunc)g_free,NULL);
548 g_list_free($<list>2);
549 yyerror(_("parse error"));
555 var = find_var_or_die($<id>4, $<line>1);
556 if(var->scope == PRIVATE_SCOPE)
557 root = "self->_priv";
558 else if(var->scope == CLASS_SCOPE) {
559 root = "SELF_GET_CLASS(self)";
561 error_print(GOB_ERROR, $<line>1,
562 _("Self aliases needed when autolinking to a classwide member"));
566 if(strcmp($<id>5, "link")==0) {
567 set = g_strdup_printf("%s->%s = ARG;",
569 } else if(strcmp($<id>5, "stringlink")==0) {
570 set = g_strdup_printf("g_free(%s->%s); "
571 "%s->%s = g_strdup(ARG);",
574 } else if(strcmp($<id>5, "objectlink")==0) {
575 set = g_strdup_printf(
577 "gtk_object_unref(GTK_OBJECT(%s->%s)); "
580 "gtk_object_ref(GTK_OBJECT(%s->%s));",
587 g_assert_not_reached();
590 if(strcmp($<id>5, "stringlink")==0) {
591 get = g_strdup_printf("ARG = g_strdup(%s->%s);", root, $<id>4);
593 /* For everything else, get is just straight assignment */
594 get = g_strdup_printf("ARG = %s->%s;", root, $<id>4);
600 type = copy_type(var->vtype);
602 node = new_argument($<id>3, type, $<list>2,
603 $<id>4, get, $<line>1,
604 set, $<line>1, $<line>1);
605 class_nodes = g_list_append(class_nodes,node);
609 argtype: TOKEN '(' TOKEN type ')' {
610 if(strcmp($<id>3,"type")!=0) {
613 yyerror(_("parse error"));
620 typestack = g_list_prepend(typestack,NULL);
624 flags: '(' flaglist ')' { $<list>$ = $<list>2; }
625 | { $<list>$ = NULL; }
628 flaglist: TOKEN '|' flaglist {
629 $<list>$ = g_list_append($<list>3,$<id>1);
632 $<list>$ = g_list_append(NULL,$<id>1);
637 type: specifier_list pointer {
638 Node *node = new_type($<id>1, $<id>2, NULL);
639 typestack = g_list_prepend(typestack,node);
642 Node *node = new_type($<id>1, NULL, NULL);
643 typestack = g_list_prepend(typestack,node);
647 /* The special cases are neccessary to avoid conflicts */
648 specifier_list: spec_list {
655 $<id>$ = g_strconcat("const ", $<id>2, NULL);
659 $<id>$ = g_strconcat($<id>1, " const", NULL);
662 | strunionenum TOKEN {
663 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
666 | CONST strunionenum TOKEN {
667 $<id>$ = g_strconcat("const ", $<id>2, " ",
671 | strunionenum TOKEN CONST {
672 $<id>$ = g_strconcat($<id>1, " ",
673 $<id>2, " const", NULL);
678 /* The special const cases take care of conflicts ! */
679 spec_list: specifier spec_list {
680 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
683 | TYPETOKEN spec_list {
684 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
689 $<id>$ = g_strconcat("const ", $<id>2, NULL);
696 $<id>$ = g_strconcat($<id>1, " const", NULL);
700 $<id>$ = g_strdup($<id>1);
703 $<id>$ = g_strconcat($<id>1, " const", NULL);
707 specifier: VOID { $<id>$ = "void"; }
708 | CHAR { $<id>$ = "char"; }
709 | SHORT { $<id>$ = "short"; }
710 | INT { $<id>$ = "int"; }
711 | LONG { $<id>$ = "long"; }
712 | FLOAT { $<id>$ = "float"; }
713 | DOUBLE { $<id>$ = "double"; }
714 | SIGNED { $<id>$ = "signed"; }
715 | UNSIGNED { $<id>$ = "unsigned"; }
718 strunionenum: STRUCT { $<id>$ = "struct"; }
719 | UNION { $<id>$ = "union"; }
720 | ENUM { $<id>$ = "enum"; }
723 pointer: '*' { $<id>$ = g_strdup("*"); }
724 | '*' CONST { $<id>$ = g_strdup("* const"); }
726 $<id>$ = g_strconcat("*", $<id>2, NULL);
729 | '*' CONST pointer {
730 $<id>$ = g_strconcat("* const", $<id>3, NULL);
735 /* this never sets the_scope */
736 simplesigtype: TOKEN sigtype {
737 if(strcmp($<id>1, "first")==0)
738 $<sigtype>$ = SIGNAL_FIRST_METHOD;
739 else if(strcmp($<id>1, "last")==0)
740 $<sigtype>$ = SIGNAL_LAST_METHOD;
742 yyerror(_("signal must be 'first' or 'last'"));
749 $<sigtype>$ = SIGNAL_LAST_METHOD;
753 /* this always sets the_scope */
754 fullsigtype: scope TOKEN sigtype {
755 if(strcmp($<id>2,"first")==0)
756 $<sigtype>$ = SIGNAL_FIRST_METHOD;
757 else if(strcmp($<id>2,"last")==0)
758 $<sigtype>$ = SIGNAL_LAST_METHOD;
760 yyerror(_("signal must be 'first' or 'last'"));
766 | TOKEN scope sigtype {
767 if(strcmp($<id>1,"first")==0)
768 $<sigtype>$ = SIGNAL_FIRST_METHOD;
769 else if(strcmp($<id>1,"last")==0)
770 $<sigtype>$ = SIGNAL_LAST_METHOD;
772 yyerror(_("signal must be 'first' or 'last'"));
779 $<sigtype>$ = SIGNAL_LAST_METHOD;
782 /* the_scope was default thus public */
783 the_scope = PUBLIC_SCOPE;
787 sigtype: TOKEN '(' tokenlist ')' {
788 gtktypes = g_list_prepend(gtktypes, $<id>1);
792 tokenlist: tokenlist ',' TOKEN {
793 gtktypes = g_list_append(gtktypes, $<id>3);
796 gtktypes = g_list_append(gtktypes, $<id>1);
800 codenocode: '{' CCODE { $<cbuf>$ = $<cbuf>2; }
801 | ';' { $<cbuf>$ = NULL; }
804 /*here CCODE will include the ending '}' */
805 method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' returnvals codenocode {
807 yyerror(_("signal without 'self' as "
809 free_all_global_state();
812 if(the_scope == CLASS_SCOPE) {
813 yyerror(_("a method cannot be of class scope"));
814 free_all_global_state();
817 push_function(the_scope, $<sigtype>3,NULL,
818 $<id>5, $<cbuf>10,$<line>1,
819 ccode_line, vararg, $<list>2);
821 | scope SIGNAL flags simplesigtype type TOKEN '(' funcargs ')' returnvals codenocode {
823 yyerror(_("signal without 'self' as "
825 free_all_global_state();
828 if(the_scope == CLASS_SCOPE) {
829 yyerror(_("a method cannot be of class scope"));
830 free_all_global_state();
833 push_function(the_scope, $<sigtype>4, NULL,
834 $<id>6, $<cbuf>11, $<line>2,
835 ccode_line, vararg, $<list>3);
837 | VIRTUAL scope type TOKEN '(' funcargs ')' returnvals codenocode {
839 yyerror(_("virtual method without 'self' as "
841 free_all_global_state();
844 if(the_scope == CLASS_SCOPE) {
845 yyerror(_("a method cannot be of class scope"));
846 free_all_global_state();
849 push_function(the_scope, VIRTUAL_METHOD, NULL, $<id>4,
851 ccode_line, vararg, NULL);
853 | scope VIRTUAL type TOKEN '(' funcargs ')' returnvals codenocode {
855 yyerror(_("virtual method without 'self' as "
857 free_all_global_state();
860 if(the_scope == CLASS_SCOPE) {
861 yyerror(_("a method cannot be of class scope"));
862 free_all_global_state();
865 push_function(the_scope, VIRTUAL_METHOD, NULL, $<id>4,
867 ccode_line, vararg, NULL);
869 | VIRTUAL type TOKEN '(' funcargs ')' returnvals codenocode {
871 yyerror(_("virtual method without 'self' as "
873 free_all_global_state();
876 push_function(PUBLIC_SCOPE, VIRTUAL_METHOD, NULL,
877 $<id>3, $<cbuf>8, $<line>1,
878 ccode_line, vararg, NULL);
880 | OVERRIDE '(' TYPETOKEN ')' type TOKEN '(' funcargs ')' returnvals codenocode {
881 push_function(NO_SCOPE, OVERRIDE_METHOD, $<id>3,
883 $<line>1, ccode_line,
886 | scope type TOKEN '(' funcargs ')' returnvals codenocode {
887 if(the_scope == CLASS_SCOPE) {
888 yyerror(_("a method cannot be of class scope"));
889 free_all_global_state();
892 push_function(the_scope, REGULAR_METHOD, NULL, $<id>3,
893 $<cbuf>8, $<line>1, ccode_line,
896 | TOKEN '(' TOKEN ')' codenocode {
897 if(strcmp($<id>1, "init")==0) {
898 push_init_arg($<id>3,FALSE);
899 push_function(NO_SCOPE, INIT_METHOD, NULL,
900 $<id>1, $<cbuf>5, $<line>2,
901 ccode_line, FALSE, NULL);
902 } else if(strcmp($<id>1, "class_init")==0) {
903 push_init_arg($<id>3,TRUE);
904 push_function(NO_SCOPE, CLASS_INIT_METHOD, NULL,
905 $<id>1, $<cbuf>5, $<line>2,
906 ccode_line, FALSE, NULL);
910 g_string_free($<cbuf>5,TRUE);
911 yyerror(_("parse error "
912 "(untyped blocks must be init or "
919 returnvals: TOKEN retcode {
920 g_free(onerror); onerror = NULL;
921 g_free(defreturn); defreturn = NULL;
922 if(!set_return_value($<id>1, $<id>2)) {
925 yyerror(_("parse error"));
930 | TOKEN retcode TOKEN retcode {
931 g_free(onerror); onerror = NULL;
932 g_free(defreturn); defreturn = NULL;
933 if(!set_return_value($<id>1, $<id>2)) {
934 g_free($<id>1); g_free($<id>2);
935 g_free($<id>3); g_free($<id>4);
936 yyerror(_("parse error"));
939 if(!set_return_value($<id>3, $<id>4)) {
940 onerror = defreturn = NULL;
941 g_free($<id>1); g_free($<id>2);
942 g_free($<id>3); g_free($<id>4);
943 yyerror(_("parse error"));
950 g_free(onerror); onerror = NULL;
951 g_free(defreturn); defreturn = NULL;
955 retcode: numtok { $<id>$ = $<id>1; }
957 $<id>$ = ($<cbuf>3)->str;
958 g_string_free($<cbuf>3, FALSE);
962 funcargs: VOID { vararg = FALSE; has_self = FALSE; }
966 if(strcmp($<id>1,"self")==0)
967 push_self($<id>1, FALSE);
970 yyerror(_("parse error"));
977 if(strcmp($<id>1,"self")==0)
978 push_self($<id>1, TRUE);
981 yyerror(_("parse error"));
988 if(strcmp($<id>2,"self")==0)
989 push_self($<id>2, TRUE);
992 yyerror(_("parse error"));
996 | TOKEN ',' arglist {
998 if(strcmp($<id>1,"self")==0)
999 push_self($<id>1, FALSE);
1002 yyerror(_("parse error"));
1006 | TOKEN CONST ',' arglist {
1008 if(strcmp($<id>1,"self")==0)
1009 push_self($<id>1, TRUE);
1012 yyerror(_("parse error"));
1016 | CONST TOKEN ',' arglist {
1018 if(strcmp($<id>2,"self")==0)
1019 push_self($<id>2, TRUE);
1022 yyerror(_("parse error"));
1026 | arglist { has_self = FALSE; }
1029 arglist: arglist1 ',' THREEDOTS { vararg = TRUE; }
1030 | arglist1 { vararg = FALSE; }
1033 arglist1: arglist1 ',' arg { ; }
1038 push_funcarg($<id>2,NULL);
1040 | type TOKEN ARRAY_DIM {
1041 push_funcarg($<id>2,$<id>3);
1043 | type TOKEN '(' TOKEN checklist ')' {
1044 if(strcmp($<id>4,"check")!=0) {
1045 yyerror(_("parse error"));
1049 push_funcarg($<id>2,NULL);
1051 | type TOKEN ARRAY_DIM '(' TOKEN checklist ')' {
1052 if(strcmp($<id>5,"check")!=0) {
1053 yyerror(_("parse error"));
1057 push_funcarg($<id>2,$<id>3);
1061 checklist: checklist check { ; }
1066 if(strcmp($<id>1,"type")==0) {
1067 Node *node = new_check(TYPE_CHECK,NULL);
1068 checks = g_list_append(checks,node);
1069 } else if(strcmp($<id>1,"null")==0) {
1070 Node *node = new_check(NULL_CHECK,NULL);
1071 checks = g_list_append(checks,node);
1073 yyerror(_("parse error"));
1079 Node *node = new_check(GT_CHECK,$<id>2);
1080 checks = g_list_append(checks,node);
1083 Node *node = new_check(LT_CHECK,$<id>2);
1084 checks = g_list_append(checks,node);
1087 Node *node = new_check(GE_CHECK,$<id>3);
1088 checks = g_list_append(checks,node);
1091 Node *node = new_check(LE_CHECK,$<id>3);
1092 checks = g_list_append(checks,node);
1095 Node *node = new_check(EQ_CHECK,$<id>3);
1096 checks = g_list_append(checks,node);
1099 Node *node = new_check(NE_CHECK,$<id>3);
1100 checks = g_list_append(checks,node);
1104 numtok: NUMBER { $<id>$ = $<id>1; }
1106 $<id>$ = g_strconcat("-",$<id>2,NULL);
1109 | TOKEN { $<id>$ = $<id>1; }