48
votes
Brainfuck interpreter written in C
This is a pretty reasonable start on a simple interpreter. Edward's suggestions are all good; a few additional suggestions:
interpret("+++++++++++++[->....
...
45
votes
Accepted
Brainfuck Interpreter written in x86 Assembly
The comment ; *argv should be ; argv, since you are not yet dereferencing the pointer.
After a ...
28
votes
Brainfuck interpreter written in C
Here are some things that may help you improve your program. In all, it seems to be nice, straightforward code that does what it needs to do. Good start!
Use only required ...
23
votes
Accepted
A completely overkill BrainFuck lexer/parser
Additional C#6.0 Modifications
How C#6.0 would you like it to be? You still have a few places you can use more C#6.0:
I'm going to work bottom-to-top in your post:
Usually, I don't support using ...
19
votes
Accepted
A brainfuck interpreter in C
Overall Observations
An interpreter should be able to read from standard in as well as from a file, this would break the entire tape model. The user could also redirect an input file to standard in.
...
16
votes
Accepted
Interactive Brainfuck interpreter in Haskell
Good job on getting it to work! I've used a string reversal program to check your interpreter and it works well. However, it also uses ~36MB of memory, which is too much.
A tape goes both directions ...
13
votes
A brainfuck interpreter in C
Only include the header files that you need
Looking at tape.h, it only contains declarations and no definitions. As such, the header files only serve to bloat up ...
10
votes
Rust Brainfuck interpreter
Profile
You can only improve what you can measure. So first of all let us run callgrind to check where we spent most of our time:
...
8
votes
Accepted
Brainfreeze: A Brainfuck compiler in C
I'm mostly reviewing the code-gen choices, not the style / implementation of the compiler itself.
The compiler itself mostly looks fine in the parts I've skimmed over (looking for how it uses the ...
8
votes
Accepted
BrainF**k interpreter in python
All of your if char == '>': ptr += 1 and similar checks should use elif after the first check. By using ...
8
votes
A brainfuck interpreter in C
You could use perror() to give more useful information from library-call failures. For example, consider
...
8
votes
Accepted
7
votes
Accepted
Text to Brainfuck translator
If you pass a long text to the code generator, the resulting program will overflow its memory. This is because you do >+++.> for each character, but you never ...
7
votes
Accepted
Brainfuck compiler with tcc backend
First off, your code does not compile, because (at least my just installed) libtcc does not contain a compile function.
As far ...
7
votes
Brainfuck to x86 Assembly Compiler
Your TargetCodeGenerator's generateAST has multiple abstraction levels embedded into one method.
And it's a long method.
It has all of these details that are pretty complex - when I see ...
7
votes
Accepted
Portable BrainFuck Interpreter in ANSI C89
Okay, what's the deal with #define ezs(x) (x)? Is it some kind of trick to either hide C-style casts, or make them more greppable? If the latter, why such a short ...
7
votes
Brainfuck compressor in Python
Since you seem to want code golf over readable code this may not be the answer you want. All the suggestions I make are things I would prefer, but I don't think it's that uncommon for others to ...
7
votes
Accepted
7
votes
Brainfuck to C transpiler
Advice I - roll your own my_basename
When you
fprintf(stderr, "usage: %s [input] [output]\n", argv[0]);
I suggest you ...
6
votes
Accepted
Brainfuck with C# operator overloading
You could get slightly closer with the [] command pair.
It's actually quite trivial:
Add an indexer to your brainfuck class (<...
6
votes
Optimized FizzBuzz in brainfuck
Tape setup
Esolang constants are compact, but not efficient. You are using an esolang constant to get the number 61, but what you actually want is a series of numbers: 0 5 66 117 122 105 70 3 0 100. ...
6
votes
BrainF**k interpreter in python
+1 on specifying argument code: str and return type -> str.
I implemented a class seen below which has the advantage of ...
6
votes
Accepted
BrainF**k interpreter in C++
Bug
The only issue I see is that the data array is never expanded.
As a result any value of ptr that is not zero will cause undefined behavior. What you want to ...
5
votes
Brainfuck Brute Force
I am trying to brute force code Brainfuck code to get the desired output.
For this, I need my code to be as fast as possible.
I am sorry, but those two statements are impossible to combine. If you ...
5
votes
Accepted
5
votes
Brainfuck interpreter in C 3
CodeReview problems
You've made two "codereview" errors (as opposed to "coding" errors):
Use tags
You didn't specify enough about your environment. What version of C are you writing for? (I'm ...
5
votes
Accepted
Simple Brainfuck Interpreter in C
The code is easy to read and to follow. There isn't a global in sight, the indentation is consistent, you use EXIT_SUCCESS and ...
5
votes
Accepted
Add two values in brainfuck
Shorter ways
I'm sure there are shorter ways to do this
What makes you so sure?
There is no shorter way to shorten the moving of one cell to another. I doubt there are any shorter and more efficient ...
4
votes
Brainfuck Interpreter written in x86 Assembly
Jump instructions are slow and should be minimized. One jump instruction in the interpreter loop can be removed as follows:
...
4
votes
Reverse multiple strings separated by comma
Upon learning more brainfuck, I've learned that my loop that subtracts 44 could be improved:
Before
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
brainfuck × 114interpreter × 64
c × 27
c++ × 13
python × 12
haskell × 12
compiler × 12
beginner × 11
performance × 10
assembly × 10
java × 8
c# × 6
ruby × 6
javascript × 5
python-3.x × 4
converting × 4
c++11 × 3
python-2.x × 3
rust × 3
f# × 3
clojure × 3
object-oriented × 2
strings × 2
parsing × 2
recursion × 2