Developed by: Zayd Hammoudeh <zayd.hammoudeh@gmail.com>
Developed by Michal Young at the University of Oregon. A complete specification of the language is available here. The language is inspired by Alexander Aiken's COOL language. Features of the language include:
- User defined and base classes
- Functions & methods
- Basic looping
- Inheritance
- Type inference
- Operator syntactic sugaring
- Short-circuit evaluation
The compiler follows the standard five stages:
- Lexing
- Parsing
- AST Construction
- Type inference
- Code generation
Note that the code generated by the compiler is standard~C. The generated code does not free memory so care should be shown.
The following must be installed on your system to build the quack compiler.
A build script is included for your convenience. Simply run src/build.sh. This will create a binary file src/bin/code_generator.
To run the program, simply call:
src/bin/code_generator <quack_program_filename.qk>
If an error is encountered, the compiler quits immediately. Otherwise, the program generates an output .c file. This file is in the same location as the specified <quack_program_filename.qk> passed to the script. The filename is also the same. The only modification is that the file extension is changed to .c.
To compile the generated output, you call:
gcc <quack_program_filename.c> builtins.c
Observe that builtins.c is a dependency of the generated code. builtins.c and builtins.h are included in the src directory. Calling gcc as above should yield a compiled binary named a.out (or whatever name you specify with the -o option).
A suite of testcases showing example quack programs is included in the folder test. The expected output for each file is in the folder: test/expected. Automated running of the test bench is supported by the file quack_compiler_testbench.sh. A list of the test bench files and their expected return state is in the file test/all_tests.csv.