From c841cfe680eff1b446672a73b181532f82597ccb Mon Sep 17 00:00:00 2001 From: Karma Riuk Date: Tue, 15 Jul 2025 20:21:53 +0200 Subject: [PATCH] made the RLPL (read-lex-print-loop) become a RPPL (read-parse-print-loop) --- src/repl/repl.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/repl/repl.cpp b/src/repl/repl.cpp index 55aa3ff..efc997a 100644 --- a/src/repl/repl.cpp +++ b/src/repl/repl.cpp @@ -1,7 +1,10 @@ #include "repl.hpp" +#include "ast/program.hpp" #include "lexer/lexer.hpp" +#include "parser/parser.hpp" +#include #include #include @@ -19,11 +22,14 @@ namespace repl { std::istringstream ss(line); lexer::lexer l{ss}; - for (token::token tok = l.next_token(); - tok.type != token::type::END_OF_FILE; - tok = l.next_token()) - out << tok << " "; - out << std::endl; + parser::parser p{l}; + std::unique_ptr program = p.parse_program(); + if (!p.errors.empty()) { + for (auto& e : p.errors) + out << e->what() << std::endl; + continue; + } + out << program->str() << std::endl; } }