From 06fb208e468e10a4c65c424c7e2e11a33dba5708 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Mon, 13 Nov 2023 15:36:43 -0500 Subject: [PATCH] add preprocessing via~ --- CMakeLists.txt | 2 +- bf.bf | 1 + hellobf.bf | 1 + libraries/BLT | 2 +- shader1.txt | 4 ++++ shader2.txt | 17 +++++++++++++++++ shader3.txt | 7 +++++++ shader4.txt | 1 + src/main.cpp | 12 ++++++------ 9 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 hellobf.bf create mode 100644 shader1.txt create mode 100644 shader2.txt create mode 100644 shader3.txt create mode 100644 shader4.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 5162400..c59e2a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.26) +cmake_minimum_required(VERSION 3.1) project(BrainFuck_Misc) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) diff --git a/bf.bf b/bf.bf index ea2b641..02693f2 100644 --- a/bf.bf +++ b/bf.bf @@ -1 +1,2 @@ +~../hellobf.bf ++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++. \ No newline at end of file diff --git a/hellobf.bf b/hellobf.bf new file mode 100644 index 0000000..ea2b641 --- /dev/null +++ b/hellobf.bf @@ -0,0 +1 @@ +++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++. \ No newline at end of file diff --git a/libraries/BLT b/libraries/BLT index 32e2d48..5472783 160000 --- a/libraries/BLT +++ b/libraries/BLT @@ -1 +1 @@ -Subproject commit 32e2d48cd31d20d80ecd7cd87ecfe74c2bbc1e5a +Subproject commit 5472783bd7194cfc844da81bfa696e7761bd2047 diff --git a/shader1.txt b/shader1.txt new file mode 100644 index 0000000..5598bed --- /dev/null +++ b/shader1.txt @@ -0,0 +1,4 @@ +#include <../shader2.txt> +#include "../shader3.txt" + +SHADER 1 ENDING TEXT \ No newline at end of file diff --git a/shader2.txt b/shader2.txt new file mode 100644 index 0000000..dc4e35e --- /dev/null +++ b/shader2.txt @@ -0,0 +1,17 @@ +i +am +a +shader +2 +i +suck +all +the +balls +possible +----- +I AM INCLUDING SHADER 3 +===== +#include <../shader3.txt> +----- +END OF SHADER 2 \ No newline at end of file diff --git a/shader3.txt b/shader3.txt new file mode 100644 index 0000000..1f2922c --- /dev/null +++ b/shader3.txt @@ -0,0 +1,7 @@ +this is some text i have included in shader 3 +----- +UWU +----- +end of shader 3 + +#include <../shader4.txt> \ No newline at end of file diff --git a/shader4.txt b/shader4.txt new file mode 100644 index 0000000..a874a70 --- /dev/null +++ b/shader4.txt @@ -0,0 +1 @@ +SHADER 4 TEXT IS THE BEST FUCKING TEXT EVER diff --git a/src/main.cpp b/src/main.cpp index ef17bba..d004e6b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,6 +2,7 @@ #include #include #include +#include class brainfuck { @@ -72,7 +73,6 @@ class brainfuck template void match(functor f, int sp, size_t& index, const std::string& program) { - while (f(index) < program.size()) { if (program[index] == '[') @@ -84,12 +84,12 @@ void match(functor f, int sp, size_t& index, const std::string& program) } } -int main() +int main(int argc, const char** argv) { - std::ifstream bf("../bf.bf"); - std::stringstream buffer; - buffer << bf.rdbuf(); - auto program = buffer.str(); + std::string file{"../bf.bf"}; + if (argc > 1) + file = argv[1]; + auto program = blt::fs::loadBrainFuckFile(file); brainfuck fuck;