Skip to content

MinimumC is a minimum C compiler intended to parse tokens, check grammar correctness and generate x86 code.

Notifications You must be signed in to change notification settings

ChrisWang13/MinimumC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MinimumC

MinimumC is a minimum C compiler intended to parse tokens, check grammar correctness and generate x86 code.

Usage

To compile MinimumC, run make in the root folder of this project.

To run MinimumC with specific arguments, run ./MinimumC "YOUR_INPUT_PROGRAM_HERE" and output of printf will be redirect to asm file.

Testing

To test the code works, run make test. tesh.sh is the test file, it first generate lib.o with gcc options -x(specificy input language, here as C),-c(no link) from redirect texts. Then it checks whether the actual return value and the estimated value are equal.

Debugging

To enable terminal debugging in MinimumC, set DEBUG_TOKEN, DEBUG_PARSE, DEBUG_CODEGEN to value 1

// Set Debug mode to non-zoro to enable debug.
#define DEBUG_TOKEN 1
#define DEBUG_PARSE 1
#define DEBUG_CODEGEN 1

Warning:

Since both debugging and code generation print the output to stdout, it is buggy to enable debugging while generating asm file.

Reference:

  1. C Coding Standard: https://users.ece.cmu.edu/~eno/coding/CCodingStandard.html

  2. Crafting Interpreters:https://craftinginterpreters.com/contents.html

About

MinimumC is a minimum C compiler intended to parse tokens, check grammar correctness and generate x86 code.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published