Class ParserAbstract<S extends IDatabase>

java.lang.Object
org.pgcodekeeper.core.database.base.parser.statement.ParserAbstract<S>
Direct Known Subclasses:
ChParserAbstract, MsParserAbstract, PgParserAbstract

public abstract class ParserAbstract<S extends IDatabase> extends Object
Abstract base class for database object parsers that provides common parsing functionality and utilities for working with ANTLR-generated parse trees.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    getFullCtxText(org.antlr.v4.runtime.ParserRuleContext ctx)
    Extracts raw text from context
    static String
    getFullCtxText(org.antlr.v4.runtime.ParserRuleContext start, org.antlr.v4.runtime.ParserRuleContext end)
    Extracts raw text between two parse tree contexts.
    static String
    getFullCtxText(org.antlr.v4.runtime.Token start, org.antlr.v4.runtime.Token end)
    Extracts raw text between two tokens.
    <T extends IStatement, R extends IStatement>
    R
    getSafe(BiFunction<T,String,R> getter, T container, String name, org.antlr.v4.runtime.Token errToken)
    Safely retrieves a database statement by name with validation.
    <T extends IStatement, R extends IStatement>
    R
    getSafe(BiFunction<T,String,R> getter, T container, org.antlr.v4.runtime.ParserRuleContext ctx)
    Safely retrieves a database statement with validation.
    static ArgMode
    parseArgMode(org.antlr.v4.runtime.ParserRuleContext mode)
    Parses an argument mode from a parse tree context.
    abstract void
    Parses a database object from the current context.
    void
    parseObject(String fileName, ParserListenerMode mode, org.antlr.v4.runtime.ParserRuleContext ctx)
    Parses a database object from the given parse tree context.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • parseObject

      public void parseObject(String fileName, ParserListenerMode mode, org.antlr.v4.runtime.ParserRuleContext ctx)
      Parses a database object from the given parse tree context.
      Parameters:
      fileName - the source file being parsed
      mode - the parsing mode (REF, SCRIPT, etc.)
      ctx - the ANTLR parse tree context to parse from
    • parseObject

      public abstract void parseObject()
      Parses a database object from the current context. Must be implemented by concrete subclasses to handle specific object types.
    • getFullCtxText

      public static String getFullCtxText(org.antlr.v4.runtime.ParserRuleContext ctx)
      Extracts raw text from context
      Parameters:
      ctx - context
      Returns:
      raw string
    • getFullCtxText

      public static String getFullCtxText(org.antlr.v4.runtime.ParserRuleContext start, org.antlr.v4.runtime.ParserRuleContext end)
      Extracts raw text between two parse tree contexts.
      Parameters:
      start - the starting context
      end - the ending context
      Returns:
      the text between the contexts
    • getFullCtxText

      public static String getFullCtxText(org.antlr.v4.runtime.Token start, org.antlr.v4.runtime.Token end)
      Extracts raw text between two tokens.
      Parameters:
      start - the starting token
      end - the ending token
      Returns:
      the text between the tokens
    • parseArgMode

      public static ArgMode parseArgMode(org.antlr.v4.runtime.ParserRuleContext mode)
      Parses an argument mode from a parse tree context.
      Parameters:
      mode - the mode parse tree context
      Returns:
      the parsed ArgMode
    • getSafe

      public <T extends IStatement, R extends IStatement> R getSafe(BiFunction<T,String,R> getter, T container, org.antlr.v4.runtime.ParserRuleContext ctx)
      Safely retrieves a database statement with validation.

      Note: Always returns null if parser is in ref mode.

      Type Parameters:
      T - the container statement type
      R - the child statement type
      Parameters:
      getter - the getter function to retrieve the child
      container - the containing statement
      ctx - the parse tree context
      Returns:
      the found statement or null if parser is in ref mode
      Throws:
      UnresolvedReferenceException - if statement not found
    • getSafe

      public <T extends IStatement, R extends IStatement> R getSafe(BiFunction<T,String,R> getter, T container, String name, org.antlr.v4.runtime.Token errToken)
      Safely retrieves a database statement by name with validation.

      Note: Always returns null if parser is in ref mode.

      Type Parameters:
      T - the container statement type
      R - the child statement type
      Parameters:
      getter - the getter function to retrieve the child
      container - the containing statement
      name - the name of the statement to find
      errToken - the token for error reporting
      Returns:
      the found statement
      Throws:
      UnresolvedReferenceException - if statement not found