Skip to content

hwielenberg/moco

 
 

Repository files navigation

Moco Build Status

moco is a Monty to LLVM compiler built using Java, ANTLR4 and LLVM.

Please read the language specification for details on the Monty programming language and refer to the feature overview for a list of implemented features.

Installing Dependencies

Linux (Ubuntu)

Install LLVM and a JRE 7.

sudo apt-get install llvm
sudo apt-get install default-jre

If you want to build moco yourself you'll need to install the following dependencies and a JDK 7.

sudo apt-get install git
sudo apt-get install maven
sudo apt-get install default-jdk

You can also install Graphviz to generate class diagrams. This is optional.

sudo apt-get install graphviz

Mac OS X

Note: Please make sure you have homebrew and a JRE 7 installed.

Install LLVM using homebrew:

brew install llvm

If you want to build moco yourself you'll need to install the following dependencies and a JDK 7.

brew install git
brew install maven

Please make sure to set the JAVA_HOME environment variable for maven.

export JAVA_HOME=$(/usr/libexec/java_home)

You can also install Graphviz to generate class diagrams. This is optional.

brew install graphviz

Windows

To use LLVM you'll need to download and install the following executables. In addition you'll need to download and extract the llvm-3.4-tools-windows.7z archive into the bin\ directory of your LLVM installation. To run the executable .jar file you'll also need a JRE 7.

If you want to build moco yourself you'll need to install the following dependencies and a JDK 7. These examples use the chocolatey package manager.

choco install maven
choco install java.jdk
choco install git.commandline

You can also install Graphviz to generate class diagrams. This is optional.

choco install graphviz

Building

Note: Instead of building your own version you can always get a precompiled .jar file at the releases page.

For building your own version based on the most recent commit clone the git repository:

git clone https://github.com/MontysCoconut/moco.git

After that you can change into the directory and build the executable .jar file. Now you can find the executable jar in the target/ directory.

cd moco
mvn package

If you want to generate the class documentation make sure to have graphviz installed and run the following command. After that you can find the generated HTML-files in the target/site directory.

mvn site

For some background information and a guide to submit merge requests please read hacking.

Usage

To use moco you'll either need to compile your own version or fetch a precompiled .jar file at the releases page.

You can just pass moco a Monty-file and it will be compiled and executed.

➤ cat hello.monty
print("Hello World!")
➤ java -jar moco-0.6.jar hello.monty
Hello World!

Please see the help text for information about the command-line switches. usage: moco [--help] [-S] [-c] [-e] [-p] [-d] [-o ] [file]

The Monty compiler.

positional arguments:
file                   Monty file to run.

optional arguments:
--help                 Print this help and exit.
-S, --emit-assembly    Emit the LLVM assembly and stop.
-c, --compile-only     Only compile the executable without running it.
-e, --stop-on-first-error
                        Stop the compilation on the first encountered error.
-p, --print-ast        Print the AST.
-d, --debug-parsetree  Debug the parsetree without running anything.
-o <file>              Write output to <file>.

Without -S or -c the program is compiled and directly executed.

Packages

No packages published

Languages

  • Java 96.4%
  • ANTLR 2.1%
  • LLVM 1.3%
  • Other 0.2%