9cc is a small, simple, easy to understand C compiler developed by Rui Ueyama. This repositry is my implementation of 9cc based on his book '低レイヤを知りたい人のためのCコンパイラ作成入門'.
- Calculator-like language
- Compile a single integer
- Addition and Subtraction
- Tokenizer
- Multiplication and Division
- Unary
+
and-
- Comparison operators
- Support arbitrary length input
- Separated compilation
- Variables and functions
- Single character local variables
- Support
return
statement - Multi-character local variables
- Control structures
- if
- while
- for
- Block
- Function call
- Function definition
- Pointer and string literal
- Introduce 'int' keyword instead of implicit type declaration
- Support pointer type
- Pointer addition/subtraction
- Support
sizeof
operator - Support array type
- Index of array
- Global variables
- Support
char *
type - String literal
- Input from file
- Line comment and block comment
- Rewrite tests in C
- Executable image and initialization expression
- Syntax of types in C
- propagate 'input' to all node types
- Rename type to kind
- Separate files
- Add rewriting AST rule for
&array_name
case. - Implement selectors for kind of Node and kind of Type of Node
- Use 4-byte size for
int
- Implement functions for Type size