A dynamically-typed interpreted programming language implemented in C++.
ITMOScript interpreter executes .is source files with features including first-class functions, lists, strings, and standard control flow constructs. The implementation follows a classic multi-pass architecture: Lexer -> Parser -> AST -> Tree-walking Evaluator.
- Lexer - Tokenizes source code (numbers, strings, identifiers, operators, keywords)
- Parser - Recursive descent parser produces an AST with operator precedence
- Interpreter - Tree-walking evaluator with dynamic typing and garbage collection via
shared_ptr - Scope - Lexical scoping with parent chains for variable lookup and assignment
- Dynamic typing - Types checked at runtime, Python-like copy/value semantics
- Data types - Numbers (double), strings, lists, booleans, nil, first-class functions
- Operators - Arithmetic, comparison, logical (
and/or/not), indexing/slicing - Control flow -
if/else if/else,while,for-inloops,break/continue - Functions - First-class, higher-order, lexical closures,
returnstatements - Comments - Single-line
//comments
Math: abs, ceil, floor, round, sqrt, rnd, parse_num, to_string
Strings: len, lower, upper, split, join, replace
Lists: range, len, push, pop, insert, remove, sort
System: print, println, read, stacktrace
cmake -B build
cmake --build build#include "interpreter.h"
std::istringstream input("println(\"Hello, ITMOScript!\")");
std::ostringstream output;
interpret(input, output);- C++17 or later
- CMake 3.10+
- Google Test (for unit tests)
| File | Description |
|---|---|
lexer.h/lexer.cpp |
Tokenizer with keyword map |
token.h/token.cpp/token_type.h |
Token types and values |
ast.h |
AST node definitions (20+ node types) |
parser.h/parser.cpp |
Recursive descent parser with precedence climbing |
interpreter.h/interpreter.cpp |
Main evaluation loop and entry point |
value.h |
Variant-based dynamic value type |
scope.h/scope.cpp |
Lexical scope with parent chain |
function.h |
User-defined function representation |
standart_library_func.h/standart_library_func.cpp |
Built-in functions |
All runtime errors (type mismatches, out-of-bounds access, undefined variables) throw exceptions caught by the interpreter, with stack trace support via stacktrace().