Class Repl
java.lang.Object
ch.turic.Repl
A REPL (Read-Eval-Print Loop) interpreter that executes code incrementally.
This interpreter can process and execute small pieces of code sequentially,
maintaining state between executions.
The interpreter manages its own context and provides support for code completion
through the completions() method. It handles lexical analysis, program
analysis, and execution of the provided code.
Thread Safety: This class is not thread-safe and should not be used in a multi-threaded environment. Each instance maintains mutable state that could be corrupted by concurrent access.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionExecutes the provided source code and returns the result of the execution.
-
Field Details
-
ctx
public ch.turic.memory.Context ctx -
lexes
public ch.turic.analyzer.LexList lexes
-
-
Constructor Details
-
Repl
public Repl()
-
-
Method Details
-
completions
-
execute
Executes the provided source code and returns the result of the execution.- Parameters:
source- The source code to execute as a string- Returns:
- The result of executing the code, which can be any Object
- Throws:
BadSyntax- if the provided code contains syntax errorsExecutionException- if an error occurs during code execution
-