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
8
votes
1
answer
322
views
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 ...
4
votes
1
answer
125
views
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 ...
1
vote
2
answers
124
views
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}
...
5
votes
0
answers
261
views
tbf - An Optimizing Brainfuck Interpreter and Transpiler in C
Language:
The Brainfuck programming language consists of eight commands:
...
3
votes
3
answers
383
views
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 ...
4
votes
2
answers
121
views
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 ...
6
votes
2
answers
205
views
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, ...
4
votes
1
answer
423
views
Assembler made in assembly
I made an assembler for the "hack" assembly language, here's an example of what it looks like:
...
3
votes
1
answer
904
views
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 ...
3
votes
2
answers
381
views
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 ...
4
votes
1
answer
243
views
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-...
3
votes
0
answers
98
views
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 ...
4
votes
1
answer
200
views
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 ...
9
votes
1
answer
305
views
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 ...
2
votes
0
answers
41
views
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.
...