Website Summary Files Commits Branches @commit @diff @stats
path: root / homework / 81568 / BF_Interpreter / bf_interpreter.h
diff options
context:
space:
mode:
Commit3e5cf5941db07bcd3527a73b62077d5277d57f2d (patch)
Author
 Mincho Paskalev <minchopaskal@gmail.com>
2018-11-28 09:42:47 +0200
Committer
 dtrendafilov <trendafilov.dn@gmail.com>
2018-11-28 09:42:47 +0200
Files1d3d4a9cecfd9d314905abc3af3dd54ac99a94aa /homework/81568/BF_Interpreter/bf_interpreter.h
IPL-3e5cf5941db07bcd3527a73b62077d5277d57f2d.tar
IPL-3e5cf5941db07bcd3527a73b62077d5277d57f2d.tar.gz
IPL-3e5cf5941db07bcd3527a73b62077d5277d57f2d.zip
Parent5288b0429fcdac891be3bced8e21787bd452d44a (diff)
Adding 3rd homework - Brainfuck Interpreter (#44)
* Add 1st hw * --amend * moving readme for 1st hw to designated folder * renamed TokenType enum to TokenClass * fixed character constant lexing. added sampe output file * add new line at end-of-file. added gitignore * a bit of refactoring * Add BF interpreter
1 files changed, 33 insertions, 0 deletions
-rw-r--r--homework/81568/BF_Interpreter/bf_interpreter.h33
diff --git a/homework/81568/BF_Interpreter/bf_interpreter.h b/homework/81568/BF_Interpreter/bf_interpreter.h
new file mode 100644
index 0000000..9e355ff
--- /dev/null
+++ b/homework/81568/BF_Interpreter/bf_interpreter.h
@@ -0,0 +1,33 @@
+#ifndef BRAINFUCK_INTERPRETER_H
+#define BRAINFUCK_INTERPRETER_H
+
+#include <cstddef>
+#include <iostream>
+
+
+class BFInterpreter {
+public:
+ using uchar = unsigned char;
+
+ BFInterpreter(const char *program, std::istream &input = std::cin, std::ostream &output = std::cout);
+ ~BFInterpreter();
+
+ void compile();
+
+private:
+ void addMemory();
+ void loop();
+ void proccessNonLoopCmd(char c);
+
+private:
+ std::istream &input;
+ std::ostream &output;
+ size_t memory_size;
+
+ uchar *memory_blocks;
+ uchar *p;
+ char *program;
+ char *pp;
+};
+
+#endif /* BRAINFUCK_INTERPRETER_H */