Class ScriptREPL


  • public class ScriptREPL
    extends Object
    A REPL for SciJava script engines, which allows dynamic language switching.
    Author:
    Curtis Rueden
    • Method Detail

      • getInterpreter

        public ScriptInterpreter getInterpreter()
        Gets the script interpreter for the currently active language.
      • loop

        public void loop()
                  throws IOException
        Starts a Read-Eval-Print-Loop from the standard input stream, returning when the loop terminates.
        Throws:
        IOException
      • loop

        public void loop​(InputStream in)
                  throws IOException
        Starts a Read-Eval-Print-Loop from the given input stream, returning when the loop terminates.
        Parameters:
        in - Input stream from which commands are read.
        Throws:
        IOException
      • loop

        public void loop​(Supplier<?> in)
        Starts a Read-Eval-Print-Loop from the given source, returning when the loop terminates.
        Parameters:
        in - Source from which commands are read.
      • initialize

        public void initialize()
        Outputs a greeting, and sets up the initial language and variables of the REPL.
      • initialize

        public void initialize​(boolean verbose)
        Sets up the initial language and variables of the REPL.
        Parameters:
        verbose - Whether to output an initial greeting.
      • prompt

        public void prompt()
        Outputs the prompt.
      • evaluate

        public boolean evaluate​(String line)
        Evaluates the line, including handling of special colon-prefixed REPL commands.
        Parameters:
        line - The line to evaluate.
        Returns:
        False iff the REPL should exit.
      • help

        public void help()
        Prints a usage guide.
      • vars

        public void vars()
        Lists variables in the script context.
      • lang

        public void lang​(String langName)
        Creates a new ScriptInterpreter to interpret statements, preserving existing variables from the previous interpreter.
        Parameters:
        langName - The script language of the new interpreter.
        Throws:
        IllegalArgumentException - if the requested language is not available.
      • lang

        public void lang​(ScriptLanguage language)
        Creates a new ScriptInterpreter to interpret statements, preserving existing variables from the previous interpreter.
        Parameters:
        language - The script language of the new interpreter.
      • langs

        public void langs()
      • debug

        public void debug()