Class ReplSession

java.lang.Object
org.ek9lang.cli.ReplSession

public final class ReplSession extends Object
Manages the REPL session state including mode, source buffers, and defined symbols. Delegates buffer operations to SectionedBuffers and command handling to MetaCommandHandler.
  • Constructor Details

    • ReplSession

      public ReplSession(int initialErrorLevel)
      Create a new REPL session with the specified initial error level.
    • ReplSession

      public ReplSession()
      Create a new REPL session with default error level 0.
  • Method Details

    • processInput

      public ReplSession.InputResult processInput(String input)
      Process a line of user input.
    • saveUndoState

      public void saveUndoState()
      Save current buffer state for undo.
    • undo

      public boolean undo()
      Undo the last buffer modification.
    • clearTrackedSymbols

      public void clearTrackedSymbols()
      Clear tracked symbols (called when buffers are cleared).
    • setRunning

      public void setRunning(boolean running)
    • setErrorLevel

      public void setErrorLevel(int level)
    • setStrictMode

      public void setStrictMode(boolean strict)
    • assembleSource

      public String assembleSource()
      Assemble all buffers into valid EK9 source code.
    • assembleSourceWithLineNumbers

      public String assembleSourceWithLineNumbers()
      Get source with line numbers for display.
    • getBufferIndex

      public int getBufferIndex(int actualLineNumber)
      Get the buffer index for a given actual source line number.
    • getPrompt

      public String getPrompt()
    • getCurrentMode

      public ReplMode getCurrentMode()
    • getErrorLevel

      public int getErrorLevel()
    • isRunning

      public boolean isRunning()
    • isStrictMode

      public boolean isStrictMode()
    • enterContinuationMode

      public void enterContinuationMode()
    • exitContinuationMode

      public void exitContinuationMode()
    • getLastMessage

      public String getLastMessage()
    • getDefinedVariables

      public List<String> getDefinedVariables()
    • getDefinedFunctions

      public List<String> getDefinedFunctions()
    • getDefinedTypes

      public List<String> getDefinedTypes()
    • trackVariable

      public void trackVariable(String name)
      Track a variable that was defined in program mode.
    • getLastProgramLine

      public String getLastProgramLine()
      Get the last line added to the program buffer.
    • removeLastLine

      public void removeLastLine()
      Remove the last line added to the current mode's buffer.
    • getPendingFilename

      public String getPendingFilename()
      Get the pending filename for save/load operations.
    • loadFromVisitor

      public String loadFromVisitor(ReplSourceVisitor visitor)
      Load content from a parsed EK9 file via the visitor.