REPL
class REPL
@brief Interactive Read-Eval-Print-Loop for WAL++
Provides a user-friendly interactive shell for WAL expressions with: - Command history and navigation - Multi-line expression support - Pretty-printed output - Built-in help system - Error recovery
Functions
| Name | Description |
|---|---|
| REPL | @brief Create REPL with existing Wal instance |
| run | @brief Start interactive REPL loop Runs until user types (quit) or EOF Return : Exit code (0 = normal, non-zero = error) |
| execute | @brief Execute single expression expr : The expression to evaluate echo_result : Print the value of the last form. True at an interactive prompt, where that is the answer. False when running a script, because upstream WAL prints nothing there, and an extra line on stdout corrupts the output of a script whose job is to write a report or a CSV. Return : true if execution succeeded |
| load_file | @brief Load and execute a file filename : Path to WAL program Return : true if successful |
| load_pipe | @brief Read and execute from a named pipe (FIFO) pipe_path : Path to the named pipe file Return : true if successful |
| read_from_stdin | @brief Read and execute from standard input Reads input from stdin until EOF and executes all input. |
| get_wal | @brief Get the WAL instance |
| stop | @brief Stop the REPL |
| get_history | @brief Get command history |
Function Details
REPL
explicit REPL(std::shared_ptr<Wal> wal = nullptr)
@brief Create REPL with existing Wal instance
execute
bool execute(const std::string& expr, bool echo_result = true)
@brief Execute single expression
-
expr - The expression to evaluate
-
echo_result - Print the value of the last form. True at an interactive prompt, where that is the answer. False when running a script, because upstream WAL prints nothing there, and an extra line on stdout corrupts the output of a script whose job is to write a report or a CSV.
- Return
- true if execution succeeded
get_history
const std::deque<std::string>& get_history() const
@brief Get command history
get_wal
std::shared_ptr<Wal> get_wal() const
@brief Get the WAL instance
load_file
bool load_file(const std::string& filename)
@brief Load and execute a file
-
filename - Path to WAL program
- Return
- true if successful
load_pipe
bool load_pipe(const std::string& pipe_path)
@brief Read and execute from a named pipe (FIFO)
-
pipe_path - Path to the named pipe file
- Return
- true if successful
read_from_stdin
bool read_from_stdin()
@brief Read and execute from standard input
Reads input from stdin until EOF and executes all input. Useful for piping simulation output directly.
- Return
- true if successful
run
int run()
@brief Start interactive REPL loop
Runs until user types (quit) or EOF
- Return
- Exit code (0 = normal, non-zero = error)
stop
void stop()
@brief Stop the REPL