cl-repl: Perform module inlining before submitting code to the interpreter

This commit is contained in:
2024-07-11 02:50:15 -05:00
parent d692f6bb80
commit 5f57924f23
2 changed files with 18 additions and 0 deletions

View File

@@ -38,8 +38,12 @@ pub fn main_menu(ctx: &mut ctx::Context) -> ReplResult<()> {
}
pub fn run(ctx: &mut ctx::Context) -> ReplResult<()> {
use cl_ast::ast_visitor::Fold;
use cl_parser::inliner::ModuleInliner;
read_and(ansi::CYAN, "cl>", " ?>", |line| {
let code = Parser::new(Lexer::new(line)).stmt()?;
let code = ModuleInliner::new(".").fold_stmt(code);
print!("{}", ansi::OUTPUT);
match ctx.run(&code) {