public class ScriptREPL extends Object
Constructor and Description |
---|
ScriptREPL(Context context) |
ScriptREPL(Context context,
OutputStream out) |
ScriptREPL(Context context,
String language) |
ScriptREPL(Context context,
String language,
OutputStream out) |
Modifier and Type | Method and Description |
---|---|
void |
debug() |
boolean |
evaluate(String line)
Evaluates the line, including handling of special colon-prefixed REPL
commands.
|
List<ScriptLanguage> |
getInterpretedLanguages()
Gets the list of languages compatible with the REPL.
|
ScriptInterpreter |
getInterpreter()
Gets the script interpreter for the currently active language.
|
void |
help()
Prints a usage guide.
|
void |
initialize()
Outputs a greeting, and sets up the initial language and variables of the
REPL.
|
void |
initialize(boolean verbose)
Sets up the initial language and variables of the REPL.
|
void |
lang(ScriptLanguage language)
Creates a new
ScriptInterpreter to interpret statements, preserving
existing variables from the previous interpreter. |
void |
lang(String langName)
Creates a new
ScriptInterpreter to interpret statements, preserving
existing variables from the previous interpreter. |
void |
langs() |
void |
loop()
Starts a Read-Eval-Print-Loop from the standard input stream, returning
when the loop terminates.
|
void |
loop(InputStream in)
Starts a Read-Eval-Print-Loop from the given input stream, returning when
the loop terminates.
|
static void |
main(String... args) |
void |
prompt()
Outputs the prompt.
|
void |
vars()
Lists variables in the script context.
|
public ScriptREPL(Context context)
public ScriptREPL(Context context, OutputStream out)
public ScriptREPL(Context context, String language, OutputStream out)
public List<ScriptLanguage> getInterpretedLanguages()
This list will match those given by ScriptService.getLanguages()
,
but filtered to exclude any who report true
for
ScriptLanguage.isCompiledLanguage()
.
public ScriptInterpreter getInterpreter()
public void loop() throws IOException
IOException
public void loop(InputStream in) throws IOException
in
- Input stream from which commands are read.IOException
public void initialize()
public void initialize(boolean verbose)
verbose
- Whether to output an initial greeting.public void prompt()
public boolean evaluate(String line)
line
- The line to evaluate.public void help()
public void vars()
public void lang(String langName)
ScriptInterpreter
to interpret statements, preserving
existing variables from the previous interpreter.langName
- The script language of the new interpreter.IllegalArgumentException
- if the requested language is not
available.public void lang(ScriptLanguage language)
ScriptInterpreter
to interpret statements, preserving
existing variables from the previous interpreter.language
- The script language of the new interpreter.public void langs()
public void debug()
Copyright © 2015–2022 SciJava. All rights reserved.