Class LangParseException

All Implemented Interfaces:
Serializable

public final class LangParseException extends ScriptParseException
Thrown when the ScriptParser encounters a syntax error in a .relix source file.

The exception message is the human-readable description of the problem followed by its source location, stated once as (line N, col M) — the message is often shown on its own, and without the position it does not say where the error is. Use ScriptParseException.line() and ScriptParseException.column() (inherited from ScriptParseException) for programmatic access to the same position; suffix(int, int) is the exact text appended, for a caller that already reports the position and wants the message without it.

This is the .relix text grammar's specialisation of the core-level ScriptParseException — the type the engine's "where does a Script come from" seam declares. Callers that do not care which frontend failed should catch the supertype.

It is a RuntimeException so that the parser API does not require checked-exception handling at every call site.

See Also:
  • Constructor Details

    • LangParseException

      public LangParseException(String message, int line, int column)
      Constructs a parse exception with a descriptive message.
      Parameters:
      message - a human-readable description of the problem
      line - 1-based source line of the offending token
      column - 1-based source column of the offending token
    • LangParseException

      public LangParseException(String message, LangToken token)
      Constructs a parse exception from the offending token.
      Parameters:
      message - human-readable problem description
      token - the token at which parsing failed
  • Method Details

    • suffix

      public static String suffix(int line, int column)
      Returns the position text the message ends with, " (line N, col M)".
      Parameters:
      line - 1-based source line
      column - 1-based source column
      Returns:
      the suffix a message at that position carries
    • description

      public String description()
      Returns the message without the suffix(int, int) it ends with.
      Overrides:
      description in class ScriptParseException
      Returns:
      the description of the problem, without its position