Class EOFError

All Implemented Interfaces:
Serializable

public class EOFError extends SyntaxError
Exception thrown when parsing is incomplete due to unexpected end of input.

EOFError is a specialized type of SyntaxError that indicates the input is incomplete rather than invalid. This typically occurs when the user has entered an incomplete construct, such as an unclosed quote, parenthesis, or bracket.

This exception provides additional information about what is missing to complete the input, which can be used by the LineReader to provide appropriate feedback to the user, such as a continuation prompt that indicates what needs to be closed.

The name "EOFError" refers to "End Of File Error", indicating that the parser reached the end of the input before the syntax was complete.

See Also:
  • Constructor Details

    • EOFError

      public EOFError(int line, int column, String message)
    • EOFError

      public EOFError(int line, int column, String message, String missing)
    • EOFError

      public EOFError(int line, int column, String message, String missing, int openBrackets, String nextClosingBracket)
  • Method Details

    • getMissing

      public String getMissing()
      Returns the string that is missing to complete the input.

      This is typically a closing delimiter such as a quote, parenthesis, or bracket that would complete the current syntactic construct.

      Returns:
      the missing string, or null if not applicable
    • getOpenBrackets

      public int getOpenBrackets()
      Returns the number of unclosed brackets in the input.

      This count can be used to determine how many closing brackets are needed to complete the input.

      Returns:
      the number of unclosed brackets
    • getNextClosingBracket

      public String getNextClosingBracket()
      Returns the next closing bracket that is expected.

      This indicates the specific type of bracket (e.g., ')', ']', or '}') that is expected next to continue closing the open brackets.

      Returns:
      the next expected closing bracket, or null if not applicable