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.
74 questions
8votes
1answer
322views
C++ - Lexer for the Monkey Programming Language from the book "Writing An Interpreter In Go"
Below is a C++ version of a lexer for the Monkey programming language, originally written in Go, as presented in the book Writing An Interpreter In Go. LOC: 262. (Excluding the tests.) Language: Copy ...
4votes
1answer
125views
C99 - Lexer for the Monkey Programming Language from the book "Writing An Interpreter In Go"
Below is a C version of a lexer for the Monkey programming language, originally written in Go, as presented in the book Writing An Interpreter In Go. LOC: 371. (Excluding the tests.) Language: Copy ...
1vote
2answers
124views
Compiler grammar and parser are disconnected
In the process of creating my first toy language, I have created the base grammar for it (which can surely be improved upon, feel free to comment). I am emitting C at the moment. \begin{align} ...
5votes
0answers
261views
tbf - An Optimizing Brainfuck Interpreter and Transpiler in C
Language: The Brainfuck programming language consists of eight commands: ...
3votes
3answers
383views
1D Convolution vector multiplication in ANSI C code
I have a code snippet here about 1D convolution in pure ANSI C code. Question: Is this most optimized C code, or can it be done in a more optimized way? In my ...
4votes
2answers
121views
Extensible typing system for a strongly-typed DSL
I recently finished cleaning up my code in a compiler/interpreter for a strongly-typed domain-specific language, which makes use of three sorts of types: Compile-time enumerated types: Have one of a ...
6votes
2answers
205views
Programming Language Source Lexer
I have a lexer (program that turns source code into tokens) written in Go that I am re-writing in Rust. The lexer should take in a sequence of tokens, generally different special characters, integers, ...
4votes
1answer
423views
Assembler made in assembly
I made an assembler for the "hack" assembly language, here's an example of what it looks like: ...
3votes
1answer
904views
Call-flow graph from Python abstract syntax tree
Below is my code for building a call-flow graph from a Python abstract syntax tree. I'm not satisfied with it because the algorithm is very complicated. Perhaps much more complicated than it needs to ...
3votes
2answers
381views
Extremely simple virtual machine in Rust
I wrote a very simple VM to get a bit more familiar with Rust. The VM architecture was not the focus, so that I think that can safely ignored. Is my code idiomatic and clean? I felt that I was very ...
4votes
1answer
243views
A Brainfuck compiler that creates a small x86_64 Linux executable from scratch
This program compiles Brainfuck source code to an x86_64 ELF executable. It doesn't rely on any backend, just raw binary stream to a functional executable. In the implementation, each cell holds an 8-...
3votes
0answers
98views
Implement kleptography in Python
I'm new here, therefore I hope to be clear in this question. Firstly, I want to underline that I'm not a programmer, and I attended only a beginner course in Python, but I like to solve problems ...
4votes
1answer
200views
AEC-to-WebAssembly compiler in C++
Now that my new compiler is capable of compiling programs such as the Analog Clock in AEC, I've decided to share the code of that compiler with you, to see what you think about it. File ...
9votes
1answer
305views
Is possible to use script for dependencies in c++?
I wanted to make a script that would parse a main file (with int main()) look in its #include "..." local headers, and ...
2votes
0answers
41views
Sierpinski Triangle in AEC
So, I've tried to extend my compiler so that it can target GNU Assembler. And I've made a simple program to demonstrate that. ...