a branflakes interpreter i used to play with c++
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

43 lines
664 B

#pragma once
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include "error.hpp"
enum class OpCode {
IncPtr, // >
DecPtr, // <
IncByte, // +
DecByte, // -
Write, // .
Read, // ,
LoopBegin, // [
LoopEnd // ]
};
const int TAPE_SIZE = 30000;
class Interpreter {
public:
Interpreter(void) {
throw ParseExcept(ErrType::NoInput);
}
Interpreter(std::vector<OpCode> v) {
prog = v;
}
void run();
private:
void processIndex(int);
std::vector<OpCode> prog;
std::stack<int> jump;
int ptr = 0;
std::vector<char> data_tape;
};