X-Git-Url: http://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/40647d7b7b7fbeae828e0a032a3c3a5f204cdfa8..f31590988781d77ff5249987801d03a986368ca2:/src/parse.y diff --git a/src/parse.y b/src/parse.y index 7d01a5d..b5d9f10 100644 --- a/src/parse.y +++ b/src/parse.y @@ -80,11 +80,13 @@ yyerror(char *str) } static void -push_variable(char *name, int scope, int line_no) +push_variable(char *name, int scope, int line_no, char *postfix) { Node *var; Type *type = typestack->data; typestack = g_list_remove(typestack,typestack->data); + + type->postfix = postfix; var = new_variable(scope,type,name,line_no); class_nodes = g_list_append(class_nodes, var); @@ -101,7 +103,7 @@ push_function(int scope, char *oid, char *id, char *onerror, type = typestack->data; typestack = g_list_remove(typestack,typestack->data); } else { - type = (Type *)new_type(0,g_strdup("void")); + type = (Type *)new_type(0,g_strdup("void"),NULL); } /* a complicated and ugly test to figure out if we have @@ -127,11 +129,13 @@ push_function(int scope, char *oid, char *id, char *onerror, } static void -push_funcarg(char *name) +push_funcarg(char *name, char *postfix) { Node *node; Type *type = typestack->data; typestack = g_list_remove(typestack,typestack->data); + + type->postfix = postfix; node = new_funcarg(type,name,checks); checks = NULL; @@ -151,7 +155,7 @@ push_init_arg(char *name, int is_class) else tn = g_strdup(((Class *)class)->otype); - type = new_type(1,tn); + type = new_type(1,tn,NULL); node = new_funcarg((Type *)type,name,NULL); funcargs = g_list_prepend(funcargs, node); } @@ -162,7 +166,7 @@ push_self(char *id) Node *node; Node *type; GList *ch = NULL; - type = new_type(1,g_strdup(((Class *)class)->otype)); + type = new_type(1,g_strdup(((Class *)class)->otype),NULL); ch = g_list_append(ch,new_check(NULL_CHECK,NULL)); ch = g_list_append(ch,new_check(TYPE_CHECK,NULL)); node = new_funcarg((Type *)type,id,ch); @@ -184,7 +188,7 @@ push_self(char *id) %token SIGNED UNSIGNED LONG SHORT INT FLOAT DOUBLE CHAR %token ONERROR -%token TOKEN NUMBER TYPETOKEN +%token TOKEN NUMBER TYPETOKEN ARRAY_DIM %token CCODE HCODE %token PUBLIC PRIVATE ARGUMENT VIRTUAL SIGNAL OVERRIDE @@ -235,11 +239,17 @@ classcode: classcode method { ; } ; variable: PUBLIC type TOKEN ';' { - push_variable($3,PUBLIC_SCOPE,$1); + push_variable($3,PUBLIC_SCOPE,$1,NULL); } - | PRIVATE type TOKEN ';' { - push_variable($3,PRIVATE_SCOPE,$1); + | PUBLIC type TOKEN ARRAY_DIM ';' { + push_variable($3,PUBLIC_SCOPE,$1,$4); } + | PRIVATE type TOKEN ';' { + push_variable($3,PRIVATE_SCOPE,$1,NULL); + } + | PRIVATE type TOKEN ARRAY_DIM ';' { + push_variable($3,PRIVATE_SCOPE,$1,$4); + } ; argument: ARGUMENT argflags TOKEN TOKEN TOKEN '{' CCODE TOKEN '{' CCODE ';' { if(strcmp($5,"get")==0 && @@ -319,11 +329,11 @@ type: type1 { ; } ; type1: type2 { - Node *node = new_type(0,$1); + Node *node = new_type(0,$1,NULL); typestack = g_list_prepend(typestack,node); } | type2 stars { - Node *node = new_type(stars,$1); + Node *node = new_type(stars,$1,NULL); stars = 0; typestack = g_list_prepend(typestack,node); } @@ -572,7 +582,10 @@ arglist1: arglist1 ',' arg { ; } ; arg: type TOKEN { - push_funcarg($2); + push_funcarg($2,NULL); + } + | type TOKEN ARRAY_DIM { + push_funcarg($2,$3); } | type TOKEN '(' TOKEN checklist ')' { if(strcmp($4,"check")!=0) { @@ -580,7 +593,15 @@ arg: type TOKEN { YYERROR; } g_free($4); - push_funcarg($2); + push_funcarg($2,NULL); + } + | type TOKEN ARRAY_DIM '(' TOKEN checklist ')' { + if(strcmp($5,"check")!=0) { + yyerror(_("parse error")); + YYERROR; + } + g_free($5); + push_funcarg($2,$3); } ;