ast

package
v0.0.0-...-765d1ad Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BadQuery

type BadQuery struct {
	From, To gotok.Pos // position range of bad declaration
}

A BadQuery node is a placeholder for queries containing syntax errors for which no correct declaration nodes can be created.

func (*BadQuery) End

func (q *BadQuery) End() gotok.Pos

func (*BadQuery) Kind

func (q *BadQuery) Kind() NodeKind

func (*BadQuery) Pos

func (q *BadQuery) Pos() gotok.Pos

type CommentGroup

type CommentGroup struct {
	List []*LineComment // len(List) > 0
}

A CommentGroup represents a sequence of comments with no other tokens and no empty lines between.

func (*CommentGroup) End

func (g *CommentGroup) End() gotok.Pos

func (*CommentGroup) Kind

func (g *CommentGroup) Kind() NodeKind

func (*CommentGroup) Pos

func (g *CommentGroup) Pos() gotok.Pos

type File

type File struct {
	Name     string
	Doc      *CommentGroup   // associated documentation; or nil
	Queries  []Query         // top-level queries; or nil
	Comments []*CommentGroup // list of all comments in the source file
}

A File node represents a query source file.

The Comments list contains all comments in the source file in order of appearance, including the comments that are pointed to from other nodes via Doc and Comment fields.

func (*File) End

func (f *File) End() gotok.Pos

func (*File) Kind

func (f *File) Kind() NodeKind

func (*File) Pos

func (f *File) Pos() gotok.Pos

type LineComment

type LineComment struct {
	Start gotok.Pos // position of the '--' starting the comment
	Text  string    // comment text excluding '\n'
}

A LineComment node represents a single line comment.

func (*LineComment) End

func (c *LineComment) End() gotok.Pos

func (*LineComment) Kind

func (c *LineComment) Kind() NodeKind

func (*LineComment) Pos

func (c *LineComment) Pos() gotok.Pos

type Node

type Node interface {
	Pos() gotok.Pos
	End() gotok.Pos
	Kind() NodeKind
}

Node is the super-type of all AST nodes.

type NodeKind

type NodeKind int

NodeKind is the kind of Node.

const (
	KindLineComment NodeKind = iota
	KindCommentGroup
	KindBadQuery
	KindTemplateQuery
	KindFile
)

func (NodeKind) String

func (k NodeKind) String() string

type Pragmas

type Pragmas struct {
	ProtobufType string // package qualified protocol buffer message type to use for output rows
}

Pragmas are options to control generated code for a single query.

type Query

type Query interface {
	Node
	// contains filtered or unexported methods
}

All query nodes implement the Decl interface.

type ResultKind

type ResultKind string

ResultKind is the shape of the output. Controls the output type of the query.

const (
	ResultKindMany ResultKind = ":many"
	ResultKindOne  ResultKind = ":one"
	ResultKindExec ResultKind = ":exec"
)

type SourceQuery

type SourceQuery struct {
	Name        string        // name of the query
	Doc         *CommentGroup // associated documentation; or nil
	Start       gotok.Pos     // position of the start token, like 'SELECT' or 'UPDATE'
	SourceSQL   string        // the complete sql query as it appeared in the source file
	PreparedSQL string        // the sql query with args replaced by $1, $2, etc.
	ParamNames  []string      // the name of each param in the PreparedSQL, the nth entry is the $n+1 param
	ResultKind  ResultKind    // the result output type
	Pragmas     Pragmas       // optional query options
	Semi        gotok.Pos     // position of the closing semicolon
}

An SourceQuery node represents a query entry from the source code.

func (*SourceQuery) End

func (q *SourceQuery) End() gotok.Pos

func (*SourceQuery) Kind

func (q *SourceQuery) Kind() NodeKind

func (*SourceQuery) Pos

func (q *SourceQuery) Pos() gotok.Pos

Jump to

Keyboard shortcuts

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