Using the Mech REPL

Starting the REPL

Commands

:help (:h)

:quit (:q)

:symbols (:s)

:plan (:p)

:whos (:w)

:clc (:c)

:clear

:load

:ls [PATH]

:cd PATH

:step [N]

Using the Mech REPL

The Mech Read-Eval-Print Loop (REPL) provides an interactive environment for executing Mech commands, inspecting symbols, and debugging programs. Below are the available REPL commands.

Starting the REPL

To start the REPL, run:

mech

You can load a script into the REPL by running with the --repl option:

mech --repl my_script.mec

Once inside, you can enter commands prefixed with :, otherwise the REPL will interpret the input as a Mech expression and evaluate it, and print the result and the associated type.

Commands

:help (:h)

Displays this help message with a list of available commands.

:help

:quit (:q)

Exits the REPL.

:quit

:symbols (:s)

Searches for symbols in the current session. You can provide an optional search pattern to filter results.

:s
:s velocity

:plan (:p)

Displays the execution plan.

:plan

:whos (:w)

Searches the symbol directory. Optionally, provide a search pattern to filter results.

:whos
:whos position

:clc (:c)

Clears the screen, resets the cursor position.

:clc

:clear

Clears the interpreter state. If a target variable is provided, only that variable is cleared.

:clear
:clear x

:load

Loads and executes the supplied a Mech file(s) into the session.

:load my_script.mec
:load my_script.mec my_other_script.mec
:load my_directory

:ls [PATH]

Lists contents of working directory. Optionally, provide a target path.

>: :ls
>: :ls /my/directory

:cd PATH

Changes the current working directory.

>: :cd /my/directory

:step [N]

Iterates the execution plan by the specified number of steps. If N is not provided, defaults to 1 step.

>: ~x := 10
>: x += 1
>: :step 10
>: x == 21  -- true