GitHub - nlsandler/write_a_c_compiler: Test suite to help you write your own C c...
source link: https://github.com/nlsandler/write_a_c_compiler
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Write a C Compiler!
This is a set of C test programs to help you write your own compiler. They were written to accompany this tutorial.
Usage
test all
./test_compiler.sh /path/to/your/compiler
test specific stages
To test stage 1 and stage 3,
./test_compiler.sh /path/to/your/compiler 1 3
To test from stage 1 to stage 6,
./test_compiler.sh /path/to/your/compiler `seq 1 6`
In order to use this script, your compiler needs to follow this spec:
-
It can be invoked from the command line, taking only a C source file as an argument, e.g.:
./YOUR_COMPILER /path/to/program.c
-
When passed
program.c
, it generates executableprogram
in the same directory. -
It doesn’t generate assembly or an executable if parsing fails (this is what the test script checks for invalid test programs).
The script doesn’t check whether your compiler outputs sensible error messages, but you can use the invalid test programs to test that manually.
Contribute
Additional test cases welcome! You can also file issues here, either about the test suite itself or about the content of the tutorial.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK