-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstew.cpp
More file actions
59 lines (53 loc) · 984 Bytes
/
stew.cpp
File metadata and controls
59 lines (53 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <cstdint>
#include <iostream>
#include <string>
#include <map>
#include <fstream>
#include <algorithm>
#include "cpu.h"
#include "memory.h"
#include "command.h"
#include "instruction.h"
#include "lineparser.h"
#include "stew.h"
CPU *cpu;
class StewLineParser : public LineParser
{
public:
using LineParser::LineParser;
bool IsSeparator(char c) override;
void ErrOutput(const std::string& msg) override;
};
void StewLineParser::ErrOutput(const std::string& msg)
{
std::cerr << msg << std::endl;
}
bool StewLineParser::IsSeparator(char c)
{
if (Done() || isspace(c))
{
return true;
}
return false;
}
int main()
{
Memory mem(0, 1 * 1024 * 1024);
cpu = new CPU(mem, 0);
InitCommands();
for(;;)
{
std::cout << ". " << std::flush;
std::string line;
if (!std::getline(std::cin, line))
{
std::cout << "<EOF>" << std::endl;
break;
}
StewLineParser lp(line);
if (Command(lp))
{
break;
}
}
}