Purple
A simple compiled language
Purple Docs

Introduction

Purple is a simple compiled language. Right now it supports:

  • Compilation into x86, MIPS
  • Basic arithmetic parsing with precedence
  • Comparisons
  • Variable declaration and assignment
  • If, Else statements
  • While Loops

Examples

Purple uses C-style syntax, although this may change as the compiler is built

{
int bob;
int alice;
bob = 5;
alice = 10;
print bob + alice; // 15
print bob > alice; // 0
int bob_alice;
bob_alice = 10 + 10 + bob + alice; // 35
if(bob_alice > 30){
print bob_alice;
}
int i;
i = 0;
while (i < 20) {
print i;
i = i + 1;
}
}

More examples can be viewed here.

Installation

View the source here.

Purple may be built with cmake:

mkdir build && cd build
cmake ..
make
cd ..
bin/purple example_file.prp