Questions tagged [compiler]

For reviews of code which implements any part of a compiler - lexing, parsing, code generation and optimization, etc. Also for any plugin for an existing compiler. Don't use this tag for code which is input to a compiler - tag it with the correct language instead.

Filter by
Sorted by
Tagged with
0
votes
0answers
30 views

Verifier for multi-purpose scripting language

I rewrote a compiler project right now containing semantics, parser and verifier, in Java. Links: source code, language overview. The language is familiar for ECMAScript. As an example, the verifier ...
5
votes
1answer
98 views

Simple BASIC to Simpletron Machine Language compiler in C

I implemented a compiler that compiles a dialect of BASIC known as SimpleBASIC into Simpletron Machine Language to be run by the Simpletron simulator. I wrote the manual for the SimpleBASIC compiler ...
2
votes
0answers
30 views

Brainfuck NASM compiler in Clojure

I've made a simple brainfuck compiler, I feel like my code is unreadable and messy, how can I improve it? src/core.clj ...
4
votes
1answer
69 views

Is this a good way to write a lexer?

I don't know whether if this is the right place to ask this. I am semi-beginner in C. I always wanted to build my own Programming Language. Here I have built a lexical analyser completely myself. ...
3
votes
0answers
102 views

Scripting language with generic classes

I am creating a dialect of ActionScript 3.0 and now have a working verifier, or “symbol solving” verifier. The language upgrades ActionScript 3.0 with few operators, light syntax facilities, numeric ...
3
votes
2answers
202 views

C++ Building Parse Tree with Boost and Modern C++

I am writing a parser. To build up the tree, I need to find the correct type for my node based on text from my language input file. Right now, I have a map from a string (the node name) to a factory ...
3
votes
1answer
57 views

State machine translates text into executable python code [v2]

A few days ago I started writing my own compiler-like program which has the goal to compile plain text into executable python code. After I let my first version review here, I made huge changes to the ...
10
votes
3answers
2k views

Heavily limited premature compiler translates text into excecutable python code

My goal is to write a smaller compiler-like program, which allows me to draw geometric shapes into a 3D Diagram. There is no need for turing-completeness and the program should only be viewed as an ...
7
votes
4answers
437 views

Lexer for C++ in python

I wrote a simple C++ lexer in python. Although it already works but I kinda feel I didn't follow the pythonic way. Any suggestion for improvements? Sample C++ Code Sample output Here's my code: ...
4
votes
2answers
835 views

Compiling and throwing simple dynamic exceptions at runtime for JVM

I've been using my Dynamic Exception with C# for quite some time already and it saved me a lot of time. This means, I don't have to create a new exception ...
6
votes
2answers
222 views

Program that generates brainfuck code that outputs given text

I created program that generates brainfuck code that outputs given text. Arguments for the program are input file with the text and ...
12
votes
1answer
187 views

Jack compiler in C

