Skip to content

A C-Minus compiler which emits DCODE. Interesting, but otherwise utterly useless.

License

Notifications You must be signed in to change notification settings

IvanPedrero/c-minus

 
 

Repository files navigation

Overview

c-minus is a ridiculously trivial compiler project, which was originally written for a university subject (Queensland University of Technology's course ITB464 Modern Compiler Construction). It implements the C-Minus language, which is the simplest possible conventional imperative language that does something interesting (recursion, arrays, iteration, decision -- that's it)

Here's what a C-Minus program might look like:

/*
 * A program to perform Euclid's algorithm to computer
 *  the greatest common denominator (GCD) of a pair of integers. 
 */

int gcd(int u, int v)
{
    if (v == 0) return u ;
    else return gcd(v,u-u/v*v);
    /* u-u/v*v == u mod v */
}

void main(void)
{   int x; int y;
    x = input(); y = input();
    output(gcd(x,y));
}

Presently, it implements a single DCODE back end, which emits the intermediate representation used by QUT's proprietary Gardens Point Modula suite of compilers.

To Do

  • Implement a different back end so it can generate executables on contemporary machines; e.g. LLVM, MSIL.

Support

Supplied as-is. If it breaks, you get to keep both pieces.

Example Usage

A few examples are below, but you my also find example usage in the '/example' and '/test' directories.

About

A C-Minus compiler which emits DCODE. Interesting, but otherwise utterly useless.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 99.9%
  • Shell 0.1%