Install OCaml and OPAM. OCaml version 4.04.0 or higher is required.
- Install dependencies:
$ opam install ounit
Build the compiler binary using make.
$ make
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);
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