A statically-typed procedural programming language with an interpreter built in C++.
Try it out on the web!
·
Report Bug
·
Request Feature
Table of Contents
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++.
A web version of the Lotus interpreter can be found here: https://multipixels.dev/projects/lotus-lang/.
Follow these steps to set up and run the Lotus interpreter on your local machine.
Ensure you have the following installed:
- A C++ compiler
- CMake
-
Clone the repository:
git clone https://github.com/Multipixels/lotus-lang.git
-
Navigate to the project's root directory:
cd lotus-lang -
Generate a new directory
outand navigate to it:mkdir out cd out -
Run CMake:
For just the Lotus interpreter, run
cmake ..
For the Lotus interpreter and test suites, run
cmake .. CMAKE_BUILD_TYPE=Debug
-
Compile the project.
i. (Windows) Open solution
out\LotusLang.slnin Visual Studio and build.ii. (Mac/Linux) Run
make -
(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
To open up the interpreter in your CLI, simply run the binary.
- (Windows):
.\LotusLang.exe- (Mac/Linux):
./LotusLangWrite 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
- Windows:
.\LotusLang.exe example.lotus- Mac/Linux:
./LotusLang example.lotus- Statically-Typed Variables: Includes primitive types like
boolean,integer,float,character, andstring. - Collections and Dictionaries: Flexible and easy-to-use data structures.
- Functions: Define reusable blocks of code with return types and parameters.
- Control Structures: Use logic and loop structures, like
if-else,while,for, and more. - Built-in Functions: Log messages to the console, modify collection contents, and more.
Richard Motorgeanu - richard.motorgeanu@gmail.com
Project Link: https://github.com/Multipixels/lotus-lang