Documentation
¶
Index ¶
- func FormatErrorContext(input string, position int, contextLength int) string
- func Parse(sql string) (*types.Config, string, error)
- func ParseAggregateTypeWithExpression(exprStr string) (aggType aggregator.AggregateType, name string, expression string, ...)
- type ErrorRecovery
- type ErrorType
- type Field
- type FunctionCall
- type FunctionValidator
- type Lexer
- type ParseError
- func CreateLexicalError(message string, position int, char byte) *ParseError
- func CreateLexicalErrorWithPosition(message string, position int, line int, column int, char byte) *ParseError
- func CreateMissingTokenError(expected string, position int) *ParseError
- func CreateSyntaxError(message string, position int, token string, expected []string) *ParseError
- func CreateUnexpectedTokenError(found string, expected []string, position int) *ParseError
- func CreateUnknownFunctionError(functionName string, position int) *ParseError
- type Parser
- type SelectStatement
- type Token
- type TokenType
- type WindowDefinition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatErrorContext ¶
FormatErrorContext 格式化错误上下文
func ParseAggregateTypeWithExpression ¶
func ParseAggregateTypeWithExpression(exprStr string) (aggType aggregator.AggregateType, name string, expression string, allFields []string)
解析聚合函数,并返回表达式信息
Types ¶
type ErrorRecovery ¶
type ErrorRecovery struct {
// contains filtered or unexported fields
}
ErrorRecovery 错误恢复策略
func NewErrorRecovery ¶
func NewErrorRecovery(parser *Parser) *ErrorRecovery
NewErrorRecovery 创建错误恢复实例
func (*ErrorRecovery) GetErrors ¶
func (er *ErrorRecovery) GetErrors() []*ParseError
GetErrors 获取所有错误
func (*ErrorRecovery) RecoverFromError ¶
func (er *ErrorRecovery) RecoverFromError(errorType ErrorType) bool
RecoverFromError 从错误中恢复
type FunctionValidator ¶
type FunctionValidator struct {
// contains filtered or unexported fields
}
FunctionValidator 函数验证器
func NewFunctionValidator ¶
func NewFunctionValidator(errorRecovery *ErrorRecovery) *FunctionValidator
NewFunctionValidator 创建函数验证器
func (*FunctionValidator) ValidateExpression ¶
func (fv *FunctionValidator) ValidateExpression(expression string, position int)
ValidateExpression 验证表达式中的函数
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
func (*Lexer) SetErrorRecovery ¶
func (l *Lexer) SetErrorRecovery(er *ErrorRecovery)
SetErrorRecovery 设置错误恢复实例
type ParseError ¶
type ParseError struct { Type ErrorType Message string Position int Line int Column int Token string Expected []string Suggestions []string Context string Recoverable bool }
ParseError 增强的解析错误结构
func CreateLexicalError ¶
func CreateLexicalError(message string, position int, char byte) *ParseError
CreateLexicalError 创建词法错误
func CreateLexicalErrorWithPosition ¶
func CreateLexicalErrorWithPosition(message string, position int, line int, column int, char byte) *ParseError
CreateLexicalErrorWithPosition 创建词法错误(带准确位置信息)
func CreateMissingTokenError ¶
func CreateMissingTokenError(expected string, position int) *ParseError
CreateMissingTokenError 创建缺失token错误
func CreateSyntaxError ¶
func CreateSyntaxError(message string, position int, token string, expected []string) *ParseError
CreateSyntaxError 创建语法错误
func CreateUnexpectedTokenError ¶
func CreateUnexpectedTokenError(found string, expected []string, position int) *ParseError
CreateUnexpectedTokenError 创建意外token错误
func CreateUnknownFunctionError ¶
func CreateUnknownFunctionError(functionName string, position int) *ParseError
CreateUnknownFunctionError 创建未知函数错误
func (*ParseError) IsRecoverable ¶
func (e *ParseError) IsRecoverable() bool
IsRecoverable 检查错误是否可恢复
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) Parse ¶
func (p *Parser) Parse() (*SelectStatement, error)
type SelectStatement ¶
type SelectStatement struct { Fields []Field Distinct bool SelectAll bool // 新增:标识是否是SELECT *查询 Source string Condition string Window WindowDefinition GroupBy []string Limit int Having string }
func (*SelectStatement) ToStreamConfig ¶
func (s *SelectStatement) ToStreamConfig() (*types.Config, string, error)
ToStreamConfig 将AST转换为Stream配置
type TokenType ¶
type TokenType int
const ( TokenEOF TokenType = iota TokenIdent TokenNumber TokenString TokenComma TokenLParen TokenRParen TokenPlus TokenMinus TokenAsterisk TokenSlash TokenEQ TokenNE TokenGT TokenLT TokenGE TokenLE TokenAND TokenOR TokenSELECT TokenFROM TokenWHERE TokenGROUP TokenBY TokenAS TokenTumbling TokenSliding TokenCounting TokenSession TokenWITH TokenTimestamp TokenTimeUnit TokenOrder TokenDISTINCT TokenLIMIT TokenHAVING TokenLIKE TokenIS TokenNULL TokenNOT // CASE表达式相关token TokenCASE TokenWHEN TokenTHEN TokenELSE TokenEND // 数组索引相关token TokenLBracket TokenRBracket )
Click to show internal directories.
Click to hide internal directories.