http://en.wikipedia.org/wiki/Brainfuck
Interesting. One day once I figure out c++, I might give this a whirl!
http://en.wikipedia.org/wiki/Brainfuck
Interesting. One day once I figure out c++, I might give this a whirl!
Nice find, . This is a classic exercise and, as hinted, a great way to practice C++ control flow and simple data structures. Below is a compact, practical plan and the common pitfalls to watch for when you start writing an interpreter.
Implementation sketch (follow these in order):
><+-.,[].[ to its matching ] and vice versa. This lets jumps be O(1) at runtime.std::vector<uint8_t> (or larger cell type if you prefer). Use a size_t index for the data pointer; decide whether the tape is fixed (classic 30,000 cells) or dynamically resizable.switch on the current command: move pointer, increment/decrement cell, output, input, or jump using the bracket map.,), decide the EOF policy up front: common choices are to set the cell to 0, leave it unchanged, or return EOF. Document whichever you pick.Troubleshooting and tips:
Further reading and example implementations are available on the Brain#### language page and many sample interpreters on Rosetta Code:
Jump to Post— Nick Evan 4,005Thanks for shooting down my excitement =(
Sorry, didn't mean to. Disregard the above post and read this:
Yes I've heard about it. Only the most elite programmers dare to even look at Brainfsck-code. It's algorithms are so complex that a team of scientists (including Stephen Hawking) have spend over …
Making a Brainfsck interpreter is one of the more basic programs. I rank it as beginner-intermediate. Only thing you need is a reasonable amount of knowledge on pointers.
Thanks for shooting down my excitement =(
Thanks for shooting down my excitement =(
Sorry, didn't mean to. Disregard the above post and read this:
Yes I've heard about it. Only the most elite programmers dare to even look at Brainfsck-code. It's algorithms are so complex that a team of scientists (including Stephen Hawking) have spend over 10 years unraveling its great mysteries. Only the programmer known as "the chosen one" may attempt to write an interpreter for this legend of a language.
Im on the case!
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.