]> git.mdlowis.com Git - proto/sclpl.git/commitdiff
support parsing multiple files for binary and library targets
authorMichael D. Lowis <mike.lowis@gentex.com>
Wed, 20 Jun 2018 20:15:05 +0000 (16:15 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Wed, 20 Jun 2018 20:15:05 +0000 (16:15 -0400)
source/main.c
source/parser.c

index 737f35574c1fb550c0aad36c76f31f102bceafde..02638c53a1663bfbe65a60a702d18c2459093325 100644 (file)
@@ -32,6 +32,7 @@ static int emit_binary(int argc, char **argv) {
         exit(1);
     }
     Parser ctx = {0};
+    codegen_init(&ctx);
     for (; argc; argc--,argv++) {
         ctx.input = fopen(*argv,"r");
         toplevel(&ctx);
@@ -46,6 +47,7 @@ static int emit_library(int argc, char **argv) {
         exit(1);
     }
     Parser ctx = {0};
+    codegen_init(&ctx);
     for (; argc; argc--,argv++) {
         ctx.input = fopen(*argv,"r");
         toplevel(&ctx);
index 99483da9ada28bac5b7b47748a0d68ad9de56cde..ac282d2ab907c323918aea8e46e1fb954cbe37ef 100644 (file)
@@ -75,6 +75,9 @@ static Tok* expect_val(Parser* p, TokType type) {
 /* Grammar Definition
  *****************************************************************************/
 AST* toplevel(Parser* p) {
+    extern FILE* yyin;
+    if (yyin != p->input)
+        yyin = p->input;
     if (matches(p, T_REQUIRES))
         require_list(p);
     if (matches(p, T_PROVIDES))