C compiler done wrong (for learning).

Overview

crust 🥧

Crust is a small C to x86-64 compiler, built using Rust. This project is meant for me to learn about compilers and the modules that they are composed of, so instead of using a lexer or parser generator, I try to build each component from scratch. Of course, this means that things will be done incorrectly and inefficiently but, with the theoreticals in mind, it should be possible to make something useable for simple programs.

I'm very much so still learning about compilers, C, assembly, and Rust, so this seemed like a great little project to just learn from. I got the idea from Nora Sandler's amazing series of blog posts.

If you have any advice for this, please reach out!

Roadmap

  • Basic lexing, parsing (into AST), and x86-64 assembly generation.
  • Unary Operators (~, !, -), not including prefix, postfix, or referencing.
  • Implement binary operators (numerical, binary, logical, relational) and proper order of operations.
  • Local int variables, assignment operators, basic stack frames.
  • Compound assignment operators.
  • Conditional flow.
  • Compound statements (nested scopes).
  • Loops (for, while, break and continue keywords).
  • Additional functions.
  • Global variables.

Much later...

  • Additional types (floats, arrays, pointers, and structs).
  • Optimizations.
You might also like...
The zkEVM Vyper compiler.

zkSync Era: Vyper Compiler zkSync Era is a layer 2 rollup that uses zero-knowledge proofs to scale Ethereum without compromising on security or decent

Unborrowed Rust Compiler (rustc without a borrowchecker)

ubrustc: Unborrowed rustc This is rustc with the borrow checker disabled. I wrote it in like, 30 minutes because this tweet made me laugh. Example //

Compiler frontend for the PureScript programming language.

purescript-analyzer Goals Provide an independent frontend for providing information for IDE tooling, separate from the compiler. Implement a rich edit

A rust library to interact with the Vyper compiler!

vyper-rs A rust library to interact with the Vyper compiler! Dependencies Please ensure that the Vyper compiler is installed and added to PATH! To ins

This rust compiler backend emmits valid CLR IR, enambling you to use Rust in .NET projects

What is rustc_codegen_clr? NOTE: this project is a very early proof-of-concept This is a compiler backend for rustc which targets the .NET platform an

An interpreter and compiler for the Brainfuck language.

Brainrust 🧠 An interpreter and compiler for the Brainfuck language. Prerequisites You need a LLVM 16.0.* installation on your system. On Windows, you

Learning rust by coding different sorting algorithms in it
Learning rust by coding different sorting algorithms in it

Sorting in Rust Sorting a 32 bit unsigned integer vector by using: Radix Sort Quick Sort Merge Sort Bubble Sort Inbuilt Sort (Probably Tim Sort) This

Learning Rust through Advent of Code 2021 - probably not very clean!

AoC 2021 ======== I'm using AoC2021 as an excuse to learn Rust (and maybe some other languages). Please do *not* use this repository as a good source

☃️ Learning Rust with AoC 2021 🎄https://adventofcode.com/2021/

🎄 Andrei's 2021 Advent of Code 🎄 Learning Goals Rust basics (vectors, arrays, math, etc.) Rust basic CLI Rust linear algebra and ndarrays (e.g., htt

Owner
Kevin Qiu
Kevin Qiu
Minimal Pandoc compiler -> HTML

Minimal Pandoc compiler -> HTML

/c/ympfh 1 Apr 6, 2022
Compiler for an "extended" version of the Mindustry logic language

Minblur Compiler Minblur is a compiler for a superset of "logic" programming language in the game Mindustry. It helps reduce code-duplication, making

Binder News 15 May 2, 2022
An awesome language and its compiler.

Calocom Project Build Build with cargo-make Just run cargo make in the root directory of the project. Or, if you want to build it in release mode, run

Aoyang Yu 31 Sep 16, 2022
Open-source compiler for the Papyrus scripting language of Bethesda games.

Open Papyrus Compiler This project is still WORK IN PROGRESS. If you have any feature requests, head over to the Issues tab and describe your needs. Y

erri120 22 Dec 5, 2022
Vyper-Compiler Version Manager in Rust

Vyper Compiler Version Manager in Rust Install $ cargo install --git https://github.com/storming0x/vvm-rs --locked vvm-rs Install from source $ git c

Storming0x 26 Dec 15, 2022
Discord-to-Cohost compiler written in Rust using Tera

Cohoard - Post formatted chatlogs to Cohost! Cohoard is a tool for turning chatlogs into formatted posts on Cohost. You can use Cohoard to easily form

Aaron Kofsky 14 Dec 15, 2022
🐱 HQ9C is a very serioues compiler for HQ9+, it meta-compiles with Rust.

HQ9+ Compiler HQ9c (Or HQ9+ Compiler) is a blockchain-based NFT minting AI machine-learning cloud infraestructure for the compiling of the great progr

Alex 5 Aug 28, 2022
Nederlandse programmeertaal. Geinterpreteerd en met dynamische types. Met bytecode compiler en virtual machine, in Rust.

Nederlang Nederlang is een geinterpreteerde programmeertaal, in het Nederlands! Met als bestandsnaam extensie.... .nl! Het maakt gebruik van dynamisch

Danny van Kooten 17 Dec 15, 2022
The JavaScript Oxidation Compiler -> Linter / Prettier

The JavaScript Oxidation Compiler (oxc) Why this project? The goal of this project is to: Create a blazingly fast JavaScript Compiler written in Rust.

Boshen 125 Feb 22, 2023
⚡ Blazing ⚡ fast ⚡ compiler for Cairo, written in 🦀 Rust 🦀

Cairo 1.0 ?? ⚡ Blazing ⚡ fast ⚡ compiler for Cairo, written in ?? Rust ?? Report a Bug - Request a Feature - Ask a Question Getting Started Prerequisi

Darlington Nnam 6 Feb 23, 2023