parser

package
v0.0.0-...-1693482 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TokenTypeDirective = "directive"
	TokenTypeText      = "text"
)
View Source
const (
	DirectiveTypeCuttle     = "cuttle"
	DirectiveTypeEnd        = "end"
	DirectiveTypeMigration  = "migration"
	DirectiveTypeApply      = "apply"
	DirectiveTypeStep       = "step"
	DirectiveTypeRevert     = "revert"
	DirectiveTypeRepository = "repository"
	DirectiveTypeQuery      = "query"
	DirectiveTypeArg        = "arg"
	DirectiveTypeDoc        = "doc"
	DirectiveTypeCol        = "col"
	DirectiveTypeDialect    = "dialect"
)

Variables

View Source
var ErrDocAlreadyExists = errors.New("doc comment already exists")
View Source
var ErrInvalidInput = errors.New("invalid input")

Functions

This section is empty.

Types

type Arg

type Arg struct {
	Name string
	Type string
}

type Col

type Col struct {
	Name string
	Type string
}

type Directive

type Directive struct {
	Token  *Token
	Type   DirectiveType
	Values map[string]string
}

type DirectiveType

type DirectiveType string

type Doc

type Doc struct {
	Lines []string
}

type Mode

type Mode string
var (
	ModeExec      Mode = "exec"
	ModeQueryMany Mode = "queryMany"
	ModeQueryRow  Mode = "queryRow"
)

type Query

type Query struct {
	Name     string
	Mode     Mode
	Doc      *Doc
	Args     []*Arg
	Cols     []*Col
	Variants map[string]*Variant
}

type Repository

type Repository struct {
	Name     string
	Queries  []*Query
	Dialects []string
}

type SrcError

type SrcError struct {
	Token *Token
	Inner error
}

func (*SrcError) Error

func (e *SrcError) Error() string

type Token

type Token struct {
	Type     TokenType
	Source   string
	Start    int
	End      int
	Content  []string
	RawLines []string
}

func (*Token) IsDirective

func (t *Token) IsDirective(name DirectiveType) bool

func (*Token) ParseDirective

func (t *Token) ParseDirective() (*Directive, error)

type TokenType

type TokenType string

type Tokenizer

type Tokenizer struct {
	// contains filtered or unexported fields
}

func NewTokenizer

func NewTokenizer(in io.Reader, file string) *Tokenizer

func (*Tokenizer) Next

func (t *Tokenizer) Next() (*Token, error)

type Unit

type Unit struct {
	Repositories      map[string]*Repository
	RepositoriesOrder []string
}

func Parse

func Parse(in io.Reader, file string, logger *slog.Logger) (*Unit, error)

type Variant

type Variant struct {
	Name    string
	Content []string
	Stmt    string
}

Jump to

Keyboard shortcuts

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