I have been doing projects from the book The Elements of Computing Systems. Under the scope of project 10 and project 11, I had to implement a compiler for a (toy) programming language called Jack (...
4
votes
2answers
75 views

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

When I used to use a PC I was familiar with py2exe, the mac equivalent I saw most people talking about was py2app — which compiles python to .app files, not .exec files. I was familiar with compiling ...
17
votes
1answer
268 views

Brainfreeze: A Brainfuck compiler in C

BrainFreeze This is my implementation of a brainfuck compiler in C. The instruction to build/run the project (GitHub repo) can be found here. I am first converting the brainfuck source to x86 ...
2
votes
0answers
133 views

Parser for simple esoteric language in Rust

I am writing a compiler for esoteric language as one of my first Rust projects. I am using rust-pest to generate a parser. Since I'm new in Rust, code review would be great. Full source code can be ...
13
votes
1answer
154 views

Brainfuck to NASM compiler in Haskell

After reading this article on writing a Brainfuck interpreter in Haskell and achieving awful performance with it (for example, mandelbrot generating 37.5 minutes on an old Intel Atom powered laptop) I'...
6
votes
0answers
381 views

Creating a new language: FreezeFlame

Where it shines FreezeFlame shines in readibility while still maintaining most of the C-like syntax. It also implements a few (Planning on several) operators that are still in testing for other ...
5
votes
2answers
199 views

Brainfuck to Python compiler

So this is (I think) a premiere for python. A function that translates brainfuck code to python code. It does a few optimizations (It chains +,...
3
votes
2answers
140 views

cmake for a toy programming language

I have very little experience with cmake, this is really the first time I used it for a project. In the past I used some ...
4
votes
0answers
161 views

Implementation of the Hindley-Milner type system (with evaluation, without type inference) as a library for use in compilers

I've written an implementation of the Hindley-Milner type system as a "Core" language for use in writing compilers of typed functional languages. This is meant to be used as a library by compilers of ...
12
votes
4answers
875 views

Simple C99 Lexer

I'm building a compiler for fun, and this is my first pass at the lexer for it. It should handle all tokens for C99, with the exception of the preprocessor tokens. It's very minimal, only grabbing the ...
6
votes
1answer
403 views

Programming language lexer in Rust

I'm working through Crafting Interpreters and trying to apply what I've learned in Rust. I've got the lexer working in what feels like a reasonably idiomatic way (hooray!), but I have a feeling it ...
0
votes
2answers
90 views

Assigning names to unnamed labels

I'm working on a compiler. During the final stage I will get a collection of Lines. This is the method that takes the Lines and ...
5
votes
2answers
3k views

Make compiler obfuscate strings

I'm looking at a task to obfuscate strings in my application like URLs, paths and queries at compile time. This is not for encrypting ...
3
votes
2answers
247 views

CodeWars - Three-pass compiler for arithmetic expressions

I'm looking for feedback on my solution to the Tiny Three-Pass Compiler kata on CodeWars. The kata is to implement a compiler for an arithmetic language in three passes - parsing to an AST, constant ...
3
votes
0answers
54 views

Type System library

I would like some reviews of my Type system library in Golang that I am building for a compiler project. Here are external links to the versioned source files, types.go builtins.go The first file: ...
5
votes
1answer
4k views

Creating data objects dynamically at runtime from an interface

Sometimes when I write objects for holding data (not real DTOs, no serialization involved) I also create an interface for it. The class that implements it can also perform some null checks. I don't ...
2
votes
3answers
915 views

Compiling and throwing simple dynamic exceptions at runtime

I often need a simple exception with a meaningful name and some helpful message which usually just looks like this one: ...
4
votes
1answer
115 views

Python basic arithmetic compiler

I am attempting to follow the "Let's build a compiler" tutorials, in order to build a basic language compiler for a custom assembly language. Currently the specs of my compiler are: Accepts a ...
7
votes
3answers
3k views

Building abstract syntax tree for markargs

Roadmap I'm trying to follow usual compiler design: Lexical analysis (1, 2) Syntactical analysis <---- you're here Semantic analysis User input Code generation + execution Background I think I ...
9
votes
1answer
312 views

PEG.js grammar for a simple programming language

I'm trying my hand at developing a compiler and have written a peg.js grammar for a simple programming language. A sneak peak at the grammar: ...
5
votes
1answer
188 views

Compiler Tokenizer implementation in C# - follow-up

I have posted this question 2 days ago and got amazing feedback on it. Hands back to the keyboard, I believe I took the suggestions into account and improved the classes drastically. In this question,...
14
votes
4answers
3k views

Compiler Tokenizer implementation in C#

I'm writing a compiler for a couple of months now, this is the tokenization part of the lexer. I would like a code review to improve my coding style and learn new techniques to pretty up my code and ...
1
vote
0answers
121 views

A compiling IRC bot in Java

I made a compiling IRC bot in Java that compiles JavaScript code using Nashorn engine, bans users if they say bad words and replies for simple user requests. I'd like ask about review my code. Main....
3
votes
2answers
47 views

Adding numbers of any type

I'm writing an interpreter, and I'm designing the abstract syntax tree currently. Right now, I'm trying to figure out a way to add (or do other operations with) two ...
40
votes
2answers
1k views

Brainfuck to x86 Assembly Compiler

After my Brainfuck Interpreter written in x86 Assembly I decided that it was time to get to the next step, writing a Brainfuck Compiler in Java that generates x86 Assembly and compiles that to an ...
10
votes
1answer
463 views

Assembler for CPU

I recently put together an assembler for a CPU I designed. I'm looking for feedback on my program structure, formatting, or anything else. I'm self taught on all of this so I don't have opportunities ...
6
votes
1answer
208 views

Logic Prolog compiler

I'm actually doing my own Prolog compiler just like SWISH one with Java. Prolog is a logic language that is particularly suited to programs that involve symbolic or non-numeric computation. Prolog ...
5
votes
1answer
2k views

Runtime compiler for getting/setting runtime property values

I've been playing about with runtime compilation to allow me to get/set runtime property values in C#, and so far I have come up with a class. This allows me to write code like the following which ...
0
votes
1answer
64 views

Compiler for grond, a language-in-the-making

I'm working on a language called grond (see it on GitHub); the compiler is so small it is included in this post. My gut tells me that this code is awful, but it works. I am hesitant to change things ...
8
votes
0answers
776 views

Cyther: The Cross Platform Cython/Python Compiler (Take 2)

I recently posted an earlier version of this code on Code Review, and now with the given suggestions and many other improvements, I am back. I included the description of exactly what Cyther is ...
8
votes
2answers
2k views

Cyther: The Cross Platform Cython/Python Compiler

The newer version of this question is located here: Cyther: The Cross Platform Cython/Python Compiler (Take 2) I am currently writing a Python library (soon to be published)that automatically ...
8
votes
2answers
187 views

Compiler for a minimal LISP dialect to run on the Java Virtual Machine

As the title states, this is a compiler written in C with a ruby build script that translates a minimal LISP dialect and spits out an executable jar file. I designed this LISP dialect and named it ...
7
votes
3answers
7k views

Lexer for C# source code

This code reads a .cs source file in the \bin folder and parses the C# code in it. The program outputs keywords, identifiers, separators and numerical constants. How could it be improved? ...
6
votes
2answers
277 views

Brainf*ck to NASM converter written in C

I have made a very simple Brainfuck to NASM converter, that is usable for practically all programs. It has one trivial optimisation (to subsitute ADD for ...
4
votes
2answers
152 views

Build script for an operating system written in C++

I recently started following the James M Kernel Dev tutorials and was able to create an operating system in C++. Here is the source on GitHub. I have a couple of questions: Is my coding style ok? ...
5
votes
2answers
68 views

Pseudoportable C script pattern - follow-up

See the initial/previous iteration. I have rewritten the script following the answer of @200_success. Now it looks like this: ...
6
votes
1answer
76 views

Pseudoportable C script pattern

(See the next iteration.) From time to time, while working with a command line in *nix family of operating systems, we have to write those scripts doing a rather specific task. Usually we use ...
14
votes
3answers
501 views

BF#: Round 2 (Fight!)

So I've completely changed how BrainfuckSharp does things, and added some features. This is obviously a follow up to: Interpreting Brainfuck code to C#, then compiling to a .exe It now features an <...
6
votes
1answer
517 views

Brainfuck to Java converter

Similar to the previous post Brainfuck Interpreter: Slower than a Snail?, it runs BF in java. The only difference is that the converter will convert the BF code into a compilable and fairly readable ...