An open API service indexing awesome lists of open source software.

https://github.com/rozukke/cig

C compiler written in Zig.
https://github.com/rozukke/cig

Last synced: 11 days ago
JSON representation

C compiler written in Zig.

Awesome Lists containing this project

README

          

```
a, 8a
`8, `8) ,adPPRg,
8) ]8 ,ad888888888b
,8' ,8' ,gPPR888888888888
,8' ,8' ,ad8"" `Y888888888P
8) 8) ,ad8"" (8888888""
8, 8, ,ad8"" d888""
`8, `8, ,ad8"" G ,ad8""
`8, `" ,ad8"" I ,ad8""
,gPPR8b C ,ad8""
dP:::::Yb ,ad8""
8):::::(8 ,ad8""
Yb:;;;:d888""
"8ggg8P"
```

# cig

The coolest C compiler in town... he even smokes.
Built by following Nora Sandler's "Writing a C Compiler" book using Zig.

## Usage
> [!IMPORTANT]
> Supports Linux and MacOS. Tested on Ubuntu 24.04 x86_64.

To run on a C source file, you can use the below command:

```bash
zig build run -- source.c

```
Below commands are available to test separate compiler stages:
- `--lex`: stop at lexing
- `--parse`: stop at parsing
- `--codegen`: stop at codegen
- `-S`: emit assembly but do not assemble

## Progress
Currently finished with Chapter 1, meaning that the compiler can currently:
- Compile programs that can return an integer in a single top level main function
- Detect syntax and language errors related to the above
- Display basic error messages

## LICENSE
**See LICENSE file.**
**Copyright © 2025 Artemis Rosman**

Header ASCII art by Normand Veilleux.