A functional programming language implementation in Rust with a complete toolchain including parser, type checker, bytecode compiler, virtual machine, and Language Server Protocol support.
- Parser using Pest with Pratt parser for operator precedence
- Semantic analysis and type checking with HIR (High-level Intermediate Representation) lowering
- Bytecode compilation with optimization passes
- Stack-based virtual machine with NaN-boxed values for efficient execution
- Language Server Protocol (LSP) support for IDE integration
- Project management tool (
melon) for creating and running projects - Module system with dot-path imports
- Lazy evaluation with thunks and function composition
- Standard library with math, string, array, and functional utilities
The melon tool provides project management and execution:
# Create a new project
cargo run --bin melon -- new myproject
cd myproject
# Run the project
cargo run --bin melon -- run
# Run with watch mode (auto-rebuild on file changes)
cargo run --bin melon -- run --watch
# Run with debug output (AST, HIR, bytecode)
cargo run --bin melon -- run --debug# Build the interpreter
cargo build --release
# Run a single file
cargo run --bin melon -- run examples/language_features/helloworld.mlnThe LSP provides real-time diagnostics, hover information, code completion, and semantic tokens. See BUILD.md for building and installing the VS Code/Cursor extension.
# Build all binaries
cargo build --release
# Build specific binaries
cargo build --release --bin melon # Project manager
cargo build --release --bin cantaloop-lsp # LSP serversrc/core/- Core language implementationparser.rs- Pest-based parserast/- Abstract Syntax Tree (enums, builder)hir_lowering/- Type checking and HIR generationbytecode/- Bytecode compilation (emitter, opcode)vm.rs- Stack-based virtual machineengine.rs- Compilation and execution orchestrationprojectLoader.rs- Project loading and module resolution
src/lsp/- Language Server Protocol implementationsrc/melon/- Project management CLI toolsrc/stdlib/- Standard library modulesexamples/- Example.mlnfiles and projectsdocumentation/- Architecture and design documentation
See documentation/ARCHITECTURE.md for a detailed description of the system architecture.