MSc thesis project implementing Rizzo, a programming language based on the work of Rizzo by Patrick Bahr, with a focus on memory management and safety. The project includes:
- A compiler that translates Rizzo source code to C, leveraging reference counting for memory management.
- A C runtime library that provides memory management primitives, safety checks and the Rizzo advance and update semantics.
- A VS Code extension that integrates the Rizzo compiler and language server for an enhanced development experience with diagnostics, hover information, and code navigation (Rough implementation; not the focus of the MSc thesis).
- OCaml (4.14+) and opam — for building the compiler
- Dune — OCaml build system (usually installed via opam)
- GCC or Clang — for compiling generated C code
- Node.js and npm — for the VS Code extension (optional)
Run the install script to download and install the latest version:
curl -fsSL https://raw.githubusercontent.com/itu-msc/RizzoMemory/main/install.sh | bashTo install a specific version, pass the --version flag:
curl -fsSL https://raw.githubusercontent.com/itu-msc/RizzoMemory/main/install.sh | bash -s -- --version v0.1.2Security Note: For added security, you can download and inspect the script before running it:
curl -fsSL https://raw.githubusercontent.com/itu-msc/RizzoMemory/main/install.sh -o install.sh # Review the script cat install.sh # Run it bash install.sh
By default the installer:
- installs versioned toolchains under
${XDG_DATA_HOME:-$HOME/.local/share}/rizzo/toolchains - updates
${XDG_DATA_HOME:-$HOME/.local/share}/rizzo/current - links
rizzocandrizzolspinto$HOME/.local/bin
You can override the managed install root with RIZZO_HOME and the symlink directory with RIZZO_BIN_DIR.
Windows does not have a raw installer yet; use the release archives directly for now.
- Build:
opam exec -- dune build - Run compiler on one or more source files:
opam exec -- dune exec rizzoc ./examples/first.rizz
By default the compiler is quiet and only emits output.c. To inspect the intermediate ASTs while compiling, pass --print-ast to rizzoc.
The compiler translates Rizzo source files (.rizz) to C (output.c), and triggers a C compile with either gcc or clang to produce an executable.
All you need to do is invoke the compiler on your Rizzo source file(s), and it will handle the rest:
rizzoc [more-files.rizz ...] <entrypoint.rizz>For help run:
rizzoc --helpFile-based compilation and editor analysis now prepend a compiler-owned stdlib before user files are typechecked. The default stdlib lives in src/stdlib in the repository and installs next to the compiler under lib/rizzoc/stdlib. That means user .rizz files can use combinators such as map, zip, scan, and filter_map without copy-pasting their definitions first.
You can replace the default stdlib with --overwrite-stdpath <path>, where <path> can point to either a single .rizz file or a stdlib directory. You can also prepend extra files or directories with repeated -I <path> flags.
Multiple input files are compiled left-to-right after that implicit stdlib and any -I includes. Later files can refer to earlier files, but the reverse order is not supported yet.
Open any .rizz file and click the ▶ Run button in the editor title bar, or run the command Rizzo: Run Current File from the Command Palette.
The extension will:
- Save the file
- Compile it with
rizzoc(auto-detected from local build oropam exec -- dune exec rizzoc --) - Compile the generated
output.cwithgcc(or the C compiler set inrizzoLsp.compiler.cc) - Run the resulting binary – all in an integrated terminal
Configuration (settings.json):
| Setting | Default | Description |
|---|---|---|
rizzoLsp.compiler.command |
(auto) | Path to rizzoc binary. Leave empty to auto-detect. |
rizzoLsp.compiler.cc |
gcc |
C compiler command (gcc or clang). |
The Extension can be installed from the GitHub releases page, or built locally from the vscode-rizzo-lsp folder.
The LSP (
rizzolsp) is installed alongside the compiler, so make sure to have the compiler in your PATH or configure the extension to find it.
The extension will automatically start the LSP server when you open a .rizz file, but you can also run it manually for development or debugging purposes.
To run the LSP server, use the command:
- LSP server:
opam exec -- dune exec rizzolsp
The VS Code extension is located in the vscode-rizzo-lsp folder.
It can easily be installed with
npm run ext:install:deps
npm run ext:installThis installs the dependencies, builds the project and then installs the extension locally.
For development you might want to run the extension in a debug session, which allows you to set breakpoints and inspect variables in the LSP server code. To do this, you can run the debug configuration Run Rizzo Extension (repo root) from the repository root. This will launch a new VS Code window with the extension loaded. You can then open any .rizz file to see diagnostics, symbols, definitions, hover information, and completion suggestions provided by the LSP server.
- Run debug config:
Run Rizzo Extension (repo root). - Then open any
.rizzfile to get diagnostics, symbols, definition, hover, and completions (Ctrl+Spaceand typing-triggered suggestions).
- The extension contributes language configuration through
package.json, so*.rizzfiles are automatically recognized. - For true "just open folder and it works" without running a debug session, run the task
rizzo: install local extensiononce (requirescodeCLI in PATH), then reopen VS Code. - The C runtime headers (
src/runtime/*.h) are bundled into the VSIX automatically by thevscode:prepublishstep vianpm run copy:runtime.
The extension provides several commands accessible via the Command Palette (Ctrl+Shift+P):
| Command | Description |
|---|---|
Rizzo: Run Current File |
Compile and run the active .rizz file |
Rizzo: Check LSP Health |
Show LSP server status and configuration |
Rizzo: Restart LSP Server |
Restart the language server |
A status bar item shows the current LSP state (starting/running/stopped).
Run the test suite with:
npm run test
# or
opam exec -- dune testTests cover parsing, type checking, transformations, and the language service.
- Thesis document: See
pdf/for the LaTeX thesis document - Development notes: See
notes/for design decisions and progress - Syntax reference: See
notes/syntax.mdfor language syntax overview