CLI and REPL
Use PriyoScript from terminal effectively, and know when to choose CLI vs REPL.
Theory
CLI (Command Line Interface) and REPL (Read-Eval-Print Loop) serve different development modes in PriyoScript. CLI is file-oriented and deterministic, making it ideal for repeatable execution, project workflows, and CI automation. REPL is interactive and stateful, making it ideal for experimentation, quick checks, and iterative learning. PriyoScript supports both flows with common diagnostics tooling (-errors, -explain) and runtime tracing (-trace) so users can move from exploration to production without changing language semantics.
Quick choice rule
Use CLI for real scripts and repeatable runs. Use REPL for rapid experiments and learning loops.
Core command summary
CLI essentials
| Command | Mode | Purpose |
|---|---|---|
monalisa <file.priyo> | CLI | Run a PriyoScript file |
monalisa -repl | REPL | Start interactive shell |
monalisa -trace <file> | CLI | Run with opcode-level trace |
Help and diagnostics
| Command | Mode | Purpose |
|---|---|---|
monalisa -h | CLI | Help and command list (alias) |
monalisa -help | CLI | Help and command list |
monalisa -v | CLI | Version (alias) |
monalisa -version | CLI | Version |
monalisa -s | CLI | Syntax quick help (alias) |
monalisa -syntax | CLI | Syntax quick help |
monalisa -e | CLI | Error code list (alias) |
monalisa -errors | CLI | List error codes |
monalisa -x <CODE> | CLI | Explain error code (alias) |
monalisa -explain <CODE> | CLI | Explain specific error code |
Trace helpers and filters
| Command | Mode | Purpose |
|---|---|---|
monalisa -th | CLI | Trace help (alias) |
monalisa -trace-help | CLI | Show trace filtering options |
monalisa -trace-format json | CLI | JSON trace lines for tooling |
monalisa -trace-op ADD,SUB | CLI | Trace only specific opcodes |
monalisa -trace-op-exclude HALT | CLI | Exclude opcodes from trace |
monalisa -trace-file modules | CLI | Trace only matching file path |
monalisa -trace-label label | CLI | Trace only matching breakpoint labels |
monalisa -trace-type trace,break | CLI | Trace event types (trace, break, all) |
monalisa -trace-frame <name> | CLI | Trace only matching frame name |
monalisa -trace-stack-min 2 | CLI | Trace only when stack depth >= N |
monalisa -trace-stack-max 6 | CLI | Trace only when stack depth < N |
REPL command summary
| Command | Purpose |
|---|---|
.help | Show REPL command list |
.clear | Clear current multiline buffer |
.editor | Enter editor mode (edit> prompt) |
.run | Execute editor buffer (editor mode only) |
.cancel | Discard editor buffer (editor mode only) |
.reset | Reset runtime state and module cache |
.load <file> | Execute file in current REPL context |
.reload [file] | Reload last loaded file or explicit file |
.history | Show executed snippets history |
.save <file> | Save snippet history to file |
.env | Inspect current bindings with kind/type/value preview |
.type <expr> | Evaluate expression and print inferred type + value |
.exit | Exit REPL |
Program Examples
Example 1: Show Help
monalisa -hOutput (short):
PriyoScript CLI help...Explanation: verifies installation and available command options.
Example 2: Run a File
monalisa hello.priyoOutput:
Hello, PriyoScript!Explanation: standard production execution path for .priyo scripts.
Example 3: Start REPL
monalisa -replOutput (short):
Hey, this is PriyoScript REPL...
priyo>Explanation: opens interactive shell with persistent in-session state.
Example 4: REPL Session
priyo> priyoKeep x = 12
priyo> priyoTell(x * 2)
24Output:
24Explanation: second line uses variable from previous line because REPL keeps environment alive.
Example 5: Error Discovery Commands
monalisa -errors
monalisa -explain PSYN-002Output (short):
List of error codes...
Explanation for PSYN-002...Explanation: helps users map runtime/syntax failures to exact docs and fixes.
Example 6: Trace Mode
monalisa -trace examples/basics/for-loop.priyoOutput (short):
[TRACE #1] examples/basics/for-loop.priyo <main> ip=0 op=...
[TRACE #2] examples/basics/for-loop.priyo <main> ip=1 op=...
...Explanation: shows VM instruction-by-instruction flow for deep debugging.
Filter examples:
monalisa -trace -trace-op CALL_METHOD,RETURN examples/basics/for-loop.priyo
monalisa -trace -trace-format json -trace-frame "<main>" examples/basics/for-loop.priyoExample 7: Breakpoint-Style Hook
monalisa {
priyoKeep total = 10
prakritiThink("after-total")
priyoTell(total)
}Output (short):
[BREAK #1] label="after-total"
10Explanation: prakritiThink(...) marks checkpoints inside trace output.
Example 8: Useful REPL commands
priyo> .help
priyo> .load examples/basics/main.priyo
priyo> .editor
edit> priyoKeep n = 10
edit> priyoTell(n * 5)
edit> .run
priyo> .reload
priyo> .env
priyo> .type 10 + 32
priyo> .history
priyo> .reset
priyo> .exitOutput (short):
REPL commands list...
Loaded: examples/basics/main.priyo
Editor mode enabled...
50
Reloaded: examples/basics/main.priyo
Bindings:
type: number
value: 42
REPL history:
Runtime state reset.Explanation: supports structured iteration in interactive mode.
Example 9: REPL persistence file
PriyoScript REPL saves session history automatically to:
.priyo_repl_history.jsonYou can keep this file for continuity or remove it to start with clean persisted history.
Execution Flow
CLI flow:
- You pass file path.
- CLI loads full source.
- Parser/compiler/VM run once.
- Program exits with output or error.
- Each run starts with a clean runtime process.
REPL flow:
- You type one line/snippet.
- REPL evaluates it immediately.
- State stays in memory for next line.
- History is persisted to
.priyo_repl_history.jsonon exit. - You repeat until
.exit. .resetclears runtime state and module cache for clean retry.- Optional editor mode (
.editor) lets you draft multi-line snippets before running.run.
Trace flow:
- You run with
-trace(optional-trace-*filters). - VM emits execution lines for each instruction.
- If
prakritiThink(...)exists, VM prints a breakpoint marker. - On runtime error, PriyoScript includes source-level stack context.
- Use trace output to isolate exact failing sequence.
Comparison With Other Languages
Node.js CLI/REPL:
node file.jsnode(interactive REPL)
Python CLI/REPL:
python script.pypython(interactive shell)
Java:
- Compile + run model (
javac,java) and optional JShell for REPL-like experience.
C:
- Compile then execute binary (
gcc,./a.out), no default built-in REPL.
PriyoScript:
monalisa file.priyomonalisa -replmonalisa -trace file.priyo
Difference summary:
- PriyoScript behaves like modern interpreted workflows (Node/Python) with dedicated language diagnostics.
- PriyoScript adds built-in error-code explanation flow (
-errorsand-explain) for beginner-friendly debugging.
Inspiration and Official References
- Node.js CLI and REPL concepts:
https://nodejs.org/api/cli.html
https://nodejs.org/api/repl.html - Python interpreter and command line:
https://docs.python.org/3/tutorial/interpreter.html - Java JShell:
https://docs.oracle.com/en/java/javase/21/jshell/introduction-jshell.html - C compile-run workflow (GCC docs):
https://gcc.gnu.org/onlinedocs/
Limitations
REPL is ideal for learning and prototyping, but long programs should be stored in .priyo files
and executed via CLI.
Debug Tip
Start with normal run. If behavior is unclear, rerun with -trace and place
prakritiThink("checkpoint") at important points.
Last updated on