implemented very simple repl

This commit is contained in:
Karma Riuk
2025-07-01 18:43:25 +02:00
parent aee7a741b1
commit 69bee723a2
4 changed files with 42 additions and 3 deletions

30
src/repl/repl.cpp Normal file
View File

@@ -0,0 +1,30 @@
#include "repl.hpp"
#include "lexer/lexer.hpp"
#include <sstream>
#include <string>
static const std::string PROMPT = ">> ";
namespace repl {
void start(std::istream& in, std::ostream& out) {
while (true) {
out << PROMPT;
std::string line;
if (!std::getline(in, line))
return;
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;
}
}
} // namespace repl

6
src/repl/repl.hpp Normal file
View File

@@ -0,0 +1,6 @@
#include <istream>
#include <ostream>
namespace repl {
void start(std::istream&, std::ostream&);
}