Class LogicalTypesParserFactory

java.lang.Object
io.confluent.kafka.schemaregistry.type.logical.LogicalTypesParserFactory

public final class LogicalTypesParserFactory extends Object
Centralized factory for building lexer + parser instances configured with a strict error listener that throws ValidationException on the first syntax error.

ANTLR's default ConsoleErrorListener writes errors to stderr and lets the parser silently recover by inserting/deleting tokens. For a DDL grammar — and especially for CHECK (...) sub-expressions where recovery can leak past the closing paren and corrupt subsequent fields — silent recovery produces partially-formed parse trees that translate to confusing downstream errors (or worse, to incorrect CEL).

This factory replaces the default listener with one that aborts on the first syntax error, surfacing a single clear message with line and column. All callers (production and tests) should route through parse(String) so the strict behavior is uniform.

  • Method Details

    • parse

      public static LogicalTypesParser.ScriptContext parse(String input)
      Parse a DDL script and return its root script parse tree. Throws ValidationException with line/column info on the first lex or parse error encountered, or when the script nests types too deeply to parse without overflowing the recursive-descent stack.
    • newParser

      public static LogicalTypesParser newParser(String input)
      Build a LogicalTypesParser with the strict error listener wired in. Use this when you need direct access to specific entry rules other than script() (e.g., partial parses for tooling).