Class ParserAbstract<S extends IDatabase>
java.lang.Object
org.pgcodekeeper.core.database.base.parser.statement.ParserAbstract<S>
- Direct Known Subclasses:
ChParserAbstract,MsParserAbstract,PgParserAbstract
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 TypeMethodDescriptionstatic StringgetFullCtxText(org.antlr.v4.runtime.ParserRuleContext ctx) Extracts raw text from contextstatic StringgetFullCtxText(org.antlr.v4.runtime.ParserRuleContext start, org.antlr.v4.runtime.ParserRuleContext end) Extracts raw text between two parse tree contexts.static StringgetFullCtxText(org.antlr.v4.runtime.Token start, org.antlr.v4.runtime.Token end) Extracts raw text between two tokens.<T extends IStatement,R extends IStatement>
RgetSafe(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>
RgetSafe(BiFunction<T, String, R> getter, T container, org.antlr.v4.runtime.ParserRuleContext ctx) Safely retrieves a database statement with validation.static ArgModeparseArgMode(org.antlr.v4.runtime.ParserRuleContext mode) Parses an argument mode from a parse tree context.abstract voidParses a database object from the current context.voidparseObject(String fileName, ParserListenerMode mode, org.antlr.v4.runtime.ParserRuleContext ctx) Parses a database object from the given parse tree context.
-
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 parsedmode- 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
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 contextend- 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 tokenend- the ending token- Returns:
- the text between the tokens
-
parseArgMode
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 typeR- the child statement type- Parameters:
getter- the getter function to retrieve the childcontainer- the containing statementctx- 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 typeR- the child statement type- Parameters:
getter- the getter function to retrieve the childcontainer- the containing statementname- the name of the statement to finderrToken- the token for error reporting- Returns:
- the found statement
- Throws:
UnresolvedReferenceException- if statement not found
-