From: Michael D. Lowis Date: Wed, 20 Jun 2018 20:15:05 +0000 (-0400) Subject: support parsing multiple files for binary and library targets X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=6d7a8066fac971b0b365eeffcebf4665053aa70c;p=proto%2Fsclpl.git support parsing multiple files for binary and library targets --- diff --git a/source/main.c b/source/main.c index 737f355..02638c5 100644 --- a/source/main.c +++ b/source/main.c @@ -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); diff --git a/source/parser.c b/source/parser.c index 99483da..ac282d2 100644 --- a/source/parser.c +++ b/source/parser.c @@ -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))