Help us shape the future of Go! Take the 2026 Go Developer Survey

parser

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrExpectedSingleStatement

type ErrExpectedSingleStatement struct {
	Count int
}

ErrExpectedSingleStatement indicates ParseOne received zero or multiple statements.

func (ErrExpectedSingleStatement) Error

type ErrUnsupportedDialect

type ErrUnsupportedDialect struct {
	Dialect string
}

ErrUnsupportedDialect indicates there is no parser backend for the requested dialect yet.

func (ErrUnsupportedDialect) Error

func (e ErrUnsupportedDialect) Error() string

type MariaDBDropForeignKeyStmt

type MariaDBDropForeignKeyStmt struct {
	Table    string
	Name     string
	IfExists bool
}

MariaDBDropForeignKeyStmt captures a MariaDB-only ALTER TABLE extension not accepted by TiDB parser.

type ParsedStatement

type ParsedStatement struct {
	SQL            string
	SourceDialect  string
	Kind           StatementKind
	Status         SupportStatus
	NativeNodeType string
	NativeAST      any
}

ParsedStatement is the project-owned parse result returned by the parser facade.

func ParseMulti

func ParseMulti[D ~string](sql string, dialect D) ([]*ParsedStatement, error)

ParseMulti parses one or more SQL statements and returns project-owned parse results.

func ParseOne

func ParseOne[D ~string](sql string, dialect D) (*ParsedStatement, error)

ParseOne parses a single SQL statement and classifies it for downstream adaptation.

type StatementKind

type StatementKind string

StatementKind identifies the recognized SQL statement family.

const (
	StatementKindSelect           StatementKind = "select"
	StatementKindInsert           StatementKind = "insert"
	StatementKindUpdate           StatementKind = "update"
	StatementKindDelete           StatementKind = "delete"
	StatementKindBegin            StatementKind = "begin"
	StatementKindCommit           StatementKind = "commit"
	StatementKindRollback         StatementKind = "rollback"
	StatementKindSavepoint        StatementKind = "savepoint"
	StatementKindReleaseSavepoint StatementKind = "release_savepoint"
	StatementKindWith             StatementKind = "with"
	StatementKindSetOp            StatementKind = "set_op"
	StatementKindSet              StatementKind = "set"
	StatementKindCreateTable      StatementKind = "create_table"
	StatementKindCreateDatabase   StatementKind = "create_database"
	StatementKindCreateView       StatementKind = "create_view"
	StatementKindExplain          StatementKind = "explain"
	StatementKindAlterTable       StatementKind = "alter_table"
	StatementKindDropDatabase     StatementKind = "drop_database"
	StatementKindDropTable        StatementKind = "drop_table"
	StatementKindDropView         StatementKind = "drop_view"
	StatementKindShow             StatementKind = "show"
	StatementKindUse              StatementKind = "use"
	StatementKindCreateIndex      StatementKind = "create_index"
	StatementKindDropIndex        StatementKind = "drop_index"
	StatementKindTruncate         StatementKind = "truncate_table"
	StatementKindRenameTable      StatementKind = "rename_table"
	StatementKindOtherDDL         StatementKind = "other_ddl"
	StatementKindOtherDML         StatementKind = "other_dml"
	StatementKindOther            StatementKind = "other"
)

type SupportStatus

type SupportStatus string

SupportStatus records whether a parsed statement is already adapted upstream.

const (
	SupportStatusSupported           SupportStatus = "supported"
	SupportStatusRecognizedUnadapted SupportStatus = "recognized_unadapted"
	SupportStatusUnsupported         SupportStatus = "unsupported"
)

Directories

Path Synopsis
ast
Package ast is the abstract syntax tree parsed from a SQL statement by parser.
Package ast is the abstract syntax tree parsed from a SQL statement by parser.
duration
Package duration provides a customized duration, which supports unit 'd', 'h' and 'm'
Package duration provides a customized duration, which supports unit 'd', 'h' and 'm'
goyacc command
Goyacc is a version of yacc generating Go parsers.
Goyacc is a version of yacc generating Go parsers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL