Lotus

Output

12

Lotus

A statically-typed procedural programming language with an interpreter built in C++.

Lotus is a programming language I developed to explore the principles of statically-typed procedural languages, test-driven development, and software testing. With Lotus, you can write programs using familiar constructs like collections, dictionaries, and control structures, all parsed and interpreted through an interpreter written in C++.

Built With

Prerequisites

Ensure you have the following installed:

Installation

  1. Clone the repository:
    git clone https://github.com/Multipixels/lotus-lang.git
    
  2. Navigate to the project’s root directory:
    cd lotus-lang
    
  3. Generate a new directory out and navigate to it:
    mkdir out
    cd out
    
  4. Run CMake:
    For just the Lotus interpreter, run
    cmake ..
    

    For the Lotus interpreter and test suites, run

    cmake .. CMAKE_BUILD_TYPE=Debug
    
  5. Compile the project.
    i. (Windows) Open solution out\LotusLang.sln in Visual Studio and build.
    ii. (Mac/Linux) Run make

  6. (Optional, Windows only) Compile the project for the web w/ Emscripten. Requires Emscripten installed and setup.
    mkdir out
    cd out
    mkdir build-wasm
    cd build-wasm
       
    call emcmake cmake ../..  -D DCMAKE_SYSTEM_NAME=Emscripten
       
    cmake --build . --target LotusLangWeb
    

Usage

CLI Interpreter

To open up the interpreter in your CLI, simply run the binary.

Interpret Lotus Code from Files

Write Lotus programs in .lotus files and run them through the interpreter. Here’s an example program:

-> Find the sum of the values in a collection
integer sum = 0;
collection<integer> myCollection = [2, 4, 6];

iterate(value : myCollection) {
  sum += value;
}

log(sum);

Run the program

Features

GitHub Page