]> git.draconx.ca Git - gob-dx.git/blobdiff - src/parse.y
Release 0.92.1
[gob-dx.git] / src / parse.y
index f4c4a409f7bfc7c5089813b8f3f452e813071ff5..c2c425320d63a236c9814ac6925d62a1e26573b5 100644 (file)
@@ -83,12 +83,19 @@ yyerror(char *str)
        exit(1);
 }
 
+static Type *
+pop_type(void)
+{
+       Type *type = typestack->data;
+       typestack = g_list_remove(typestack,typestack->data);
+       return type;
+}
+
 static void
 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 *type = pop_type();
 
        type->postfix = postfix;
        
@@ -105,8 +112,7 @@ push_function(int scope, int method, char *oid, char *id, char *onerror,
        char *c_cbuf;
        
        if(method!=INIT_METHOD && method!=CLASS_INIT_METHOD) {
-               type = typestack->data;
-               typestack = g_list_remove(typestack,typestack->data);
+               type = pop_type();
        } else {
                type = (Type *)new_type(0,g_strdup("void"),NULL);
        }
@@ -151,8 +157,7 @@ static void
 push_funcarg(char *name, char *postfix)
 {
        Node *node;
-       Type *type = typestack->data;
-       typestack = g_list_remove(typestack,typestack->data);
+       Type *type = pop_type();
 
        type->postfix = postfix;
        
@@ -280,12 +285,13 @@ variable: scope type TOKEN ';'            {
                        push_variable($<id>3,the_scope,$<line>1,$<id>4);
                                                }
        ;
-argument:      ARGUMENT argflags TOKEN TOKEN TOKEN '{' CCODE TOKEN '{' CCODE ';' {
+argument:      ARGUMENT argflags argtype TOKEN TOKEN '{' CCODE TOKEN '{' CCODE ';' {
                        if(strcmp($<id>5,"get")==0 &&
                           strcmp($<id>8,"set")==0) {
                                Node *node;
+                               Type *type = pop_type();
                                g_free($<id>5); g_free($<id>8);
-                               node = new_argument($<id>3,$<list>2,$<id>4,
+                               node = new_argument($<id>3,type,$<list>2,$<id>4,
                                                    ($<cbuf>7)->str,$<line>6,
                                                    ($<cbuf>10)->str,$<line>9,
                                                    $<line>1);
@@ -295,8 +301,9 @@ argument:   ARGUMENT argflags TOKEN TOKEN TOKEN '{' CCODE TOKEN '{' CCODE ';' {
                        } else if(strcmp($<id>5,"set")==0 &&
                                strcmp($<id>8,"get")==0) {
                                Node *node;
+                               Type *type = pop_type();
                                g_free($<id>5); g_free($<id>8);
-                               node = new_argument($<id>3,$<list>2,$<id>4,
+                               node = new_argument($<id>3,type,$<list>2,$<id>4,
                                                    ($<cbuf>10)->str,$<line>9,
                                                    ($<cbuf>7)->str,$<line>6,
                                                    $<line>1);
@@ -313,19 +320,21 @@ argument: ARGUMENT argflags TOKEN TOKEN TOKEN '{' CCODE TOKEN '{' CCODE ';' {
                                YYERROR;
                        }
                                                }
-       |       ARGUMENT argflags TOKEN TOKEN TOKEN '{' CCODE ';' {
+       |       ARGUMENT argflags argtype TOKEN TOKEN '{' CCODE ';' {
                        if(strcmp($<id>5,"get")==0) {
                                Node *node;
+                               Type *type = pop_type();
                                g_free($<id>5);
-                               node = new_argument($<id>3,$<list>2,$<id>4,
+                               node = new_argument($<id>3,type,$<list>2,$<id>4,
                                                    ($<cbuf>7)->str,$<line>6,
                                                    NULL,0, $<line>1);
                                g_string_free($<cbuf>7,FALSE);
                                class_nodes = g_list_append(class_nodes,node);
                        } else if(strcmp($<id>5,"set")==0) {
                                Node *node;
+                               Type *type = pop_type();
                                g_free($<id>5);
-                               node = new_argument($<id>3,$<list>2,$<id>4,
+                               node = new_argument($<id>3,type,$<list>2,$<id>4,
                                                    NULL,0,($<cbuf>7)->str,
                                                    $<line>6, $<line>1);
                                g_string_free($<cbuf>7,FALSE);
@@ -340,6 +349,21 @@ argument:  ARGUMENT argflags TOKEN TOKEN TOKEN '{' CCODE TOKEN '{' CCODE ';' {
                        }
                                                }
        ;
+
+argtype:       TOKEN '(' TOKEN type ')'        {
+                       if(strcmp($<id>3,"type")!=0) {
+                               g_free($<id>1);
+                               g_free($<id>3);
+                               yyerror(_("parse error"));
+                               YYERROR;
+                       }
+                       $<id>$ = $<id>1;
+                                               }
+       |       TOKEN                           {
+                       $<id>$ = $<id>1;
+                       typestack = g_list_prepend(typestack,NULL);
+                                               }
+       ;
        
 argflags:      '(' flaglist ')'                { $<list>$ = $<list>2; }
        |                                       { $<list>$ = NULL; }