View on GitHub

MontiLang

A Customizable Stack-Oriented Imperative Programming language

About | Examples | Documentation | Downloads

Download this project as a .zip file Download this project as a tar.gz file

About

MontiLang is a Stack-Oriented imperative programming language developed in python. It is highly customisable and contains many features found in higher level and Object Oriented languages.

Current State

Some of the features that are currently implemented are as follows:

The following will be coming soon:

Installation

The simplest way to use MontiLang is to download the binaries from the Releases page. Alternatively, you can download and build from the source code with the instructions below.

The easiest way to compile and use Monti is through the python package ‘Pyinstaller’. Install Pyinstaller from PyPi and download the MontiLang source code.

On windows:

install mysysgit, or download source files directly.

python -m pip install pyinstaller
git clone https://github.com/lduck11007/MontiLang.git
cd MontiLang/src
pyinstaller icon=../icon.ico main.py -n monti
SETX /M path "%path%;C:\[path_to_directory]\MontiLang\src\dist\monti"

On Linux:

use pip, or the built-in package manager for your distro to install pyinstaller. If this does not work, install from the Pyinstaller releases and run setup.py, or run straight from the source code from pyinstaller.py.

git clone https://github.com/lduck11007/MontiLang.git
cd /MontiLang/src
pyinstaller icon=../icon.ico main.py -n monti
PATH=/path/to/location:$PATH

Usage:

To interpret a Monti file, use

path/to/monti/executable [file] <optional flags>

If no file is specified, Monti will launch into an interactive REPL

Including the the -c flag will cause the program to not run, but will preprocess and print the source code as it is read by the interpreter

Examples

Example program that takes an input as a number, and prints that far into the Fibonacci sequence.

/# Test Fibonacci program #/
|Enter length of sequence: | INPUT NIP VAR loop .

0 VAR a .
1 VAR b .
FOR loop
    a b + VAR c .
    a PRINT .
    b VAR a .
    c VAR b .
ENDFOR

FizzBuzz: Program that loops through numbers 1-100, prints ‘fizz’ if it is a multiple of 3, ‘buzz’ if a multiple of 5, and ‘fizzbuzz’ if both. &DEFINE LOOP 100& 1 VAR i .

FOR LOOP
    || VAR ln .
    i 5 % 0 == 
    IF : .
        ln |Buzz| + VAR ln .
    ENDIF
    i 3 % 0 ==
    IF : .
        ln |Fizz| + VAR ln .
    ENDIF
    ln || ==
    IF : .
        i PRINT .
    ENDIF
    ln || !=
    IF : .
        ln PRINT .
    ENDIF
i 1 + VAR i .
ENDFOR

See the Documentation.mt file in /examples for a more detailed explanation of language features.

Help contribute to MontiLang, add examples on rosettacode at https://rosettacode.org/wiki/Category:MontiLang