Merge pull request #256 from vvakame/impl-ts
[jackhill/mal.git] / cpp / step0_repl.cpp
CommitLineData
9ddaa0b9
ST
1#include "String.h"
2#include "ReadLine.h"
3
4#include <iostream>
5#include <memory>
6
7String READ(const String& input);
8String EVAL(const String& ast);
9String PRINT(const String& ast);
10String rep(const String& input);
11
12static ReadLine s_readLine("~/.mal-history");
13
14int main(int argc, char* argv[])
15{
16 String prompt = "user> ";
17 String input;
18 while (s_readLine.get(prompt, input)) {
19 std::cout << rep(input) << "\n";
20 }
21 return 0;
22}
23
24String rep(const String& input)
25{
26 return PRINT(EVAL(READ(input)));
27}
28
29String READ(const String& input)
30{
31 return input;
32}
33
34String EVAL(const String& ast)
35{
36 return ast;
37}
38
39String PRINT(const String& ast)
40{
41 return ast;
42}