Skip to content
Port of 9cc simple c compiler
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
program
.gitignore A very simple compiler that comiles an integer. Nov 10, 2018
Makefile A file tree_analysis.c is added. Listing of string literals is done i… Dec 27, 2018
README.md
codegen.c
dtype.c
dtype_test.c
m99cc.h
main.c A bug that struct size was wrongly calculated is fixed. Jan 6, 2019
note.md Global variables are added. Dec 8, 2018
parse.c Dot operator and arrow operator can be parsed. Jan 5, 2019
parse_test.c Some functions added. Test is passing. Jan 6, 2019
test.sh Very simple struct variable working. Jan 6, 2019
token.c Add dot operator (.) and arrow operator to token.c and token_test.c Jan 5, 2019
token_test.c Add dot operator (.) and arrow operator to token.c and token_test.c Jan 5, 2019
tree_analysis.c
util.c A bug that struct size was wrongly calculated is fixed. Jan 6, 2019
util_test.c Any previously unadded files added. Dec 13, 2018

README.md

About

This is a compiler for a c-like-language.

The early version of the code was based on 9cc which is explained in web based tutorial [低レイヤを知りたい人のためのCコンパイラ作成入門](https://www.sigbus.info/compilerbook\) by Rui Ueyama.

Now the large part of the code has been diverted from the original 9cc.

What does it do?

Not much yet.

Basic codes like below can be compiled to assembly code. (print() is defined separately. Full code is in program/fibonacci.c)

int main() {
  int i;
  int d, e, f;
  d = 0;
  e = 1;
  f = 1;
  for(i = 0; i < 11; i = i + 1) {
    print(d);
    f = d + e;
    d = e;
    e = f;
  }
  putchar(10);
  0;
}

This code write fibonacci seriese to the console, like below.

0 1 1 2 3 5 8 13 21 34 55

You can’t perform that action at this time.