Skip to content

Commit

Permalink
Identify the "bug". Add a warning for it
Browse files Browse the repository at this point in the history
  • Loading branch information
DolphyWind committed Aug 3, 2024
1 parent c4e8d7d commit 71d7d3b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
15 changes: 9 additions & 6 deletions examples/brainfuck_interpreter/brainfuck.ec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
? It uses total of seven stacks. So please make sure your stack count is greater than or equal to this value
? This program reads the code from stdin. Please put ! to indicate the end of the code.
? The code gets executed after ! symbol.

? Contains a bug. I have no idea what the bug is but some code straight up don't work
? Update: I think the "bug" is not really a bug but rather an OS limitation. Because I realised std::cin
? cannot read more than 4095 characters on a line. Same behavior is present in python but not in python REPL
? Stacks are used for these purposes:
? First two stacks are used for storing code.
Expand Down Expand Up @@ -49,28 +52,28 @@
| +-+ I | +----+
| I | |
B I I S
B I +-M-+ +-#-+
B I +-M-+ +-#-+ ? "+"
| I I ] [
I #-+ +------+ |
E | #-F+
| +ψ+ I
B | #-b-+
B | S
B | +-#-+
B | +-#-+ ? ","
| | ] [
+{-------------+ +-------+ |
n | #-F+
| +ω+ I
| | #-b-+
+{---------------------+ S
n +-#-+
n +-#-+ ? "-"
| ] [
| +----------+ |
| | #-F+
| +δ+ I
| | #-b-+
+{---------------------------+ S
n +-#-+
n +-#-+ ? "."
| ] [
| +--------------+ |
| | #-F+
Expand All @@ -81,13 +84,13 @@
| #-+ I
| #-b-+
| S
| +-#-+
| +-#-+ ? "<"
| ] [
| +------+ |
| | #-F+
| +λ+ I
| | I
+{-----------------------------------------------------------+ #-b-+
+{-----------------------------------------------------------+ #-b-+ ? ">"
n S
| +-#-+
| ] [ A
Expand Down
4 changes: 2 additions & 2 deletions examples/brainfuck_interpreter/util.ec
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ n #
| #######MMMMMMMD+
| $
| S
| #
| +-+-+
| |
| +-#-+
| g G
| U E
+---------------------+{--O
Expand Down
5 changes: 4 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ SOFTWARE.

int main(int argc, char *argv[])
{
std::ios::sync_with_stdio(false);
setvbuf(stdin, nullptr, _IOFBF, 1024 * 1024);

std::cout << std::setprecision(15);
std::vector<std::string> args;
args.reserve(argc);
Expand All @@ -39,4 +42,4 @@ int main(int argc, char *argv[])
Electra electraInterpreter(args);
electraInterpreter.mainLoop();
return 0;
}
}

0 comments on commit 71d7d3b

Please sign in to comment.