lotabout/write-a-C-interpreter
lotabout/write-a-C-interpreter has 4,402 GitHub stars and 772 forks. GitHot measured 0 stars in 24 hours and -2 in 7 days. Last checked 2026-11-09 13:38 UTC. Last push 2025-11-22.
Write a simple interpreter of C. Inspired by c4 and largely based on it.
Measured star growth
- in 24h
- 0
- in 7 days
- -2
- in 15 days
- Update delayed
- in 1 month
- Update delayed
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalC interpreter that interprets itself.
How to Run the Code
File xc.c is the original one and xc-tutor.c is the one that I make for
the tutorial step by step.
gcc -o xc xc.c
./xc hello.c
./xc -s hello.c
./xc xc.c hello.c
./xc xc.c xc.c hello.c
About
This project is inspired by c4 and is largely based on it.
However, I rewrote them all to make it more understandable and help myself to understand it.
Despite the complexity we saw in books about compiler design, writing one is not that hard. You don't need that much theory though they will help for better understanding the logic behind the code.
Also I write a series of article about how this compiler is built under directory tutorial/en.
There is also a chinese version in my blog.
- 手把手教你构建 C 语言编译器(0)——前言
- 手把手教你构建 C 语言编译器(1)——设计
- 手把手教你构建 C 语言编译器(2)——虚拟机
- 手把手教你构建 C 语言编译器(3)——词法分析器
- 手把手教你构建 C 语言编译器(4)——递归下降
- 手把手教你构建 C 语言编译器(5)——变量定义
- 手把手教你构建 C 语言编译器(6)——函数定义
- 手把手教你构建 C 语言编译器(7)——语句
- 手把手教你构建 C 语言编译器(8)——表达式
- 手把手教你构建 C 语言编译器(9)——总结
Resources
Further Reading:
- Let's Build a Compiler: An excellent starting material for building compiler.
Forks:
Licence
The original code is licenced with GPL2, so this code will use the same licence.
Explore related projects
codecrafters-io/build-your-own-x
Master programming by recreating your favorite technologies from scratch.
561,398 starspublic-apis/public-apis
A collective list of free APIs
497,679 starsmorluto/rea
Reverse engineer anything with agents, from app behavior down to native binaries.
447,495 starsopenclaw/openclaw
The AI that really does things. Any OS. Any Platform. The lobster way. 🦞
394,261 stars