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 InequalityToken PeriodToken CreateToken SelectToken InsertToken UpdateToken DeleteToken ExplainToken TruncateToken DropToken GrantToken FromToken WhereToken TableToken IntoToken ValuesToken JoinToken OnToken IfToken NotToken ExistsToken NullToken AutoincrementToken CountToken SetToken OrderToken ByToken WithToken TimeToken ZoneToken ReturningToken InToken AndToken OrToken AscToken DescToken LimitToken IsToken ForToken DefaultToken LocalTimestampToken FalseToken UniqueToken NowToken OffsetToken TextToken IntToken PrimaryToken KeyToken StringToken NumberToken DateToken )
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 ¶
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()
PrettyPrint prints instruction's declarations on console with indentation
Click to show internal directories.
Click to hide internal directories.