Skip to content

RegistersNinja/C_Compiler_In_Rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C Compiler in Rust

Description

A Rust implementation of a simple C static program along the lines of:

int main(void) {
    return 2;
}

The compilation consists of three stages:

  1. The lexer: tokenizes the program.
  2. The parser: builds AST (as enums) and handles the proper syntax (as well as descending recursion that practically doesn't exist here because of simplicity)
  3. The assembly generator: outputs the assembly

Preprocessor and linker that were used are from gcc.

Project structure

/src
├── args.rs
├── compiler
│   ├── assembly_generator.rs
│   ├── lexer.rs
│   ├── mod.rs
│   └── parser.rs
└── main.rs

Reference

  1. Nora Sandler - Blog
  2. Writing C compiler
  3. Probably the best Stack post ever

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published