made the RLPL (read-lex-print-loop) become a

RPPL (read-parse-print-loop)
This commit is contained in:
Karma Riuk
2025-07-15 20:21:53 +02:00
parent 20b2c4a818
commit c841cfe680

View File

@@ -1,7 +1,10 @@
#include "repl.hpp"
#include "ast/program.hpp"
#include "lexer/lexer.hpp"
#include "parser/parser.hpp"
#include <memory>
#include <sstream>
#include <string>
@@ -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<ast::program> program = p.parse_program();
if (!p.errors.empty()) {
for (auto& e : p.errors)
out << e->what() << std::endl;
continue;
}
out << program->str() << std::endl;
}
}