A fast, lightweight interpreter for the Monkey programming language, implemented in C++23.
- REPL: Interactive Read-Eval-Print Loop with syntax highlighting and history (via
readline). - Data Types: Integers, Booleans, Strings, Functions, and Closures.
- Control Flow:
if-elsestatements,returnstatements. - Functions: First-class functions, higher-order functions, and closures.
- Testing: Comprehensive test suite using GoogleTest.
- Compiler: C++23 compatible compiler (e.g., GCC 13+, Clang 16+, or MSVC 19.36+).
- Build System: CMake (3.10+).
- Package Manager: vcpkg (recommended for dependencies).
- Libraries:
readline: For REPL history and editing.gtest: For running the test suite.
Ensure you have vcpkg installed and integrated with your build system.
cmake --preset vcpkg
cmake --build build./build/inkThe project uses GoogleTest for unit and integration testing.
cd build
./testsUse the let keyword to bind values to identifiers.
let x = 5;
let y = 10;
let label = "Hello, Ink!";Supports standard infix operators: +, -, *, /.
let result = (5 + 10) * 2 / 5; // 6let isTrue = true;
let isFalse = false;
5 == 5; // true
10 != 9; // true
10 > 5; // true
5 < 10; // trueFunctions are defined using the fn keyword.
let add = fn(a, b) {
return a + b;
};
add(5, 10); // 15Functions carry their environment with them.
let newAdder = fn(x) {
return fn(y) { x + y; };
};
let addTwo = newAdder(2);
addTwo(3); // 5if statements are expressions and return values.
let max = if (x > y) { x; } else { y; };src/: Implementation files.include/: Header files.tests/: Test suite.CMakeLists.txt: Build configuration.