Skip to main content

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.

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 ...
Madagascar's user avatar
  • 10.1k
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 ...
Madagascar's user avatar
  • 10.1k
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} ...
Tsaras's user avatar
  • 147
5 votes
0 answers
261 views

tbf - An Optimizing Brainfuck Interpreter and Transpiler in C

Language: The Brainfuck programming language consists of eight commands: ...
Madagascar's user avatar
  • 10.1k
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 ...
euraad's user avatar
  • 183
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 ...
P...'s user avatar
  • 141
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, ...
John Allison's user avatar
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: ...
elonma1234's user avatar
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 ...
Gaslight Deceive Subvert's user avatar
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 ...
xilpex's user avatar
  • 289
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-...
xiver77's user avatar
  • 419
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 ...
Davide Motta's user avatar
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 ...
FlatAssembler's user avatar
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 ...
milanHrabos's user avatar
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. ...
FlatAssembler's user avatar

15 30 50 per page
1
2 3 4 5