Skip to content

ZaydH/quack_compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quack Language Compiler

Documentation Status docs

Developed by: Zayd Hammoudeh <zayd.hammoudeh@gmail.com>

Quack Language

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

Compiler Stages

The compiler follows the standard five stages:

  1. Lexing
  2. Parsing
  3. AST Construction
  4. Type inference
  5. 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.

Compiler Dependencies

The following must be installed on your system to build the quack compiler.

Building & Running the 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).

Testbench

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.

About

Compiler for the Toy Quack Language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors