Skip to content

anpawo/Glados-Mary

Repository files navigation

Mary Programming Language (GLaDOS)

Static Badge

The goal of this project is to implement a programming language of our own design in Haskell.

Needed Dependencies ⚙️

The best way to install Haskell, is using GHCup.

Build the Project 🛠️

After installing the necessary dependencies, in order to build the project, use the Makefile. Follow these steps:

  • Clone the project:
git clone git@github.com:anpawo/mary.git
  • Go to the project directory:
cd mary
  • Build using Makefile:
make

How to Use? 🛠️

  • First, you need to write a file according to the Mary syntax.
  • You should consider installing the vscode-extension for better readability.
  • Once your file is done, you can run it with ./glados <filename>

For starters, here's a little file with a guess the number game.

import std

function guess_the_number(n: int) -> void {
    print("guess the number between 0 and 100");
    guess: int = n + 1;
    while guess != n then
    {
        guess = toInt(getline());
        if guess == n then
        {
            print("you won");
        }
        else
        {
            if guess < n then
            {
                print("higher");
            }
            else
            {
                print("lower");
            }
        }
    }
}

function main() -> void {
    guess_the_number(random(0, 100));
}

Quick Guide

functions

function main() -> void {
  print("hello world");
}

binary operators with custom precedence

operator ** precedence 8 (n: int, power: int) -> int {
    if power == 0 then
    {
        return 1;
    }
    else
    {
        return n * n ** (power - 1);
    }
}

union types

type number = int | float

structures

struct person {
  name: str,
  age: int
}

lambdas (which are closure) and imports

import list
// provides the function map
// and the operator `..` (range)
// which are both coded in the mary language.
// check out the stdlib directory for more.

function main() -> void {
    print(map(\x -> x * 2, 1..10));
    //        ^^^^^^^^^^^
    //          lambda
}

// output [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]

You can do great things with this much!

For more information about the language, check out the Mary User Manual.

Our Team ❤️

Developers


Zacharie Rodde

Jean-Garice Denoncin

Ryan Hercule

Camil Kaddouri

Marius Rousset

About

Mary, an imperative statically-typed programming language.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors