• Stars
    star
    3,825
  • Rank 11,006 (Top 0.3 %)
  • Language
    C
  • License
    GNU General Publi...
  • Created over 8 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Write a simple interpreter of C. Inspired by c4 and largely based on it.

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 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)——前言
  2. 手把手教你构建 C 语言编译器(1)——设计
  3. 手把手教你构建 C 语言编译器(2)——虚拟机
  4. 手把手教你构建 C 语言编译器(3)——词法分析器
  5. 手把手教你构建 C 语言编译器(4)——递归下降
  6. 手把手教你构建 C 语言编译器(5)——变量定义
  7. 手把手教你构建 C 语言编译器(6)——函数定义
  8. 手把手教你构建 C 语言编译器(7)——语句
  9. 手把手教你构建 C 语言编译器(8)——表达式
  10. 手把手教你构建 C 语言编译器(9)——总结

Resources

Further Reading:

Forks:

Licence

The original code is licenced with GPL2, so this code will use the same licence.

More Repositories

1

skim

Fuzzy Finder in rust!
Rust
4,856
star
2

rargs

xargs + awk with pattern matching support. `ls *.bak | rargs -p '(.*)\.bak' mv {0} {1}`
Rust
462
star
3

Let-s-build-a-compiler

A C & x86 version of the "Let's Build a Compiler" by Jack Crenshaw
C
455
star
4

fuzzy-matcher

Fuzzy Matching Library for Rust
Rust
240
star
5

very-simple

A very simple theme for hexo
SCSS
149
star
6

skim.vim

vim support for skim
Vim Script
133
star
7

tuikit

Tool kit for writing TUI applications in Rust.
Rust
103
star
8

hexo-theme-noise

A hexo theme
Less
100
star
9

CodeGenerator

Intellij IDEA Plugin for creating customized code generators like the builtin toString, equals, etc.
Java
49
star
10

spring-security-example

REST authentication apis & token based authentication, etc.
Java
32
star
11

transformer-playground

Annotation processor @Transform for creating transformers for classes.
Java
16
star
12

pymustache

Mustache template engine from scratch in Python.
Python
16
star
13

static-wiki

CSS
14
star
14

SlackGuide-cn

A chinese guide for slackware based on SlackBook.
11
star
15

dotfiles

Manage the resource files under home folder
Emacs Lisp
8
star
16

lotabout.github.io

My personal blog. (source at source branch)
C++
8
star
17

buddy-system

Simple implementation of a buddy system for memory management.
C
8
star
18

orgwiki

personal wiki generated by org-mode
CSS
8
star
19

compiler-design-in-c

Codes for book <compiler design in C>
C
6
star
20

ywvim

a fork of ywvim. http://www.vim.org/scripts/script.php?script_id=2662
Vim Script
6
star
21

vimwiki-tpl

template for vimwiki
CSS
5
star
22

project-euler-racket

Project Euler in racket.
Racket
5
star
23

axe

Handy utilities for racket
Racket
5
star
24

simple-template-engine

A simple template engine written in python
Python
5
star
25

mdbook-fix-cjk-spacing

mdbook preprocessor that removes extra space rendered for Chinese lines.
Rust
4
star
26

c-interfaces

codes for book "C Interfaces and Implementation Techniques".
C
4
star
27

underscore-comment

Read and Comment on source code of underscore.js
JavaScript
3
star
28

hexo-filter-fix-cjk-spacing

Join continuous CJK lines in markdown in Hexo.
JavaScript
3
star
29

simple-framework

A simple python web framework from scratch
Python
3
star
30

jasypt-online

Jasypt 在线加解密工具
HTML
2
star
31

nikola-bnw

A nikola theme.
CSS
2
star
32

zzz

theme for nikola
CSS
2
star
33

ideas

log for new ideas and the execution of ideas
2
star
34

cup

A small web framework for racket
Racket
2
star
35

learn-c-the-hard-way

code & exercise reading book <Learn C the hard way>
C
2
star
36

curtail

pipe stdin to a fixed-size log file
Rust
2
star
37

build-your-own-pytorch

Understand deep learning framework(like torch) by implementing the essentials
Python
2
star
38

zlex

A lexical analyzer generator.
C
2
star
39

pymkd

Markdown in python
Python
1
star
40

cljs-douban

douban.fm in CLJS+Electron
Clojure
1
star
41

lemon

Lemon parser generator (http://www.hwaci.com/sw/lemon/). Submit for code review for study purpose.
C
1
star
42

code-snippets

collection of useful code snippets.
C
1
star
43

my-time

A time management web application written in clojure with luminus.
Clojure
1
star
44

cljs-douban-reframe

douban.fm in CLJS+Electron+Re-frame
Clojure
1
star
45

my-slackbuilds

My slackware build scripts
Shell
1
star
46

pscat

socat in one python file
Python
1
star
47

orgmark.vim

Vim Script
1
star
48

docker-slackware

Build slackware images for docker
1
star
49

LiSP

Codes for book "Lisp in Small Pieces"
Scheme
1
star
50

java-spi-playground

A simple expression interpreter that use SPI to load user-customized functions
Java
1
star
51

dragon-book-notes

Notes reading the Dragon Book.
C
1
star
52

dwm

My own customization of dwm, starting with dwm-6.0.
C
1
star