Documentation
¶
Overview ¶
Package parser contains the exported entry points for invoking the parser.
Index ¶
- func ClickHousePlaceholder(name string, _ int) string
- func ParseFile(fset *gotok.FileSet, filename string, src interface{}, mode Mode) (f *ast.File, err error)
- func ParseFileDialect(fset *gotok.FileSet, filename string, src interface{}, mode Mode, ...) (f *ast.File, err error)
- func PostgresPlaceholder(_ string, ordinal int) string
- type Mode
- type Placeholder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClickHousePlaceholder ¶ added in v0.1.0
ClickHousePlaceholder leaves a pggen.arg() reference exactly as written.
ClickHouse query files declare their parameters natively, as {name:Type}, carrying a type pggen has no way to invent here. So this dialect rewrites nothing, and Generate rejects pggen.arg() with an explanation instead.
func ParseFile ¶
func ParseFile(fset *gotok.FileSet, filename string, src interface{}, mode Mode) (f *ast.File, err error)
ParseFile parses the source code of a single query source file and returns the corresponding ast.File node. The source code may be provided via the filename of the source file, or via the src parameter.
If src != nil, ParseFile parses the source from src and the filename is only used when recording position information. The type of the argument for the src parameter must be string, []byte, or io.Reader. If src == nil, ParseFile parses the file specified by filename.
The mode parameter controls the amount of source text parsed and other optional parser functionality. Position information is recorded in the file set fset, which must not be nil.
If the source couldn't be read, the returned AST is nil and the error indicates the specific failure. If the source was read but syntax errors were found, the result is a partial AST (with ast.Bad* nodes representing the fragments of erroneous source code). Multiple errors are returned via a scanner.ErrorList which is sorted by source position.
func ParseFileDialect ¶ added in v0.1.0
func ParseFileDialect(fset *gotok.FileSet, filename string, src interface{}, mode Mode, ph Placeholder) (f *ast.File, err error)
ParseFileDialect is ParseFile with control over how query parameters are rendered into ast.SourceQuery.PreparedSQL. A dialect whose query files already carry their own parameter syntax passes a Placeholder that leaves the SQL untouched.
func PostgresPlaceholder ¶ added in v0.1.0
PostgresPlaceholder renders Postgres positional parameters: $1, $2, and so on, in order of first appearance.
Types ¶
type Mode ¶
type Mode uint
A Mode value is a set of flags (or 0). They control the amount of source code parsed and other optional parser functionality.
type Placeholder ¶ added in v0.1.0
Placeholder renders the reference to a query parameter the way the target dialect spells it. name is the pggen.arg name and ordinal is its 1-based position in order of first appearance.