Class AbstractSqlParser
- All Implemented Interfaces:
SqlParser
- Direct Known Subclasses:
AnsiSqlParser,AthenaSqlParser,BigQuerySqlParser,CouchbaseSqlParser,DatabricksSqlParser,DaxSqlParser,Db2SqlParser,GaussDbSqlParser,GreenplumSqlParser,HanaSqlParser,HiveSqlParser,ImpalaSqlParser,InformixSqlParser,MdxSqlParser,MssqlSqlParser,MySqlSqlParser,NetezzaSqlParser,OdbcSqlParser,OpenEdgeSqlParser,OracleSqlParser,PostgreSqlParser,PrestoSqlParser,RedshiftSqlParser,SnowflakeSqlParser,SoqlSqlParser,SparkSqlParser,SparksqlSqlParser,SybaseSqlParser,TeradataSqlParser,VerticaSqlParser
This class implements the Template Method Pattern, defining the skeleton of the parsing algorithm while allowing subclasses to override specific steps. It provides default implementations for common operations and hooks for vendor-specific customization.
Design Pattern: Template Method
- Template Methods:
parse(ParserContext),tokenize(ParserContext) - Abstract Methods: Must be implemented by subclasses
- Hook Methods: Optional overrides for customization
Parsing Algorithm (Template Method):
- Get lexer (
getLexer(ParserContext)) - Tokenize SQL (
performTokenization(ParserContext, TCustomLexer)) - Process tokens (
processTokensBeforeParse(ParserContext, TSourceTokenList)) - Get parser(s) (
getParser(ParserContext, TSourceTokenList)) - Parse SQL (
#performParsing(ParserContext, TCustomParser, TCustomParser, TSourceTokenList)) - Semantic analysis (
performSemanticAnalysis(ParserContext, TStatementList))
Subclass Responsibilities:
public class OracleSqlParser extends AbstractSqlParser {
public OracleSqlParser() {
super(EDbVendor.dbvoracle);
this.delimiterChar = '/';
}
// Must implement abstract methods
protected TCustomLexer getLexer(ParserContext context) {
return new TLexerOracle();
}
protected TCustomParser getParser(ParserContext context, TSourceTokenList tokens) {
return new TParserOracleSql(tokens);
}
// ... other abstract methods
// Optionally override hook methods
protected void processTokensBeforeParse(ParserContext context, TSourceTokenList tokens) {
// Oracle-specific token processing
}
}
- Since:
- 3.2.0.0
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected charprotected Stack<gudusoft.gsqlparser.compiler.TFrame>Frame stack for scope management during parsing.protected gudusoft.gsqlparser.compiler.TContextGlobal context for semantic analysis.protected gudusoft.gsqlparser.compiler.TFrameGlobal frame pushed to frame stack during parsing.protected TCustomLexerThe lexer instance used for tokenization.protected ParserContextCurrent parser context for the ongoing parse operation.protected TSourceTokenListToken list container - created once in constructor, cleared before each parse.protected ISqlCmdsSQL command resolver for identifying statement types (SELECT, INSERT, etc.).protected TSQLEnvSQL environment for semantic analysis.protected TStatementListStatement list container - created once in constructor, cleared before each extraction.protected List<TSyntaxError>protected final EDbVendor -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractSqlParser(EDbVendor vendor) Construct parser for given database vendor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidHook method for vendor-specific post-processing after a statement is parsed.protected intattemptErrorRecovery(TCustomSqlStatement statement, int parseResult, boolean onlyNeedRawParseTree) Attempt error recovery for CREATE TABLE/INDEX statements with unsupported options.protected voidcopyErrorsFromStatement(TCustomSqlStatement statement) Copy error messages from a statement to the parser's error collection.protected voiddoAfterTokenize(TSourceTokenList tokens) Post-tokenization normalization.final TStatementListdoExtractRawStatements(ParserContext context, TSourceTokenList tokens) Extract raw statements without full parsing (public API).protected SqlParseResultextractRawStatements(ParserContext context, TSourceTokenList tokens, TCustomLexer lexer, long tokenizationTimeMs) Extract raw statements without full parsing.protected abstract voidCall vendor-specific raw statement extraction logic.protected TSourceTokenGet next source token from the lexer.Get the default delimiter string for this vendor.charGet the delimiter character for this vendor.intGet the count of syntax errors.protected abstract TCustomLexergetLexer(ParserContext context) Get the lexer for this vendor.protected abstract TCustomParsergetParser(ParserContext context, TSourceTokenList tokens) Get the main parser for this vendor.final SqlParseResultgetrawsqlstatements(ParserContext context) Template method for extracting raw statements without full parsing.protected TCustomParsergetSecondaryParser(ParserContext context, TSourceTokenList tokens) Get secondary parser (e.g., PL/SQL for Oracle).Get the syntax errors collected during parsing.Get the database vendor this parser handles.protected voidhandleStatementParsingException(TCustomSqlStatement stmt, int statementIndex, Exception ex) Handle exceptions that occur during individual statement parsing.protected voidInitialize global context and frame stack for statement parsing.protected booleanisDollarFunctionDelimiter(int tokencode, EDbVendor dbVendor) Check if a token is a dollar function delimiter ($$, $tag$, etc.) for PostgreSQL-family databases.protected voidonRawStatementComplete(ParserContext context, TCustomSqlStatement statement, TCustomParser mainParser, TCustomParser secondaryParser, TStatementList statementList, boolean isLastStatement, SqlParseResult.Builder builder) Hook method called when a raw statement is complete.protected voidHook for vendor-specific logic when a raw statement is completed.final SqlParseResultparse(ParserContext context) Template method for full parsing.protected voidperformInterpreter(ParserContext context, TStatementList statements) Perform interpretation/evaluation on parsed statements.protected abstract TStatementListperformParsing(ParserContext context, TCustomParser parser, TCustomParser secondaryParser, TSourceTokenList tokens, TStatementList rawStatements) Perform actual parsing with syntax checking.protected voidperformSemanticAnalysis(ParserContext context, TStatementList statements) Perform semantic analysis on parsed statements.protected TSourceTokenListperformTokenization(ParserContext context, TCustomLexer lexer) Perform tokenization using vendor-specific lexer.protected AbstractSqlParser.PreparedSqlReaderprepareSqlReader(ParserContext context) protected voidprocessTokensBeforeParse(ParserContext context, TSourceTokenList tokens) Process tokens before parsing (vendor-specific adjustments).protected voidprocessTokensInTokenTable(ParserContext context, TCustomLexer lexer, TSourceTokenList tokens) Process tokens using token table (vendor-specific token code adjustments).voidsetTokenHandle(ITokenHandle tokenHandle) Set an event handler which will be fired when a new source token is created by the lexer during tokenization.protected abstract voidSetup vendor-specific parsers for raw statement extraction.final SqlParseResulttokenize(ParserContext context) Template method for tokenization only (without full parsing).protected abstract voidCall vendor-specific tokenization logic.toString()protected StringConvert line breaks to Windows format.
-
Field Details
-
vendor
-
delimiterChar
-
defaultDelimiterStr
-
syntaxErrors
-
sourcetokenlist
Token list container - created once in constructor, cleared before each parse.This follows the component reuse pattern to avoid allocation overhead.
-
sqlstatements
Statement list container - created once in constructor, cleared before each extraction.This follows the component reuse pattern to avoid allocation overhead.
-
parserContext
Current parser context for the ongoing parse operation.Set at the beginning of each parse operation, contains input SQL and options.
-
sqlcmds
SQL command resolver for identifying statement types (SELECT, INSERT, etc.).Initialized lazily using SqlCmdsFactory.get(vendor) - vendor-specific implementation.
-
lexer
The lexer instance used for tokenization.Subclasses should set this field in their constructor to their specific lexer instance. This allows common tokenization logic in AbstractSqlParser to access the lexer generically.
-
globalContext
Global context for semantic analysis.Created during performParsing phase, contains SQL environment and statement references.
-
sqlEnv
SQL environment for semantic analysis.Vendor-specific environment configuration, used by resolver and semantic analysis.
-
frameStack
Frame stack for scope management during parsing.Used to track nested scopes (global, statement, block-level) during parsing.
-
globalFrame
Global frame pushed to frame stack during parsing.Represents the outermost scope, must be popped after parsing completes.
-
-
Constructor Details
-
AbstractSqlParser
Construct parser for given database vendor.- Parameters:
vendor- the database vendor
-
-
Method Details
-
getVendor
Description copied from interface:SqlParserGet the database vendor this parser handles. -
setTokenHandle
Set an event handler which will be fired when a new source token is created by the lexer during tokenization.- Parameters:
tokenHandle- the event handler to process the new created source token
-
parse
Template method for full parsing.This method defines the skeleton of the parsing algorithm. Subclasses should NOT override this method; instead, they should override the abstract methods and hook methods called by this template.
Algorithm:
- Create lexer
- Tokenize (time tracked)
- Process tokens (vendor-specific preprocessing)
- Create parser(s)
- Parse (time tracked)
- Semantic analysis (time tracked)
- Interpreter (time tracked)
-
tokenize
Template method for tokenization only (without full parsing).This method is used by
getrawsqlstatements()which only needs tokenization and raw statement extraction, without detailed syntax checking or semantic analysis.Algorithm:
- Get lexer
- Tokenize (time tracked)
- Extract raw statements (no parsing)
-
getrawsqlstatements
Template method for extracting raw statements without full parsing.This method performs tokenization and raw statement extraction, but skips the expensive full parsing and semantic analysis steps.
Algorithm:
- Tokenize SQL (via
tokenize(ParserContext)) - Extract raw statements (via
extractRawStatements(ParserContext, TSourceTokenList, TCustomLexer, long)) - Return result with tokens and raw statements
Equivalent to legacy API:
TGSqlParser.getrawsqlstatements()- Specified by:
getrawsqlstatementsin interfaceSqlParser- Parameters:
context- immutable context with all inputs- Returns:
- immutable result with tokens and raw statements (no AST)
- Tokenize SQL (via
-
getLexer
Get the lexer for this vendor.Subclass Responsibility: Return vendor-specific lexer instance. The lexer may be created fresh or cached/reused for performance.
Example:
protected TCustomLexer getLexer(ParserContext context) { TLexerOracle lexer = new TLexerOracle(); lexer.delimiterchar = delimiterChar; lexer.defaultDelimiterStr = defaultDelimiterStr; return lexer; }- Parameters:
context- the parser context- Returns:
- configured lexer instance (never null)
-
getParser
Get the main parser for this vendor.Subclass Responsibility: Return vendor-specific parser instance. The parser may be created fresh or cached/reused for performance. If reusing, the token list should be updated.
Example:
protected TCustomParser getParser(ParserContext context, TSourceTokenList tokens) { TParserOracleSql parser = new TParserOracleSql(tokens); parser.lexer = getLexer(context); return parser; }- Parameters:
context- the parser contexttokens- the source token list- Returns:
- configured parser instance (never null)
-
performTokenization
Perform tokenization using vendor-specific lexer.Template Method: This method implements the common tokenization algorithm across all database vendors. Subclasses customize through one hook:
tokenizeVendorSql()- Call vendor-specific tokenization logicAlgorithm:
- Store parser context
- Prepare SQL reader (file/string with charset detection)
- Configure lexer with input reader and charset
- Reset lexer state
- Clear token list and reset position
- Reset token table cache
- Call
tokenizeVendorSql()hook - Return populated token list
- Parameters:
context- parser context with SQL input configurationlexer- the lexer instance (same as this.flexer)- Returns:
- token list populated by vendor-specific tokenization
- Throws:
RuntimeException- if tokenization fails
-
tokenizeVendorSql
Call vendor-specific tokenization logic.Hook Method: Called by
performTokenization(gudusoft.gsqlparser.parser.ParserContext, gudusoft.gsqlparser.TCustomLexer)to execute vendor-specific SQL-to-token conversion logic.Subclass Responsibility: Call the vendor-specific tokenization method (e.g., dooraclesqltexttotokenlist, domssqlsqltexttotokenlist) which reads from lexer and populates sourcetokenlist.
Example (Oracle):
protected void tokenizeVendorSql() { dooraclesqltexttotokenlist(); }Example (MSSQL):
protected void tokenizeVendorSql() { domssqlsqltexttotokenlist(); }Example (PostgreSQL):
protected void tokenizeVendorSql() { dopostgresqltexttotokenlist(); } -
doExtractRawStatements
Extract raw statements without full parsing (public API).This public method allows external callers (like TGSqlParser) to extract raw statements from an already-tokenized source list without re-tokenization.
- Specified by:
doExtractRawStatementsin interfaceSqlParser- Parameters:
context- the parser contexttokens- the source token list (already tokenized)- Returns:
- statement list (never null)
- Since:
- 3.2.0.0
-
extractRawStatements
protected SqlParseResult extractRawStatements(ParserContext context, TSourceTokenList tokens, TCustomLexer lexer, long tokenizationTimeMs) Extract raw statements without full parsing.Template Method: This method implements the common algorithm for extracting raw statements across all database vendors. Subclasses customize the process through two hook methods:
setupVendorParsersForExtraction()- Initialize vendor parsersextractVendorRawStatements(SqlParseResult.Builder)- Call vendor extraction logic
Algorithm:
- Create SqlParseResult.Builder
- Set common fields (lexer, tokens, tokenization time)
- Store context and tokens for extraction
- Initialize SQL command resolver
- Call
setupVendorParsersForExtraction()hook - Time the extraction
- Call
extractVendorRawStatements(SqlParseResult.Builder)hook - Set parsing time
- Build and return result
- Parameters:
context- the parser contexttokens- the source token listlexer- the lexer instance (for including in result)tokenizationTimeMs- tokenization time from tokenize() step- Returns:
- complete SqlParseResult with raw statements and metadata
-
setupVendorParsersForExtraction
Setup vendor-specific parsers for raw statement extraction.Hook Method: Called by
extractRawStatements(gudusoft.gsqlparser.parser.ParserContext, gudusoft.gsqlparser.TSourceTokenList, gudusoft.gsqlparser.TCustomLexer, long)after initializing sqlcmds but before calling the vendor-specific extraction logic.Subclass Responsibility: Inject sqlcmds into vendor parser(s) and update their token lists. Examples:
- Single parser (MSSQL): Inject into fparser only
- Dual parsers (Oracle): Inject into both fparser and fplsqlparser
Example (MSSQL):
protected void setupVendorParsersForExtraction() { this.fparser.sqlcmds = this.sqlcmds; this.fparser.sourcetokenlist = this.sourcetokenlist; }Example (Oracle with dual parsers):
protected void setupVendorParsersForExtraction() { this.fparser.sqlcmds = this.sqlcmds; this.fplsqlparser.sqlcmds = this.sqlcmds; this.fparser.sourcetokenlist = this.sourcetokenlist; this.fplsqlparser.sourcetokenlist = this.sourcetokenlist; } -
extractVendorRawStatements
Call vendor-specific raw statement extraction logic.Hook Method: Called by
extractRawStatements(gudusoft.gsqlparser.parser.ParserContext, gudusoft.gsqlparser.TSourceTokenList, gudusoft.gsqlparser.TCustomLexer, long)to execute the vendor-specific logic for identifying statement boundaries.Subclass Responsibility: Call the vendor-specific extraction method (e.g., dooraclegetrawsqlstatements, domssqlgetrawsqlstatements) passing the builder. The extraction method will populate the builder with raw statements.
Example (Oracle):
protected void extractVendorRawStatements(SqlParseResult.Builder builder) { dooraclegetrawsqlstatements(builder); }Example (MSSQL):
protected void extractVendorRawStatements(SqlParseResult.Builder builder) { domssqlgetrawsqlstatements(builder); }- Parameters:
builder- the result builder to populate with raw statements
-
performParsing
protected abstract TStatementList performParsing(ParserContext context, TCustomParser parser, TCustomParser secondaryParser, TSourceTokenList tokens, TStatementList rawStatements) Perform actual parsing with syntax checking.Subclass Responsibility: Parse SQL using vendor-specific parser and optional secondary parser (e.g., PL/SQL for Oracle).
Important: This method receives raw statements that have already been extracted by
getrawsqlstatements(ParserContext). Subclasses should NOT re-extract statements - just parse each statement to build the AST.Example:
protected TStatementList performParsing(ParserContext context, TCustomParser parser, TCustomParser secondaryParser, TSourceTokenList tokens, TStatementList rawStatements) { // Use the passed-in rawStatements (DO NOT re-extract!) for (int i = 0; i < rawStatements.size(); i++) { TCustomSqlStatement stmt = rawStatements.get(i); stmt.parsestatement(...); // Build AST for each statement } return rawStatements; }- Parameters:
context- the parser contextparser- the main parser instancesecondaryParser- secondary parser (may be null)tokens- the source token listrawStatements- raw statements already extracted (never null)- Returns:
- statement list with parsed AST (never null)
-
getSecondaryParser
Get secondary parser (e.g., PL/SQL for Oracle).Hook Method: Default implementation returns null. Override if vendor needs a secondary parser. The parser may be created fresh or cached/reused for performance.
Example (Oracle):
protected TCustomParser getSecondaryParser(ParserContext context, TSourceTokenList tokens) { TParserOraclePLSql plsqlParser = new TParserOraclePLSql(tokens); plsqlParser.lexer = getLexer(context); return plsqlParser; }- Parameters:
context- the parser contexttokens- the source token list- Returns:
- secondary parser instance, or null if not needed
-
doAfterTokenize
Post-tokenization normalization.Handles matching parentheses wrapping around SQL and marks semicolons before closing parens to be ignored.
Extracted from: TGSqlParser.doAfterTokenize() (lines 5123-5161)
- Parameters:
tokens- the source token list (mutable)
-
processTokensInTokenTable
protected void processTokensInTokenTable(ParserContext context, TCustomLexer lexer, TSourceTokenList tokens) Process tokens using token table (vendor-specific token code adjustments).Currently handles BigQuery and Snowflake to convert DO keywords to identifiers when there's no corresponding WHILE/FOR.
Extracted from: TGSqlParser.processTokensInTokenTable() (lines 5186-5209)
- Parameters:
context- the parser contextlexer- the lexer (for accessing TOKEN_TABLE)tokens- the source token list (mutable)
-
processTokensBeforeParse
Process tokens before parsing (vendor-specific adjustments).Hook Method: Default implementation handles Snowflake consecutive semicolons. Override if vendor needs additional token preprocessing.
Extracted from: TGSqlParser.processTokensBeforeParse() (lines 5165-5184)
Example:
protected void processTokensBeforeParse(ParserContext context, TSourceTokenList tokens) { super.processTokensBeforeParse(context, tokens); // Call base implementation // Add vendor-specific processing... }- Parameters:
context- the parser contexttokens- the source token list (mutable)
-
performSemanticAnalysis
Perform semantic analysis on parsed statements.Hook Method: Default implementation does nothing. Override to provide vendor-specific semantic analysis.
Typical Implementation:
- Column-to-table resolution (TSQLResolver)
- Dataflow analysis
- Reference resolution
- Scope resolution
- Parameters:
context- the parser contextstatements- the parsed statements (mutable)
-
performInterpreter
Perform interpretation/evaluation on parsed statements.Hook Method: Default implementation does nothing. Override to provide AST interpretation/evaluation.
Typical Implementation:
- Execute simple SQL statements
- Evaluate expressions
- Constant folding
- Static analysis
- Parameters:
context- the parser contextstatements- the parsed statements (mutable)
-
copyErrorsFromStatement
Copy error messages from a statement to the parser's error collection.This method should be called by performParsing implementations when a statement has syntax errors.
- Parameters:
statement- the statement with errors
-
attemptErrorRecovery
protected int attemptErrorRecovery(TCustomSqlStatement statement, int parseResult, boolean onlyNeedRawParseTree) Attempt error recovery for CREATE TABLE/INDEX statements with unsupported options.When parsing CREATE TABLE or CREATE INDEX statements, the parser may encounter vendor-specific options that are not in the grammar. This method implements the legacy error recovery behavior by marking unsupported tokens after the main definition as SQL*Plus commands (effectively ignoring them).
Recovery Strategy:
- Find the closing ')' of the column/index definitions (nested=0)
- Mark all remaining tokens (except ';') as sqlpluscmd to ignore them
- Clear errors and re-parse the statement
When to call: After parsing a statement that has errors. Only recovers if ENABLE_ERROR_RECOVER_IN_CREATE_TABLE is true.
- Parameters:
statement- the statement to attempt recovery onparseResult- the result code from parsing (0 = success)onlyNeedRawParseTree- whether only raw parse tree is needed- Returns:
- new parse result after recovery attempt, or original if no recovery
-
getSyntaxErrors
Get the syntax errors collected during parsing.- Returns:
- list of syntax errors (never null)
-
getErrorCount
Get the count of syntax errors.- Returns:
- number of syntax errors
-
isDollarFunctionDelimiter
Check if a token is a dollar function delimiter ($$, $tag$, etc.) for PostgreSQL-family databases.Migrated from TGSqlParser.isDollarFunctionDelimiter() (lines 5074-5080).
Dollar-quoted strings are used in PostgreSQL-family databases to delimit function bodies. Each vendor has its own delimiter token code.
- Parameters:
tokencode- the token code to checkdbVendor- the database vendor- Returns:
- true if the token is a dollar function delimiter for the given vendor
-
onRawStatementComplete
protected void onRawStatementComplete(ParserContext context, TCustomSqlStatement statement, TCustomParser mainParser, TCustomParser secondaryParser, TStatementList statementList, boolean isLastStatement, SqlParseResult.Builder builder) Hook method called when a raw statement is complete.This method is called by vendor-specific raw statement extraction methods (e.g., dooraclegetrawsqlstatements) when a statement boundary is detected. It sets up the statement with parser references and adds it to the statement list.
- Parameters:
context- parser contextstatement- the completed statementmainParser- main parser instancesecondaryParser- secondary parser instance (may be null)statementList- statement list to add toisLastStatement- true if this is the last statementbuilder- optional result builder (used during raw statement extraction, may be null)
-
onRawStatementCompleteVendorSpecific
Hook for vendor-specific logic when a raw statement is completed.Migrated from TGSqlParser.doongetrawsqlstatementevent() (lines 5129-5178).
This method is called after basic statement setup but before adding to the statement list. Subclasses can override to add vendor-specific token manipulations or metadata.
Default implementation handles PostgreSQL-family routine body processing.
- Parameters:
statement- the completed statement
-
prepareSqlReader
protected AbstractSqlParser.PreparedSqlReader prepareSqlReader(ParserContext context) throws IOException - Throws:
IOException
-
initializeGlobalContext
Initialize global context and frame stack for statement parsing.This method sets up the semantic analysis infrastructure required during the parsing phase. It creates:
- Global context (TContext) for semantic analysis
- SQL environment (TSQLEnv) with vendor-specific configuration
- Frame stack for scope management
- Global scope frame as the outermost scope
When to call: At the beginning of performParsing(), before parsing statements.
Cleanup required: Must call
globalFrame.popMeFromStack(frameStack)after all statements are parsed to clean up the frame stack.Extracted from: Identical implementations in OracleSqlParser and MssqlSqlParser to eliminate ~16 lines of duplicate code per parser.
-
handleStatementParsingException
protected void handleStatementParsingException(TCustomSqlStatement stmt, int statementIndex, Exception ex) Handle exceptions that occur during individual statement parsing.This method provides robust error handling that allows parsing to continue even when individual statements throw exceptions. It:
- Creates a detailed
TSyntaxErrorwith exception information - Captures statement location (line, column) from first token
- Includes statement number, exception type, and message
- Optionally logs full stack trace if debugging is enabled
- Adds error to
syntaxErrorslist for user feedback
Benefits:
- Parsing continues for remaining statements after exception
- Users get complete error feedback for all statements
- Developers get stack traces for debugging parser issues
Example error message:
"Exception during parsing statement 3: NullPointerException - Cannot invoke..."Extracted from: Identical implementations in OracleSqlParser and MssqlSqlParser to eliminate ~51 lines of duplicate code per parser.
- Parameters:
stmt- the statement that failed to parsestatementIndex- 0-based index of the statement in the statement listex- the exception that was thrown during parsing
- Creates a detailed
-
afterStatementParsed
Hook method for vendor-specific post-processing after a statement is parsed.This method is called after each statement is successfully parsed but before error recovery and error collection. Subclasses can override this to perform vendor-specific operations such as:
- Checking for vendor-specific syntax errors in nested statements
- Validating vendor-specific constraints
- Collecting vendor-specific metadata
Default implementation: Does nothing (no-op).
Example override (Oracle):
@Override protected void afterStatementParsed(TCustomSqlStatement stmt) { if (stmt.isoracleplsql()) { findAllSyntaxErrorsInPlsql(stmt); } }When called: After
stmt.parsestatement()succeeds, beforehandleCreateTableErrorRecovery()andcopyErrorsFromStatement().- Parameters:
stmt- the statement that was just parsed
-
getanewsourcetoken
Get next source token from the lexer.This method wraps the lexer's yylexwrap() call and performs several important tasks:
- Fetches the next raw token from the lexer
- Combines consecutive whitespace/newline tokens for cleaner token stream
- Sets token metadata (vendor, status, container, position in list)
- Optionally calls token handler callback
Token Consolidation Rules:
- Whitespace after a newline is merged into the newline token
- Consecutive newlines are merged into a single newline token
Implementation Note: This method is extracted from TGSqlParser.getanewsourcetoken() and made available to all database-specific parsers to avoid code duplication.
- Returns:
- next source token, or null if end of input
-
towinlinebreak
Convert line breaks to Windows format.Currently returns the input unchanged. This method exists for compatibility with the original TGSqlParser implementation.
- Parameters:
s- Input string- Returns:
- String with Windows line breaks (currently unchanged)
-
getDelimiterChar
Get the delimiter character for this vendor.- Returns:
- delimiter character (e.g., ';', '/', '$')
-
getDefaultDelimiterStr
Get the default delimiter string for this vendor.- Returns:
- default delimiter string
-
toString
-