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("+++++++++++++[->....
...
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 ...
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 ...
11
votes
Accepted
A tree of polymorphic types (Crafting Interpreters Book)
Unique pointers own objects
It's important to realize that std::unique_pointer does not only free memory automatically, it also restricts copying pointers, such ...
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:
...
9
votes
Accepted
Interpreter for NLRNIS programming language, written in Python
To build a language with good quality code requires understanding the various approaches to building operators, evaluators and tokenizers.
Lets go through the concepts from simplest to complicated, to ...
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
Accepted
8
votes
A tree of polymorphic types (Crafting Interpreters Book)
Enable more warnings so your compiler can help you
Many problems can be diagnosed automatically, prior to human review.
For example, using GCC:
...
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
Accepted
6
votes
Starting point for a collaboratively developed golfing language interpreted in Python
Object programming
Y'ouve split your code into various classes. Yet, it seems like the way you use them could be improved.
Indeed, the various "is_SOMETHING" method are very suspicious, both in the ...
6
votes
Simple interpreter written in Rust
Learn to love rustfmt. It will correct your code to the idiomatic Rust style.
Learn to love clippy. It will provide more lints to change your code to be more idiomatic. For example, it identifies many ...
6
votes
JIT-based programming language
Overall code is written in a uniform style - good.
Separate Code
There is far too much code in one file. And even that is not organized enough. This is unmanageable and increases review/...
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 ...
6
votes
Accepted
Simple scripting language (interpreter) in C
Potential bug
str[strlen(str) - 1] is undefined behavior when str[0] == 0. Instead use a logical AND.
...
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
Starting point for a collaboratively developed golfing language interpreted in Python
There's a lot of code here, so I'm going to go through it very sketchily. If you need a point explaining in more detail, ask.
There's no documentation. What is the specification of the language being ...
5
votes
Accepted
(Lisp in (Rust))
Organization
Let's first take a look at the organization of the code. The gigantic
code block is stored in one file, with comments like /* Types */ and
...
5
votes
Accepted
Very simple interpreter in C
There are a number of issues in this very short program.
Unless there are coding standards that require otherwise, it is better to use typedef to define types ...
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
Simple scripting language (interpreter) in C
Boolean type
If you really want / need a boolean type, use <stdbool.h>. If you don't, just use an int as much prior code ...
5
votes
Extensible typing system for a strongly-typed DSL
General Observations
This is a personal preference, but I really don't like code that overuses macros: it is very hard to debug and maintain.
This question has horizontal scroll bars which is an ...
4
votes
Accepted
Haskell Brainf*ck interpreter: runtime error handling
When you compile a language, you usually split the input into tokens with a lexer, then parse those tokens with a parser into syntactic elements in an abstract syntax tree (AST) and then use that to ...
4
votes
4
votes
Accepted
Befunge-93 interpreter in Python
Here are some improvement you can do
gather the four directions >,<,^,...
4
votes
Peter Norvigs' lis.py in c++17
Is std::list the best choice for the List datatype? There are a couple of places where using operator[] would make the code a little easier to read but std::list doesn't provide that. On the other ...
4
votes
115 line brainfuck interpreter written in C++
I see some things that may help you improve your program.
Use all of the required #includes
The function std::strchr is used ...
4
votes
Accepted
115 line brainfuck interpreter written in C++
Design
You do not validate that the program is valid before starting. You should check that '[' and ']' are all matched correctly. This can be done while loading the program.
Your memory (tape) runs ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
interpreter × 149brainfuck × 64
python × 32
c × 28
haskell × 16
c++ × 15
java × 13
beginner × 12
language-design × 12
performance × 11
python-3.x × 11
c# × 8
javascript × 7
rust × 7
parsing × 6
python-2.x × 6
console × 6
scheme × 6
lisp × 5
object-oriented × 4
ruby × 4
recursion × 4
f# × 4
math-expression-eval × 4
compiler × 4