Skip to content

Shoo is a statically typed programming language with first-class functions, structs, and arrays.

License

Notifications You must be signed in to change notification settings

claire-1/shoo-lang

 
 

Repository files navigation

shoo-lang

CircleCI Coverage Status

Table of Contents

Overview

This project is our compiler for the Fall 2018 Progamming Languages and Translators class at Columbia University taught by Professor Stephen Edwards. We worked a group to design our own programming language and compiler for it. The Shoo_Final_Report.pdf details the development of our language, how to write a program in our language, and the division of labor.

Requirements

Install OCaml and OPAM. OCaml version 4.04.0 or higher is required.

  • Install dependencies:
$ opam install ounit

Usage

Build the compiler binary using make.

$ make

Sample Program

Shoo is a programming language with C-like syntax while supporting first class functions, structs, and type inference.

Here is a sample program written in Shoo:

struct Professor {
  string name;
}

struct Student {
  string name;
  func(Professor;void) greet;
}

function createProfessor(string name) Professor {
  return { name = name; };
}

function createStudentCreator(string defaultGreeting) func(string;Student) {
  return function(string name) Student {
    function helper(int i) string {
      string x = "st";
      if (i == 0 || i == 4) {
        x = "th";
      } elif (i == 2) {
        x = "nd";
      } elif (i == 3) {
        x = "rd";
      }
      return str_of_int(i) + x;
    }
    return {
      name = name;
      greet = function(Professor p) void {
        for (int i = 0; i < 5; i = i + 1) {
          println(name + " says " + defaultGreeting + " to " + p.name + " for the " + helper(i) + " time");
        }
        return;
      };
    };
  };
}

Professor stephen = createProfessor("Stephen");

createStudentCreator("hello")("Sam").greet(stephen);

Running Tests

Take a look inside testall.sh for the variables which set the path to the LLVM interpreter as variable "lli". Set the path to the LLVM compiler as "llc". Set the path to the C compiler as "cc".

$ make
$ ./testall.sh

About

Shoo is a statically typed programming language with first-class functions, structs, and arrays.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TeX 80.9%
  • OCaml 16.7%
  • Shell 1.3%
  • Other 1.1%