Skip to main content
17 votes

Compiling and throwing simple dynamic exceptions at runtime for JVM

Is there anything that can be simplified or made even cleaner? Yes, don't invoke the Java compiler at runtime. From your examples in a comment: ...
Simon Forsberg's user avatar
17 votes

Heavily limited premature compiler translates text into excecutable python code

I see a number of things that may help you improve your program. Since the existing review covered a lot of good points, this review will cover the parts not already mentioned. Use the correct form ...
Edward's user avatar
  • 66.6k
15 votes

Compiler Tokenizer implementation in C#

One small comment about your API. public void Tokenize() I would expect a Tokenize method to return a stream (IEnumerable) of ...
RubberDuck's user avatar
  • 30.9k
15 votes
Accepted

Heavily limited premature compiler translates text into excecutable python code

Allocations can fail Don't use buffer until we know it's not null. (And no need to multiply by sizeof (char), since that's ...
Toby Speight's user avatar
  • 81.7k
12 votes
Accepted

Simple C99 Lexer

#ifndef __JMCOMP_LEXER_H__ That is a symbol reserved for use by the implementation. Writing your this in a way that mimics what you see in the compiler-supplied ...
JDługosz's user avatar
  • 11.3k
11 votes

Compiler Tokenizer implementation in C#

Your code looks very clean and organized. Only some comments (without understanding the code in depth) You would probably use the regex option ...
JanDotNet's user avatar
  • 8,538
11 votes

Compiling and throwing simple dynamic exceptions at runtime

Surprising This is a gross violation of the Principle of Least Surprise. The only possible reaction I could have seeing this in the wild would be, "What the heck?" This is not a normal way of using ...
jpmc26's user avatar
  • 1,233
8 votes

Compiler Tokenizer implementation in C#

A few other things: cursor += 2; and cursor++; are all over the place in your Tokenizer. ...
Nikita B's user avatar
  • 13k
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 ...
Peter Cordes's user avatar
  • 3,416
8 votes

Heavily limited premature compiler translates text into excecutable python code

Another point that hasn't been fleshed out by other reviewers is the generated python code. list is a built-in function in python - by calling your list ...
Shadow's user avatar
  • 271
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 ...
Pimgd's user avatar
  • 22.3k
7 votes
Accepted

Assembler for CPU

Some simplifications You can initialize the symbols dictionnary in one instruction: ...
301_Moved_Permanently's user avatar
7 votes

Programming Language Source Lexer

Disclaimer I've NEVER written Rust, used Rust anywhere, or done anything with/about Rust. However, I do have to say that, what you have there, is extremely easy to read and understand, even for a ...
Ismael Miguel's user avatar
6 votes

Compiler Tokenizer implementation in C#

You can use verbatim strings to reduce the slash chaos: { SyntaxKind.RootOperationToken, new Regex(@"\/\/") }, You can also use IReadOnlyDictionary to ...
Marian Spanik's user avatar
6 votes
Accepted

Jack compiler in C

First, you tackled a tough problem and you obviously put a lot of effort into it. The code is well structured. The organization of the code seems fine. My code contains occasional free() statements,...
pacmaninbw's user avatar
  • 24.8k
6 votes

Lexer for C++ in python

You'll run out of stack memory if you recursively call run() at so many places. You can remove those. You should consider opening the file with a another context ...
fayaz's user avatar
  • 61
6 votes

Lexer for C++ in python

A lot of could be written in a more functional style. That means that functions return the result of their execution instead of printing it. It makes your code more readable, more composable and ...
Noah Haasis's user avatar
6 votes
Accepted

C++ - Lexer for the Monkey Programming Language from the book "Writing An Interpreter In Go"

For someone new to C++ and OOP, your code is pretty good! Can you really lex one line at a time? Your Lexer only processes one line at a time, at least that's how ...
G. Sliepen's user avatar
  • 61.7k
5 votes

Python command line tool for compiling py files to exec files on Mac

I recommend that you read PEP 8. It's advised against doing import os, re. Instead have one line dedicated to each import. You should have an empty line between ...
Peilonrayz's user avatar
  • 43.5k
5 votes
Accepted

Compiling and throwing simple dynamic exceptions at runtime for JVM

Setting isAccessible to true You seem to be always settings isAccessible to true. This is only needed if you are accessing ...
Ferrybig's user avatar
  • 1,357
5 votes
Accepted

Is this a good way to write a lexer?

Here are a number of things that may help you improve your program. Don't use define for function-like macros There is no advantage and considerable disadvantages ...
Edward's user avatar
  • 66.6k
5 votes
Accepted

Simple BASIC to Simpletron Machine Language compiler in C

C99, assignment-in-conditions At the risk of sounding like a broken record - I'll make the same recommendations as in Simpletron simulator in C . Consider moving your variable declarations closer to ...
Reinderien's user avatar
  • 65.4k
5 votes
Accepted

AEC-to-WebAssembly compiler in C++

How to create an alias for an enum I see you are declaring 5 constants, like i32, to avoid having to write out a whole ...
G. Sliepen's user avatar
  • 61.7k
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 ...
pacmaninbw's user avatar
  • 24.8k
4 votes

Building abstract syntax tree for markargs

The tests do not belong where you put them. Imagine me wanting to use your language. I'd expect a standalone compiler executable, and the set of tests - which I can may freely manipulate - driven by ...
vnp's user avatar
  • 57.3k
4 votes
Accepted

Creating data objects dynamically at runtime from an interface

Cache the type so you don't build it each time. ConcurrentDictionary could do it. Just make a static field to hold the dictionary ...
CharlesNRice's user avatar
  • 4,408
4 votes
Accepted

Make compiler obfuscate strings

I will not review the code itself but the algorithm you're using. Given that: Password is available (it's added to the encrypted string). Algorithm is perfectly clear and available (especially ...
Adriano Repetti's user avatar
4 votes
Accepted

Assigning names to unnamed labels

A few notes about your code: Both the inner and outer method are fairly small, and the name of the outer method is already aptly descriptive, so I see no need for a named inner method here. An ...
Pieter Witvoet's user avatar
4 votes

Simple C99 Lexer

Same Lexer writtern in Lex. Lexer.l ...
Loki Astari's user avatar
  • 96.6k
4 votes

Simple C99 Lexer

Include what you use You use isdigit, isalpha, etc. -- but you haven't included ctype.h or <...
Jerry Coffin's user avatar
  • 33.6k

Only top scored, non community-wiki answers of a minimum length are eligible