Documentation
¶
Overview ¶
Package lexer implements a small, allocation-free SQL lexer for the interpolation package. It only recognizes lexical regions that matter when locating placeholders: quoted strings and identifiers, comments and the placeholders themselves. It does not parse SQL grammar.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dialect ¶
type Dialect struct {
Placeholder PlaceholderStyle
HashComment bool
HashCommentNeedsSpace bool
DashCommentNeedsSpace bool
SlashSlashComment bool
BraceComment bool
LineCommentEndsOnCR bool
BlockCommentNested bool
ExecutableComment bool
BackslashEscape bool
BacktickIdent bool
BracketIdent bool
PGStyle bool
OracleAltQuote bool
}
Dialect describes the lexical rules that vary between SQL flavors.
type PlaceholderStyle ¶
type PlaceholderStyle int
PlaceholderStyle selects the parameter syntax recognized by the scanner.
const ( // NoPlaceholder disables placeholder recognition. NoPlaceholder PlaceholderStyle = iota // QuestionMark recognizes sequential "?" parameters. QuestionMark // DollarNumber recognizes numbered "$1" parameters. DollarNumber // AtNumber recognizes numbered "@p1" parameters. AtNumber // ColonNumber recognizes numbered ":1" parameters. ColonNumber )
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner walks a SQL query once and emits tokens covering the whole input.
type TokenType ¶
type TokenType int
TokenType identifies a lexical region in a SQL query.
const ( // Text is an ordinary part of the query. Text TokenType = iota // Quoted is a string literal, quoted identifier, dollar-quoted string or // another region in which placeholders must not be interpreted. Quoted // Comment is a line or block comment. Comment // Placeholder is a parameter to be replaced by a value. Placeholder )