Skip to content

The Goat Compiler is written in Haskell utilizing lexical analyser (Alex), monadic parser (Parsec) and intermediate representation (Oz).

License

Notifications You must be signed in to change notification settings

CaviarChen/PLI_Goat_Compiler

 
 

Repository files navigation

Goat Compiler

Build Status GitHub repo size GitHub contributors GitHub

The Goat Compiler is written in Haskell utilizing lexical analyser (Alex), monadic parser (Parsec) and intermediate representation (Oz).

Authors

Goat Programming Language

You can access the specification of the Goat Programming Language here.

An example program:

# sample.gt
proc p(val int x, val int y)
    int a[2];
begin
    a[x] := 42;
    a[y] := a[x];
    write a[y];
    write "\n";
end

proc main ()
begin
    call p(1,0);
end

Usage

Build the compiler:

make

Display command line usage:

./Goat -h  
usage: Goat [-st | -sa | -sd | -p | -d | -r | -h] file
Options and arguments:
-st    : display secret tokens
-sa    : display secret Abstract Syntax Tree
-sd    : display secret Decorated Abstract Syntax Tree
-p     : pretty print the source file
-d     : debug build (no optimization)
-r     : release build (full optimization and remove comments)
-h     : display the help menu
file   : the file to be processed

default build (full optimization and keep comments)

Note that the compiler only generate OZ Intermediate Representation, to run the program, you'll need the OZ VM.

To run a program, you can use the script 'single_test.sh':

./single_test.sh sample.gt

To run the compiler against all test cases:

python3 test.py

Acknowledgement

This project is one of the assessments of COMP90045 Programming Language Implementation at the University of Melbourne. The lecturer Harald Søndergaard reserves all the rights.

The final mark of this project is 30 + 1 (bonus) out of 30.

About

The Goat Compiler is written in Haskell utilizing lexical analyser (Alex), monadic parser (Parsec) and intermediate representation (Oz).

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Haskell 82.9%
  • Python 10.1%
  • Logos 3.7%
  • Makefile 1.9%
  • Shell 1.4%