moved headers around a bit

This commit is contained in:
Bob Polis 2020-09-22 13:38:17 +02:00
parent d1c4106bba
commit 0e735ce7a8
2 changed files with 4 additions and 5 deletions

View File

@ -9,7 +9,7 @@
#include "interpreter.hpp" #include "interpreter.hpp"
#include <cctype> #include <cctype>
#include <algorithm> #include <algorithm>
#include <iostream> #include <sstream>
int to_int(const std::string& val) { int to_int(const std::string& val) {
std::istringstream iss {val}; std::istringstream iss {val};

View File

@ -14,7 +14,6 @@
#include <vector> #include <vector>
#include <map> #include <map>
#include <stdexcept> #include <stdexcept>
#include <sstream>
class syntax_error : public std::runtime_error { class syntax_error : public std::runtime_error {
public: public:
@ -34,11 +33,11 @@ class interpreter {
private: private:
std::vector<std::string> _prog; // program lines without label defs or comments std::vector<std::string> _prog; // program lines without label defs or comments
std::vector<std::string> _values; // value stack std::vector<std::string> _values; // value stack
std::map<std::string, size_t> _labels; // label name => prog line index
std::map<std::string, std::string> _vars; // var name => string value
std::vector<size_t> _calls; // call stack std::vector<size_t> _calls; // call stack
std::map<std::string, size_t> _labels; // label name => prog line index
std::map<std::string, std::string> _vars; // variable name => string value
size_t _pc {0}; // current program counter (index into _prog) size_t _pc {0}; // current program counter (index into _prog)
std::vector<size_t> _pc_offsets; // removed line indices for prog index => source line std::vector<size_t> _pc_offsets; // removed line indices for: prog index => source line
void reset(); void reset();
void exec_instruction(const std::string& code, bool& done); void exec_instruction(const std::string& code, bool& done);