aboutsummaryrefslogtreecommitdiff
path: root/repl.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-07-05 15:51:23 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-07-05 15:51:23 -0400
commita86dc05d366c0733b645763dd5c3e7396041bd7b (patch)
tree409af6b99d0bb828ca44b75202e170dea87389b9 /repl.c
parente51e6f840cb2414cad6e816aea7adea74ee8b1b8 (diff)
Cache AST parsings so we don't have to re-parse files
Diffstat (limited to 'repl.c')
-rw-r--r--repl.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/repl.c b/repl.c
index d3d433dc..f4051451 100644
--- a/repl.c
+++ b/repl.c
@@ -60,8 +60,7 @@ void repl(void)
} else {
code = heap_strf("func main(): >> %s", code);
}
- file_t *f = spoof_file("<repl>", code);
- ast_t *ast = parse_file(f, &on_err);
+ ast_t *ast = parse_file(heap_strf("<code>%s", code), &on_err);
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);