Documentation Index
Fetch the complete documentation index at: https://mintlify.com/elfrask/cls/llms.txt
Use this file to discover all available pages before exploring further.
clxr is the lightweight CLS runtime executor. Unlike clx, which ships the full development toolchain (type checker, LSP server, package manager, REPL, and more), clxr contains only what is needed to run a CLS program: the lexer, parser, tree-walker interpreter, and the core standard library. It is designed for deployment scenarios where you want to ship a .clsapp package or a standalone .clsx script and execute it on a target machine without installing the development tools.
Usage
clxr accepts exactly one positional argument: the path to either a CLS source file (.clsx) or a packaged application (.clsapp). Any additional arguments after the file path are collected and forwarded to the program’s main(args: String[]) function.
Execution Modes
Running a .clsx Source File
When the argument ends in .clsx, clxr reads the file from disk and immediately compiles and executes it through the full pipeline:
Lex
The source text is tokenized by the
Lexer. Syntax errors are reported with source context and clxr exits with code 1.Execute module body
The interpreter walks the AST and evaluates all top-level statements (variable declarations, function definitions, etc.).
Running a .clsapp Packaged Application
A .clsapp file is a ZIP archive produced by clx build. When the argument ends in .clsapp, clxr mounts the archive through the Virtual File System (VFS) before executing:
Open the ZIP
clxr opens the .clsapp archive and registers its contents under the res:// VFS protocol, making all bundled resources accessible at runtime via res://filename.Read manifest.json
clxr reads manifest.json from the archive to determine the entry point file name. If no manifest is present, it defaults to source.clsx.Extract and compile the entry point
The entry source file is read from the ZIP, then lexed and parsed in memory — no temporary files are created on disk.
manifest.json inside the archive follows this structure:
Resources bundled inside a
.clsapp (images, config files, data) are accessible at res:// paths. However, clxr does not expose the fs module, so reading from the host filesystem is not available. Use res:// for embedded assets.Available Modules
clxr initialises the interpreter with ModuleResolver::with_core_stdlib(), which includes only the cross-platform core modules. The desktop-only node modules (fs, http, Lib) are not registered.
| Module | Available in clxr | Notes |
|---|---|---|
math | ✅ | math.sqrt, math.pow, math.random, etc. |
json | ✅ | json.parse, json.stringify |
async | ✅ | async/await support |
fs | ❌ | Desktop-only — use clx run instead |
http | ❌ | Desktop-only — use clx run instead |
Lib | ❌ | Desktop-only .clslib loader — use clx run instead |
print, input, len, type, int, float, str, bool, now, exit, sleep, throw) are always available without any import.
Error Reporting
When a runtime error occurs,clxr builds a full call stack traceback and prints it before exiting with code 1. Each frame in the traceback includes:
- A frame number
- The function name and source file
- The offending source line with a
^caret marking the exact position
Comparison: clx vs clxr
| Feature | clx | clxr |
|---|---|---|
| Primary purpose | Development & authoring | Deployment & execution |
Core stdlib (math, json, async) | ✅ | ✅ |
Desktop modules (fs, http, Lib) | ✅ | ❌ |
Type checker (clx check) | ✅ | ❌ |
REPL (clx repl) | ✅ | ❌ |
LSP server (clx lsp) | ✅ | ❌ |
Project scaffolding (clx new) | ✅ | ❌ |
Package manager (clx add/install) | ✅ | ❌ |
Build to .clsapp (clx build) | ✅ | ❌ |
Run .clsx directly | ✅ | ✅ |
Run .clsapp packages | ❌ | ✅ |
| Full call stack traceback | ✅ | ✅ |
| Binary size | Full toolchain | Lightweight |
Exit Codes
| Code | Meaning |
|---|---|
0 | main() returned 0 — successful execution |
1 | Syntax error, parse error, runtime error, or the file could not be opened |
main function, so you can signal specific outcomes to the calling shell:
clx build
Package your project into a .clsapp file
clx Reference
Full development CLI reference