partial start of implementation for interpreter

This commit is contained in:
Bob Polis 2020-09-06 12:57:28 +02:00
parent 431367cb40
commit 00d0eac893
2 changed files with 82 additions and 0 deletions

9
interpreter.cpp Normal file
View File

@ -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"

73
interpreter.hpp Normal file
View File

@ -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 <iostream>
#include <string>
#include <vector>
#include <map>
class interpreter {
public:
interpreter() = default;
std::string eval(std::istream& in);
private:
std::vector<std::string> _ops;
std::map<std::string, std::vector<std::string>> _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_