Rayforce ← Back to home
GitHub

REPL Reference

Commands, profiling, keyboard shortcuts, and script mode for the Rayfall REPL.

Starting the REPL

The rayforce binary operates in three modes depending on how it is invoked:

# Interactive mode — full line editing, highlighting, completion
./rayforce

# Run a script file
./rayforce script.rfl

# Pipe mode — reads from stdin, no colour output
echo '(+ 1 2)' | ./rayforce

Interactive mode is detected automatically when stdin is a terminal. On startup the REPL prints a banner with the version, CPU, memory, and core count, then shows the prompt.

REPL Commands

All commands start with : and are handled before expression evaluation.

Command Alias Description
:?:helpDisplay the command list.
:t:timeitToggle profiling on/off.
:envList all defined variables with their types.
:clearClear the screen.
:q:quitExit the REPL.

You can also exit with \\, exit, or Ctrl-D on an empty line.

Profiling with :t

Toggle profiling with :t. When active, every evaluation emits a nested span tree showing where time was spent:

‣ :t
. Timeit is on.
‣ (+ 1 2)
3
╭ top-level
│ ✶  parse: 0.016 ms
│ ✶  eval: 0.004 ms
╰─┤ 0.025 ms
‣ :t
. Timeit is off.

Spans nest automatically. The DAG executor reports sub-spans for optimizer passes (type inference, fusion, predicate pushdown) and per-morsel execution when applicable. A progress bar appears for long-running operations.

For one-off measurement, use the timeit builtin which returns elapsed time in milliseconds:

(timeit (+ 1 2))
;; => 0.003

Multi-Line Input

The REPL auto-detects incomplete expressions by tracking unmatched brackets ( [ {. When the current input has unmatched openers, pressing Enter starts a continuation line instead of evaluating:

 (set double
    (fn [x]
      (* x 2)))
; evaluated after the closing ) balances all openers

The parser is aware of string literals and ; comments, so brackets inside strings or comments do not affect the count.

Keyboard Shortcuts

Key Action
Up / Ctrl-PPrevious history entry
Down / Ctrl-NNext history entry
Left / RightMove cursor (Right at end of line accepts ghost text)
Home / Ctrl-AMove to start of line
End / Ctrl-EMove to end of line
TabAutocomplete (cycles through candidates)
Ctrl-RReverse incremental history search
Ctrl-KKill from cursor to end of line
Ctrl-UKill entire line
Ctrl-WDelete word backward
DeleteDelete character at cursor
BackspaceDelete character before cursor
Ctrl-CCancel current input (interrupts running evaluation)
Ctrl-DExit on empty line, otherwise delete character at cursor
EscCancel tab-completion cycling

Syntax Highlighting

The REPL highlights input in real time as you type:

Highlighting is stripped from the final submitted text so it does not interfere with parsing.

Autocomplete

Press Tab to complete the current token. Candidates are drawn from four sources:

Press Tab repeatedly to cycle through matches. Press Esc to cancel.

Script Mode

Pass a .rfl file path to run it non-interactively:

./rayforce analysis.rfl

The entire file is read into memory and evaluated as a single Rayfall program via ray_eval_str(). The last expression's value is printed to stdout. If evaluation produces an error, it is printed to stderr and the process exits with code 1; otherwise the exit code is 0.

Pipe mode works the same way but reads from stdin line by line, evaluating each balanced expression as it arrives.