grammars

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package grammars defines SQL dialect grammars.

Index

Constants

View Source
const (
	// SQLiteGrammar contains the SQLite DDL grammar rules
	SQLiteGrammar = `` /* 909-byte string literal not displayed */

	// PostgreSQLGrammar contains the PostgreSQL DDL grammar rules
	PostgreSQLGrammar = `` /* 1397-byte string literal not displayed */

	// MySQLGrammar contains the MySQL DDL grammar rules
	MySQLGrammar = `` /* 1920-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func GetDialectGrammar

func GetDialectGrammar(dialect Dialect) (string, error)

GetDialectGrammar returns the grammar for a given dialect

func ValidateSyntax

func ValidateSyntax(dialect Dialect, sql string) ([]string, error)

ValidateSyntax checks if SQL matches the dialect's syntax rules

Types

type Dialect

type Dialect string

Dialect represents a SQL dialect

const (
	// DialectSQLite represents the SQLite dialect.
	DialectSQLite Dialect = "sqlite"
	// DialectPostgreSQL represents the PostgreSQL dialect.
	DialectPostgreSQL Dialect = "postgresql"
	// DialectMySQL represents the MySQL dialect.
	DialectMySQL Dialect = "mysql"
)

type GrammarDefinition

type GrammarDefinition struct {
	Statements []*StatementDefinition `@@*`
}

GrammarDefinition represents a parsed SQL grammar

type RuleDefinition

type RuleDefinition struct {
	Name     string        `@Ident "="`
	Variants []*VariantDef `"|"? @@*`
}

RuleDefinition represents a grammar rule

type StatementDefinition

type StatementDefinition struct {
	Name    string            `@Ident`
	Pattern string            `@String`
	Rules   []*RuleDefinition `@@*"`
}

StatementDefinition represents a SQL statement type

type VariantDef

type VariantDef struct {
	Tokens []string `@Ident+`
}

VariantDef represents a rule variant

Jump to

Keyboard shortcuts

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