BrainF*ck Runtime in C, just a fun little project to learn C with. Might turn this into my own esolang later.
CMake 1.78%Brainfuck 0.40%C 96.88%Shell 0.94%
bf-runtime's Introduction
๐ Hey, I'm Henry Langmack!
๐ I'm 16, and I'm currently living in New Jersey.
๐ I've been programming since I was 9 and was introduced by a cousin.
๐ป Shortly after I started attending KidOYO during summers and did student mentor work in the summer of 2020. Recently, I've been shipping a lot of apps using Flutter and SwiftUI. Interesed in SAAS.
When the program encounters a closing bracket (']'), from what I understood, it sets program->current to the last opening bracket, which causes problems when you have nested loops. This can be fixed implementing the following:
Create an char** array which is your stack
Every time you encounter a [, loop through the entire program (to the right), and with each '[' you encounter, add its position into the stack, for each ']' you encounter, remove the last position from the stack. When you encounter ']' that removes the last element from the stack, that is the corresponding bracket
Do the same thing in reverse every time you encounter a ].
I don't know if this is the most efficient way to do this, but it works, and that's enough for me