public class AnsiSqlParser extends AbstractSqlParser
This parser handles ANSI standard SQL syntax. It delegates tokenization and raw statement extraction to DB2 logic, as ANSI SQL shares similar parsing characteristics with DB2.
Design Notes:
AbstractSqlParserTLexerAnsi, TParserAnsiMigrated from TGSqlParser:
SqlParser,
AbstractSqlParser,
TLexerAnsi,
TParserAnsiAbstractSqlParser.PreparedSqlReaderdefaultDelimiterStr, delimiterChar, frameStack, globalContext, globalFrame, lexer, parserContext, sourcetokenlist, sqlcmds, sqlEnv, sqlstatements, syntaxErrors, vendor| Constructor and Description |
|---|
AnsiSqlParser()
Construct ANSI SQL parser.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
extractVendorRawStatements(SqlParseResult.Builder builder)
Call ANSI-specific raw statement extraction logic.
|
protected TCustomLexer |
getLexer(ParserContext context)
Return the ANSI lexer instance.
|
protected TCustomParser |
getParser(ParserContext context,
TSourceTokenList tokens)
Return the ANSI SQL parser instance with updated token list.
|
protected TStatementList |
performParsing(ParserContext context,
TCustomParser parser,
TCustomParser secondaryParser,
TSourceTokenList tokens,
TStatementList rawStatements)
Perform full parsing on raw ANSI SQL statements.
|
protected void |
setupVendorParsersForExtraction()
Setup ANSI parser for raw statement extraction.
|
protected void |
tokenizeVendorSql()
Call ANSI-specific tokenization logic.
|
String |
toString() |
afterStatementParsed, attemptErrorRecovery, copyErrorsFromStatement, doAfterTokenize, doExtractRawStatements, extractRawStatements, getanewsourcetoken, getDefaultDelimiterStr, getDelimiterChar, getErrorCount, getrawsqlstatements, getSecondaryParser, getSyntaxErrors, getVendor, handleStatementParsingException, initializeGlobalContext, isDollarFunctionDelimiter, onRawStatementComplete, onRawStatementCompleteVendorSpecific, parse, performInterpreter, performSemanticAnalysis, performTokenization, prepareSqlReader, processTokensBeforeParse, processTokensInTokenTable, setTokenHandle, tokenize, towinlinebreakpublic AnsiSqlParser()
Configures the parser for ANSI standard SQL with default delimiter: semicolon (;)
Following the original TGSqlParser pattern, the lexer and parser are created once in the constructor and reused for all parsing operations.
protected TCustomLexer getLexer(ParserContext context)
The lexer is created once in the constructor and reused for all parsing operations. This method simply returns the existing instance, matching the original TGSqlParser pattern where the lexer is created once and reset before each use.
getLexer in class AbstractSqlParsercontext - parser context (not used, lexer already created)protected TCustomParser getParser(ParserContext context, TSourceTokenList tokens)
The parser is created once in the constructor and reused for all parsing operations. This method updates the token list and returns the existing instance, matching the original TGSqlParser pattern.
getParser in class AbstractSqlParsercontext - parser context (not used, parser already created)tokens - source token list to parseprotected void tokenizeVendorSql()
Delegates to dodb2sqltexttotokenlist which handles ANSI/DB2 specific keyword recognition and token generation.
This follows the original TGSqlParser pattern where doansitexttotokenlist() delegates to dodb2sqltexttotokenlist().
tokenizeVendorSql in class AbstractSqlParserprotected void setupVendorParsersForExtraction()
ANSI uses a single parser, so we inject sqlcmds and update the token list for the main parser only.
setupVendorParsersForExtraction in class AbstractSqlParserprotected void extractVendorRawStatements(SqlParseResult.Builder builder)
Delegates to dodb2getrawsqlstatements which handles ANSI/DB2 statement boundaries and compound blocks.
This follows the original TGSqlParser pattern where doansigetrawsqlstatements() delegates to dodb2getrawsqlstatements().
extractVendorRawStatements in class AbstractSqlParserbuilder - result builder to populateprotected TStatementList performParsing(ParserContext context, TCustomParser parser, TCustomParser secondaryParser, TSourceTokenList tokens, TStatementList rawStatements)
This method parses each raw statement into a complete parse tree, handling stored procedures, functions, triggers, and nested blocks.
performParsing in class AbstractSqlParsercontext - parser contextparser - main parser instancesecondaryParser - secondary parser (null for ANSI)tokens - source token listrawStatements - raw statements to parsepublic String toString()
toString in class AbstractSqlParser