A lightweight, modern scripting language interpreter written in C++. ManaScript is designed to be simple yet powerful, with a clean syntax and robust features.
- Modern C++ implementation
- Clean and intuitive syntax
- Support for basic arithmetic operations
- Variable declarations and assignments
- Control flow statements (if/else)
- Print statements for output
- Interactive mode
- File execution mode
- Tokenization and parsing
- Abstract Syntax Tree (AST) generation
- CMake (version 3.10 or higher)
- C++17 compatible compiler
- Visual Studio 2022 (for Windows)
- PowerShell (for Windows build script)
-
Install Required Tools
- Install Visual Studio 2022 with C++ development tools
- Install CMake from cmake.org
- Ensure PowerShell is available (comes with Windows 10/11)
-
Clone the Repository
git clone https://github.com/ItsVicky25/mana-script.git
cd mana-script- Build the Project
- On Windows:
# Run the build script
./build.ps1
# The script will:
# 1. Create a build directory
# 2. Configure CMake
# 3. Build the project
# 4. Create a bin directory with the executable- On Linux/macOS:
# Create and enter build directory
mkdir build
cd build
# Configure and build
cmake ..
make
# Create bin directory and copy executable
mkdir -p ../bin
cp manascript ../bin/- Verify Installation
# Check if the executable exists
ls bin/manascript.exe # Windows
ls bin/manascript # Linux/macOS
# Run version check
./bin/manascript.exe -v # Windows
./bin/manascript -v # Linux/macOS# Start the interpreter in interactive mode
./bin/manascript.exe -i # Windows
./bin/manascript -i # Linux/macOS
# Example interactive session:
> let x = 10
> let y = 20
> print(x + y)
30
> exitCreate a file named hello.ms:
// hello.ms
let name = "World";
print("Hello, " + name + "!");
let sum = 5 + 3;
print("5 + 3 = " + sum);Run the script:
./bin/manascript.exe hello.ms # Windows
./bin/manascript hello.ms # Linux/macOS# Execute code directly from command line
./bin/manascript.exe -e "let x = 5; print(x * 2);" # Windows
./bin/manascript -e "let x = 5; print(x * 2);" # Linux/macOS# Run the test suite
./build/tests/Release/test_lexer.exe # Windows
./build/tests/test_lexer # Linux/macOSThe examples directory contains sample scripts:
# Run an example script
./bin/manascript.exe examples/arithmetic.ms # Windows
./bin/manascript examples/arithmetic.ms # Linux/macOS-
Build Fails
- Ensure CMake is properly installed
- Check if Visual Studio 2022 is installed with C++ tools
- Verify PowerShell execution policy allows script execution
-
Executable Not Found
- Check if the
bindirectory exists - Verify the build process completed successfully
- Ensure you're in the correct directory
- Check if the
-
Script Execution Errors
- Check script syntax
- Verify file permissions
- Ensure file extension is
.ms
let x = 10;
let name = "John";let sum = 5 + 3;
let product = 4 * 2;
let difference = 10 - 5;
let quotient = 15 / 3;if (x < y) {
print("x is less than y");
} else {
print("x is greater than or equal to y");
}print("Hello, World!");
print(42);mana-script/
├── bin/ # Compiled executables
├── include/ # Header files
├── src/ # Source files
├── tests/ # Test files
├── examples/ # Example scripts
├── CMakeLists.txt # CMake build configuration
└── build.ps1 # Windows build script
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by modern scripting languages like JavaScript,c++ and Python