Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lotabout/write-a-C-interpreter
Write a simple interpreter of C. Inspired by c4 and largely based on it.
https://github.com/lotabout/write-a-C-interpreter
Last synced: 3 months ago
JSON representation
Write a simple interpreter of C. Inspired by c4 and largely based on it.
- Host: GitHub
- URL: https://github.com/lotabout/write-a-C-interpreter
- Owner: lotabout
- License: gpl-2.0
- Created: 2015-12-23T04:52:31.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2024-03-29T09:30:51.000Z (10 months ago)
- Last Synced: 2024-10-15T09:41:03.441Z (3 months ago)
- Language: C
- Size: 155 KB
- Stars: 4,024
- Watchers: 153
- Forks: 743
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- AwesomeInterpreter - write-a-C-interpreter
README
C 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](https://github.com/rswier/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.
1. [手把手教你构建 C 语言编译器(0)——前言](http://lotabout.me/2015/write-a-C-interpreter-0/)
2. [手把手教你构建 C 语言编译器(1)——设计](http://lotabout.me/2015/write-a-C-interpreter-1/)
3. [手把手教你构建 C 语言编译器(2)——虚拟机](http://lotabout.me/2015/write-a-C-interpreter-2/)
4. [手把手教你构建 C 语言编译器(3)——词法分析器](http://lotabout.me/2015/write-a-C-interpreter-3/)
4. [手把手教你构建 C 语言编译器(4)——递归下降](http://lotabout.me/2016/write-a-C-interpreter-4/)
5. [手把手教你构建 C 语言编译器(5)——变量定义](http://lotabout.me/2016/write-a-C-interpreter-5/)
6. [手把手教你构建 C 语言编译器(6)——函数定义](http://lotabout.me/2016/write-a-C-interpreter-6/)
7. [手把手教你构建 C 语言编译器(7)——语句](http://lotabout.me/2016/write-a-C-interpreter-7/)
8. [手把手教你构建 C 语言编译器(8)——表达式](http://lotabout.me/2016/write-a-C-interpreter-8/)
0. [手把手教你构建 C 语言编译器(9)——总结](http://lotabout.me/2016/write-a-C-interpreter-9/)# Resources
Further Reading:
- [Let's Build a Compiler](http://compilers.iecc.com/crenshaw/): An excellent
starting material for building compiler.Forks:
- [A fork that implement debugger for xc.c](https://github.com/descent/write-a-C-interpreter)
# Licence
The original code is licenced with GPL2, so this code will use the same
licence.