Class EOFError

  • All Implemented Interfaces:
    java.io.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:
    SyntaxError, Parser, Parser.ParseContext.SECONDARY_PROMPT, Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      EOFError​(int line, int column, java.lang.String message)  
      EOFError​(int line, int column, java.lang.String message, java.lang.String missing)  
      EOFError​(int line, int column, java.lang.String message, java.lang.String missing, int openBrackets, java.lang.String nextClosingBracket)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getMissing()
      Returns the string that is missing to complete the input.
      java.lang.String getNextClosingBracket()
      Returns the next closing bracket that is expected.
      int getOpenBrackets()
      Returns the number of unclosed brackets in the input.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • EOFError

        public EOFError​(int line,
                        int column,
                        java.lang.String message)
      • EOFError

        public EOFError​(int line,
                        int column,
                        java.lang.String message,
                        java.lang.String missing)
      • EOFError

        public EOFError​(int line,
                        int column,
                        java.lang.String message,
                        java.lang.String missing,
                        int openBrackets,
                        java.lang.String nextClosingBracket)
    • Method Detail

      • getMissing

        public java.lang.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 java.lang.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