diff --git a/interpreter.cpp b/interpreter.cpp new file mode 100644 index 0000000..13b059c --- /dev/null +++ b/interpreter.cpp @@ -0,0 +1,9 @@ +// +// interpreter.cpp +// curly +// +// Created by Bob Polis at 2020-09-05 +// Copyright (c) 2020 SwiftCoder. All rights reserved. +// + +#include "interpreter.hpp" diff --git a/interpreter.hpp b/interpreter.hpp new file mode 100644 index 0000000..4e533de --- /dev/null +++ b/interpreter.hpp @@ -0,0 +1,73 @@ +// +// interpreter.hpp +// curly +// +// Created by Bob Polis at 2020-09-05 +// Copyright (c) 2020 SwiftCoder. All rights reserved. +// + +#ifndef _interpreter_H_ +#define _interpreter_H_ + +#include +#include +#include +#include + +class interpreter { + public: + interpreter() = default; + + std::string eval(std::istream& in); + + private: + std::vector _ops; + std::map> _funs; + + // integer operations + void add(); + void sub(); + void mul(); + void div(); + void mod(); + void abs(); + void neg(); + void dup(); + void inc(); + void dec(); + + // string operations + void rev(); + void slc(); + void idx(); + void cat(); + void len(); + void rot(); + + // tests + void teq(); + void tne(); + void tlt(); + void tle(); + void tgt(); + void tge(); + + // blocks + void end(); + + // conditionals + void ift(); + void els(); + + // loops + void whl(); + + // functions + void fun(); + void run(); + + // solution + void sol(); +}; + +#endif // _interpreter_H_