txlyre 2 dias atrás
pai
commit
863bc0b6dd
1 arquivos alterados com 16 adições e 9 exclusões
  1. 16 9
      qic.c

+ 16 - 9
qic.c

@@ -2271,12 +2271,16 @@ node_t *parse_program(list_t *tokens, size_t *pos) {
       if (flag)
         PARSE_ERROR("misplaced require statement")
 
-      if (!AT(STRING))
-        PARSE_ERROR("expected string");
+      list_t *paths = list_new();
 
-      token_t *path = tokens->data[(*pos)++];
+      do {
+        if (!AT(STRING))
+          PARSE_ERROR("expected string");
+
+        list_push(paths, tokens->data[(*pos)++]);
+      } while (MATCH(COMMA));
 
-      n = NODET(REQUIRE, path);
+      n = NODEL(REQUIRE, paths);
     } else if (MATCH(HEADER)) {
       if (flag)
         PARSE_ERROR("misplaced header statement")
@@ -4407,12 +4411,15 @@ void compile_node(buffer_t *gbuf, buffer_t *buf, list_t *ctx, table_t *ltab, sta
       EMIT("goto __label%d;", *gid);
       } break;
 
-    case N_REQUIRE: {
-      char *path = unescape(node->t->text);
+    case N_REQUIRE:
+      for (size_t i = 0; i < node->l->length; i++) {
+        token_t *t = node->l->data[i];
+        char *path = unescape(t->text);
 
-      if (require_once(gbuf, buf, ctx, ltab, lstk, sstk, lbl, path) < 0)
-        COMPILE_ERROR("'%s' is not a valid file path or a builtin library name", path);
-      } break;
+        if (require_once(gbuf, buf, ctx, ltab, lstk, sstk, lbl, path) < 0)
+          COMPILE_ERROR("'%s' is not a valid file path or a builtin library name", path);
+      }
+      break;
 
     case N_IFEXPR:
       EMIT("(_qi_truthy(state, ");