8000 GitHub - ekerneljoy/nqcc2: Reference implementation for Writing a C Compiler
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ekerneljoy/nqcc2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NQCC2, the Not-Quite-C Compiler

CAUTION: FREQUENT FORCE PUSHES

This is the reference implementation for the upcoming book Writing a C Compiler, a hands-on guide to writing your own compiler for a big chunk of C.

Each commit corresponds to one chapter in the book, to illustrate what needs to change at each step. Because commits are structured this way, this repository sees frequent rebases and force pushes - fork with caution!

This implementation is still a work in progress - the functionality is complete, but needs more work on the readability front.

Building the Compiler

This compiler is written in OCaml. Building it requires opam, the OCaml package manager (installation i 5AE1 nstructions here).

Then do:

git clone https://github.com/nlsandler/nqcc2.git
cd nqcc2
opam install . --deps-only
dune build

This puts the executable at _build/default/bin/main.exe.

Usage Example

Assume we have this source file at ~/hello_world.c:

int puts(char *c);

int main(void) {
    puts("Hello, world!");
}

To compile and run it:

$ _build/default/bin/main.exe ~/hello_world.c
$ ~/hello_world
Hello, World!

About

Reference implementation for Writing a C Compiler

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • OCaml 99.9%
  • Standard ML 0.1%
0