You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#include <cstdio>
|
|
|
|
#include <iostream> // std::cin
|
|
|
|
#include <string> // std::getline
|
|
|
|
#include <string_view>
|
|
|
|
|
|
|
|
#include "forward.h"
|
|
|
|
|
|
|
|
auto read(std::string_view data) -> std::string_view
|
|
|
|
{
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto eval(std::string_view data) -> std::string_view
|
|
|
|
{
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto print(std::string_view data) -> void
|
|
|
|
{
|
|
|
|
printf("%s\n", data.data());
|
|
|
|
}
|
|
|
|
|
|
|
|
auto rep(std::string_view data) -> void
|
|
|
|
{
|
|
|
|
print(eval(read(data)));
|
|
|
|
}
|
|
|
|
|
|
|
|
auto main() -> int
|
|
|
|
{
|
|
|
|
while (true) {
|
|
|
|
printf("user> ");
|
|
|
|
std::string line;
|
|
|
|
std::getline(std::cin, line);
|
|
|
|
|
|
|
|
// Exit with Ctrl-D
|
|
|
|
if (std::cin.eof() || std::cin.fail()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
rep(line);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Below is needed for compilation
|
|
|
|
namespace blaze {
|
|
|
|
|
|
|
|
auto read(std::string_view) -> ValuePtr
|
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
auto eval(ValuePtr, EnvironmentPtr) -> ValuePtr
|
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
// Added to keep the linker happy at step A
|
|
|
|
ValuePtr readline(const std::string&) { return nullptr; }
|
|
|
|
|
|
|
|
} // namespace blaze
|