diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-05-14 14:25:27 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-05-14 14:25:27 -0400 |
| commit | fe28816b5069a0cab5a71d366fb7ecbc4be00a64 (patch) | |
| tree | cf2c65b39795980c94ae90b250134b6429bdffb8 | |
| parent | 77fb880cc42b87e0ef7a16638ebc52f27b1fd0ab (diff) | |
Fix REPL
| -rw-r--r-- | repl.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -1,4 +1,4 @@ - +// A Read-Evaluate-Print-Loop #include <dlfcn.h> #include <setjmp.h> #include <stdarg.h> @@ -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("<repl>", 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); |
