Website Summary Files Commits Branches @commit @diff @stats
path: root / homework / 81625 / Brainfuck-Interpretator / src / main.cpp
diff options
context:
space:
mode:
Commit99a9f9389a41a1df544ab51fc0170e48f10e34c8 (patch)
Author
 thetedgt <44469837+thetedgt@users.noreply.github.com>
2018-11-29 14:42:06 +0200
Committer
 dtrendafilov <trendafilov.dn@gmail.com>
2018-11-29 14:42:06 +0200
Files0ee5061e2034b2a8708af6b2af0caf8fe96f139b /homework/81625/Brainfuck-Interpretator/src/main.cpp
IPL-99a9f9389a41a1df544ab51fc0170e48f10e34c8.tar
IPL-99a9f9389a41a1df544ab51fc0170e48f10e34c8.tar.gz
IPL-99a9f9389a41a1df544ab51fc0170e48f10e34c8.zip
Parent72d9bbcc3154142af79fb686d9dc7e4d1fa1badb (diff)
Added Homework 3 - BF Interpreter (#64)
* homework 1 * Adding homework 3 - brainfuck interpreter * Add README.md
1 files changed, 37 insertions, 0 deletions
-rw-r--r--homework/81625/Brainfuck-Interpretator/src/main.cpp37
diff --git a/homework/81625/Brainfuck-Interpretator/src/main.cpp b/homework/81625/Brainfuck-Interpretator/src/main.cpp
new file mode 100644
index 0000000..7003a78
--- /dev/null
+++ b/homework/81625/Brainfuck-Interpretator/src/main.cpp
@@ -0,0 +1,37 @@
+#include "BFI.h"
+
+int main()
+{
+ std::string helloWorld = "++++++++++[>+>+++>+++++++>++++++++++<<<<-]>>>++.>+.+++++++..+++.<<++.>+++++++++++++++.>.+++.------.--------.<<+.<.";
+ std::string squares = "++++[>+++++<-]>[<+++++>-]+<+[>[>+>+<<-]++>>[<<+>>-]>>>[-]++>[-]+>>>+[[-]++++++>>>]<<<[[<++++++++<++>>-]+<.<[>----<-]<]<<[>>>>>[>>>[-]+++++++++<[>-<-]+++++++++>[-[<->-]+[<<<]]<[>+<-]>]<<-]<<-]";
+ std::string beer = ">++++++++++[<++++++++++>-]<->>>>>+++[>+++>+++<<-]<<<<+<[>[>+>+<<-]>>[-<<+>>]++++"
+ ">+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[[-]>>>>>>[[-]<++++++++++<->>]<-[>+>+<<-]>[<+>"
+ "-]+>[[-]<->]<<<<<<<<<->>]<[>+>+<<-]>>[-<<+>>]+>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<"
+ "<[>>+>+<<<-]>>>[-<<<+>>>]++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[>+<[-]]<[>>+<<[-]]"
+ ">>[<<+>>[-]]<<<[>>+>+<<<-]>>>[-<<<+>>>]++++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[>+"
+ "<[-]]<[>>+<<[-]]>>[<<+>>[-]]<<[[-]>>>++++++++[>>++++++<<-]>[<++++++++[>++++++<-]"
+ ">.<++++++++[>------<-]>[<<+>>-]]>.<<++++++++[>>------<<-]<[->>+<<]<++++++++[<+++"
+ "+>-]<.>+++++++[>+++++++++<-]>+++.<+++++[>+++++++++<-]>.+++++..--------.-------.+"
+ "+++++++++++++>>[>>>+>+<<<<-]>>>>[-<<<<+>>>>]>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<<<"
+ "[>>>+>+<<<<-]>>>>[-<<<<+>>>>]+>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<<[>>+<<[-]]>[>+<"
+ "[-]]++>>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<+<[[-]>-<]>[<<<<<<<.>>>>>>>[-]]<<<<<<<<<"
+ ".>>----.---------.<<.>>----.+++..+++++++++++++.[-]<<[-]]<[>+>+<<-]>>[-<<+>>]+>+<"
+ "[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<<[>>+>+<<<-]>>>[-<<<+>>>]++++>+<[-<->]<[[-]>>-<<]"
+ ">>[[-]<<+>>]<<[>+<[-]]<[>>+<<[-]]>>[<<+>>[-]]<<[[-]>++++++++[<++++>-]<.>++++++++"
+ "++[>+++++++++++<-]>+.-.<<.>>++++++.------------.---.<<.>++++++[>+++<-]>.<++++++["
+ ">----<-]>++.+++++++++++..[-]<<[-]++++++++++.[-]]<[>+>+<<-]>>[-<<+>>]+++>+<[-<->]"
+ "<[[-]>>-<<]>>[[-]<<+>>]<<[[-]++++++++++.>+++++++++[>+++++++++<-]>+++.+++++++++++"
+ "++.++++++++++.------.<++++++++[>>++++<<-]>>.<++++++++++.-.---------.>.<-.+++++++"
+ "++++.++++++++.---------.>.<-------------.+++++++++++++.----------.>.<+++++++++++"
+ "+.---------------.<+++[>++++++<-]>..>.<----------.+++++++++++.>.<<+++[>------<-]"
+ ">-.+++++++++++++++++.---.++++++.-------.----------.[-]>[-]<<<.[-]]<[>+>+<<-]>>[-"
+ "<<+>>]++++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[[-]++++++++++.[-]<[-]>]<+<]";
+ std::string triangle = ">++++[<++++++++>-]>++++++++[>++++<-]>>++>>>+>>>+<<<<<<<<<<[-[->+<]>[-<+>>>.<<]>>>[[->++++++++[>++++<-]>.<<[->+<]+>[->++++++++++<<+>]>.[-]>]]+<<<[-[->+<]+>[-<+>>>-[->+<]++>[-<->]<<<]<<<<]++++++++++.+++.[-]<]+++++";
+
+
+ BFI bfi(beer);
+ bfi.interpret();
+ bfi.printUsedMemory();
+ return 0;
+}
+