Documentation ¶
Overview ¶
Package parser implements a parser for SQL statements
Inspired by go/parser
Index ¶
Constants ¶
View Source
const ( SpaceToken = iota SemicolonToken CommaToken BracketOpeningToken BracketClosingToken LeftDipleToken RightDipleToken LessOrEqualToken GreaterOrEqualToken BacktickToken DoubleQuoteToken SimpleQuoteToken StarToken EqualityToken DistinctnessToken PeriodToken CreateToken SelectToken InsertToken UpdateToken DeleteToken ExplainToken TruncateToken DropToken GrantToken DistinctToken FromToken WhereToken TableToken SchemaToken CurrentSchemaToken IntoToken ValuesToken JoinToken AsToken OnToken IfToken NotToken ExistsToken NullToken UnsignedToken AutoincrementToken CountToken SetToken OrderToken ByToken WithToken TimeToken ZoneToken ReturningToken InToken AndToken OrToken AscToken DescToken LimitToken IsToken ForToken DefaultToken LocalTimestampToken FalseToken UniqueToken NowToken OffsetToken IndexToken CollateToken NocaseToken TextToken IntToken PrimaryToken KeyToken StringToken DecimalToken NumberToken DateToken FloatToken ArgToken NamedArgToken )
SQL Tokens
View Source
const DateLongFormat = "2006-01-02 15:04:05.999999999 -0700 MST"
DateLongFormat is same as time.Time#String(), except this does not include monotonic time section
View Source
const DateNumberFormat = "2006-01-02"
View Source
const DateShortFormat = "2006-Jan-02"
DateShortFormat is a short format
Variables ¶
This section is empty.
Functions ¶
func TypeNameFromToken ¶
Types ¶
type Instruction ¶
type Instruction struct {
Decls []*Decl
}
Instruction define a valid SQL statement
func ParseInstruction ¶
func ParseInstruction(instruction string) ([]Instruction, error)
ParseInstruction calls lexer and parser, then return Decl tree for each instruction
func (Instruction) PrettyPrint ¶
func (i Instruction) PrettyPrint(printer func(fmt string, varargs ...interface{}))
PrettyPrint prints instruction's declarations on console with indentation
Click to show internal directories.
Click to hide internal directories.