Class SyntaxError

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    EOFError

    public class SyntaxError
    extends java.lang.RuntimeException
    Exception thrown when a syntax error is encountered during parsing.

    SyntaxError is thrown by the Parser when it encounters invalid syntax in the input line. It provides information about the location of the error (line and column) and a descriptive message about the nature of the error.

    This exception is typically caught by the LineReader, which may then display an error message to the user or take other appropriate action based on the parsing context.

    The EOFError subclass is used specifically for incomplete input errors, such as unclosed quotes or brackets, which might be completed by additional input.

    See Also:
    Parser, EOFError, Parser.ParseContext, Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      SyntaxError​(int line, int column, java.lang.String message)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int column()
      Returns the column position where the syntax error occurred.
      int line()
      Returns the line number where the syntax error occurred.
      • 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

      • SyntaxError

        public SyntaxError​(int line,
                           int column,
                           java.lang.String message)
    • Method Detail

      • column

        public int column()
        Returns the column position where the syntax error occurred.
        Returns:
        the column position (0-based index)
      • line

        public int line()
        Returns the line number where the syntax error occurred.
        Returns:
        the line number (0-based index)