txlyre há 1 dia atrás
pai
commit
7dcc39d84b
1 ficheiros alterados com 27 adições e 27 exclusões
  1. 27 27
      qic.c

+ 27 - 27
qic.c

@@ -1619,48 +1619,48 @@ node_t *parse_func(list_t *tokens, size_t *pos, int is_expr) {
     name = tokens->data[(*pos)++];
   }
 
-  EXPECT(LPAR, "(");
-
   table_t *params = NULL;
 
-  if (!AT(RPAR)) {
-    int flag = 0;
+  if (MATCH(LPAR)) {
+    if (!AT(RPAR)) {
+      int flag = 0;
 
-    params = table_new();
+      params = table_new();
 
-    size_t argc = 0;
+      size_t argc = 0;
 
-    do {
-      if(!AT(NAME))
-        PARSE_ERROR("expected identifier");
+      do {
+        if(!AT(NAME))
+          PARSE_ERROR("expected identifier");
 
-      char *l = ((token_t *)tokens->data[(*pos)++])->text;
-      node_t *r = NULL;
+        char *l = ((token_t *)tokens->data[(*pos)++])->text;
+        node_t *r = NULL;
 
-      if (!flag && AT(ASSIGN))
-        flag = 1;
+        if (!flag && AT(ASSIGN))
+          flag = 1;
 
-      if (flag) {
-        EXPECT(ASSIGN, "=");
+        if (flag) {
+          EXPECT(ASSIGN, "=");
 
-        r = parse_expr(tokens, pos);
-      }
+          r = parse_expr(tokens, pos);
+        }
 
-      list_t *pair = list_new();
+        list_t *pair = list_new();
 
-      size_t *argcp = malloc(sizeof(size_t));
-      memcpy(argcp, &argc, sizeof(size_t));
+        size_t *argcp = malloc(sizeof(size_t));
+        memcpy(argcp, &argc, sizeof(size_t));
 
-      argc++;
+        argc++;
 
-      list_push(pair, argcp);
-      list_push(pair, r);
+        list_push(pair, argcp);
+        list_push(pair, r);
 
-      table_set(params, l, pair);
-    } while (MATCH(COMMA));
-  }
+        table_set(params, l, pair);
+      } while (MATCH(COMMA));
+    }
 
-  EXPECT(RPAR, ")");
+    EXPECT(RPAR, ")");
+  }
 
   table_t *captured = NULL;