Skip to content

seg4lt/jai-c-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C Compiler in Jai

Simple implementation of c-compiler using Jai

TODO

  • SETCC needs only 1 byte, but today we are using 4 bytes. Need to fix this
  • Parse typedef - Read more on context sentitive grammer.
  • Update to support arm64 assembly
  • Revamp output printer and add tests
  • Function pointers
    • Implement after arrays are added
  • Support sending multiple files

Notes

  • Run on docker - docker-compose exec box bash -c 'jai build.jai && ./out/jaicc -- ./c/main.c && ./c/main && echo $?'

Run on Mac - (ld doesn't work on M1)

  • arch -x86_64 - run x86_64 binaries on M1 mac
  • arch -x86_64 fish - run x86_64 binaries on M1 mac

Test Flags

Command: ./test_compiler ../out/jaicc --chapter 1 --stage lex

  • Lex: --stage lex - for lex
  • Parse: --stage parse ,
  • Validate: --stage validate
  • Asm Gen: --stage codegen
  • Tacky IR: --stage tacky
  • Full: --chapter <n> Extras
  • Bitwise: ./test_compiler /path/to/your_compiler --chapter 3 --stage bitwise
  • Run all extra credit stuff: --extra-credit
  • --bitwise --compound --increment

Clone Repo Notes

  • Initial clone: git clone --recurse-submodules <repository_url>
  • If you already cloned the repository without --recurse-submodules, you can initialize and update the submodules afterward: git submodule update --init --recursive

References

About

basic c compiler written in jai

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages