From fe28816b5069a0cab5a71d366fb7ecbc4be00a64 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 14 May 2024 14:25:27 -0400 Subject: Fix REPL --- repl.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'repl.c') diff --git a/repl.c b/repl.c index 94b47e45..9f01c247 100644 --- a/repl.c +++ b/repl.c @@ -1,4 +1,4 @@ - +// A Read-Evaluate-Print-Loop #include #include #include @@ -58,12 +58,13 @@ void repl(void) fflush(stdout); } } else { - code = heap_strf(">> %s", code); + code = heap_strf("func main(): >> %s", code); } file_t *f = spoof_file("", code); ast_t *ast = parse_file(f, &on_err); - if (ast->tag == DocTest) ast->__data.DocTest.skip_source = 1; - run(env, ast); + ast_t *doctest = Match(Match(Match(ast, Block)->statements->ast, FunctionDef)->body, Block)->statements->ast; + if (doctest->tag == DocTest) doctest->__data.DocTest.skip_source = 1; + run(env, doctest); } printf("\x1b[33;1m>>\x1b[m "); fflush(stdout); -- cgit v1.2.3