百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

crust

> 编程语言
开源

C99 (玩具)编译器工具链在 Rust 中 (在一个周末里,为娱乐和自我教育)

176 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

C99 (玩具)编译器工具链在 Rust 中 (在一个周末里,为娱乐和自我教育)

CRUST

A simple C compiler written in the Rust-lang. (early development stage, started at Mar 30, 2019)

(PS. this is the development branch, if you want to see how to write a simple c compiler in rust, you should check branch toy, which contains a simple c compiler written in rust without extra libs, it can read simple c source code and produce x86-64 assembly code).

Project Goal

Should follow the C11 Standard and generate binary code from C source code.

This compiler is in the very early development stage, the plan is to continue developing it until it can compile real-world applications.

If you are interested in crust and want to contribute, feel free to join the Gitter chat room, we have already got some contributors now who are interested in building this project.

Milestone 0.1 Goal

  1. Finish the preprocessor.
  2. Support all C11 grammar rules.
  3. replace gcc with it's own assembler to generate binary code
  4. Stabilize the interfaces among different layers.
  5. With some possible optimizations.

Track of current progress

  • Preprocessor (working on)
    • support #include "local-header", nested-include is supported (need to add more features)
    • Trigraph translation
    • comment support /**/ and //
    • line concatenation with \
    • object-like macro expansion
    • function-like macro expansion
    • should support all directives (ifdef, elif, endif, ...)
  • Lexer (working on)
    • lex all c11 keywords
    • the floating point number and number with postfix should be supported later.
  • Parser (almost done, need to be carefully tested)
    • support c11 standard and generate ast tree
    • better ast printer
    • should be able handle typedef
    • add more tests for parser
  • Semantics Analyzer (working on)
    • Type system
    • Type checker
  • Benchmark (working on)
    • Use Criterion.rs to do benchmarks.
    • Generate more informations from benchmarking.
  • IR generator (TODO)
  • Optimizer (TODO)
  • Assembly code generator (TODO)
  • Code clean up
    • Remove #[allow(dead_code)]

Requirements

You need a valid rust environment, Cargo.

Build

(PS. Now the crust can only preprocess, lex, and parse the source code, the generator was disabled now).

bash
$ cargo build # use this command to build the project

run

bash
$ cargo run [FLAGS]  ...

Running Tests

Run:

bash
$ ./test_dev.sh

Benchmark

(PS. This is pretty time consuming, cause benchmark will do lots of iterations to test different layers' performance.

Might take 20 to 30 minutes until it is finished. ) Run:

bash
$ cargo bench

After it is finished, you can open target/criterion/report/index.html in your web browser to see the details of performance.

License

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rustassemblycc11compiler

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言