ast

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LangVelty = "velty"
	LangGO    = "go"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Assign

type Assign struct {
	Holder       Expression
	ExtraHolders []Expression
	Expression   Expression
}

func NewAssign

func NewAssign(holder Expression, expr Expression) *Assign

func (*Assign) Generate

func (s *Assign) Generate(builder *Builder) (err error)

type BinaryExpr

type BinaryExpr struct {
	X  Expression
	Op string
	Y  Expression
}

func NewBinary

func NewBinary(x Expression, op string, y Expression) *BinaryExpr

func (*BinaryExpr) Generate

func (s *BinaryExpr) Generate(builder *Builder) (err error)

type Block

type Block []Statement

func (*Block) Append

func (b *Block) Append(statement Statement)

func (*Block) AppendEmptyLine

func (b *Block) AppendEmptyLine()

func (Block) Generate

func (b Block) Generate(builder *Builder) error

type Builder

type Builder struct {
	*strings.Builder
	Options
	Indent string
	State  *Scope

	IndexByCode *Builder
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder(option Options, declaredVariables ...string) *Builder

func (*Builder) IncIndent

func (b *Builder) IncIndent(indent string) *Builder

func (*Builder) NewBuilder added in v0.10.0

func (b *Builder) NewBuilder() *Builder

func (*Builder) WriteIndentedString

func (b *Builder) WriteIndentedString(s string) error

func (*Builder) WriteString

func (b *Builder) WriteString(s string) error

type CallExpr

type CallExpr struct {
	Terminator bool
	Receiver   Expression
	Name       string
	Args       []Expression
}

func NewCallExpr

func NewCallExpr(holder Expression, name string, args ...Expression) *CallExpr

func (*CallExpr) Generate

func (e *CallExpr) Generate(builder *Builder) (err error)

type Condition

type Condition struct {
	If           Expression
	IFBlock      Block
	ElseIfBlocks []*ConditionalBlock
	ElseBlock    Block
}

func NewCondition

func NewCondition(ifExpr Expression, ifBlock, elseBlock Block) *Condition

func (*Condition) Generate

func (s *Condition) Generate(builder *Builder) (err error)

type ConditionalBlock

type ConditionalBlock struct {
	If    Expression
	Block Block
}

type DerefExpression

type DerefExpression struct {
	X Expression
}

func NewDerefExpression

func NewDerefExpression(x Expression) *DerefExpression

func (*DerefExpression) Generate

func (s *DerefExpression) Generate(builder *Builder) error

type ErrorCheck

type ErrorCheck struct {
	X Expression
}

func NewErrorCheck

func NewErrorCheck(expr Expression) *ErrorCheck

func (*ErrorCheck) Generate

func (e *ErrorCheck) Generate(builder *Builder) error

type Expression

type Expression interface {
	Node

} //can be BinaryExpr or CallExpr or QuerySelector Expr

type Foreach

type Foreach struct {
	Value *Ident
	Set   *Ident
	Body  Block
}

func NewForEach

func NewForEach(value, set *Ident, body Block) *Foreach

func (*Foreach) Generate

func (s *Foreach) Generate(builder *Builder) (err error)

type FuncArg

type FuncArg struct {
	Name  string
	Ident *Ident
}

func (*FuncArg) Generate

func (a *FuncArg) Generate(builder *Builder) error

type Function

type Function struct {
	Receiver *Receiver
	Name     string
	ArgsIn   []*FuncArg
	ArgsOut  []string
	Body     Block
	Return   *ReturnExpr
}

func (*Function) Generate

func (f *Function) Generate(builder *Builder) error

type Ident

type Ident struct {
	Holder string
	Name   string
}

func NewHolderIndent added in v0.10.0

func NewHolderIndent(holder, name string) *Ident

func NewIdent

func NewIdent(name string) *Ident

func (Ident) Generate

func (e Ident) Generate(builder *Builder) (err error)

type Insert

type Insert struct {
	Table   string
	Columns []string
	Fields  []string
}

func (*Insert) Generate

func (s *Insert) Generate(builder *Builder) (err error)

type LiteralExpr

type LiteralExpr struct {
	Literal string
}

func NewLiteral

func NewLiteral(text string) *LiteralExpr

func NewQuotedLiteral

func NewQuotedLiteral(text string) *LiteralExpr

func (*LiteralExpr) Generate

func (s *LiteralExpr) Generate(builder *Builder) error

type MapExpr

type MapExpr struct {
	Map Expression
	Key Expression
}

func (*MapExpr) Generate

func (m *MapExpr) Generate(builder *Builder) error

type Node

type Node interface {
	Generate(builder *Builder) error
}

type Options

type Options struct {
	Lang                 string
	StateName            string
	CallNotifier         func(callExpr *CallExpr) (Expression, error)
	AssignNotifier       func(assign *Assign) (Expression, error)
	SliceItemNotifier    func(value, set *Ident) error
	WithoutBusinessLogic bool
	OnIfNotifier         func(value *Condition) (Expression, error)
	WithLowerCaseIdent   bool
}

type Receiver

type Receiver struct {
	Name  string
	Ident *Ident
}

func (*Receiver) Generate

func (r *Receiver) Generate(builder *Builder) error

type RefExpression

type RefExpression struct {
	X Expression
}

func NewRefExpression

func NewRefExpression(x Expression) *RefExpression

func (*RefExpression) Generate

func (s *RefExpression) Generate(builder *Builder) error

type ReturnExpr

type ReturnExpr struct {
	X Expression
}

func NewReturnExpr

func NewReturnExpr(expr Expression) *ReturnExpr

func (*ReturnExpr) Generate

func (r *ReturnExpr) Generate(builder *Builder) error

type Scope

type Scope struct {
	Variables map[string]*Variable
	Parent    *Scope
}

func NewScope

func NewScope(declaredVariables ...string) *Scope

func (*Scope) DeclareVariable

func (s *Scope) DeclareVariable(variable string)

func (*Scope) IsDeclared

func (s *Scope) IsDeclared(variable string) bool

func (*Scope) NextScope

func (s *Scope) NextScope() *Scope

type SelectorExpr

type SelectorExpr struct {
	Ident
	X *SelectorExpr
}

func (*SelectorExpr) Generate

func (s *SelectorExpr) Generate(builder *Builder) error

type Statement

type Statement interface {
	Node
}

type StatementExpression

type StatementExpression struct {
	Expression
}

func NewStatementExpression

func NewStatementExpression(expr Expression) *StatementExpression

NewStatementExpression return new statement expr

func (*StatementExpression) Generate

func (s *StatementExpression) Generate(builder *Builder) (err error)

type TerminatorExpression

type TerminatorExpression struct {
	X Expression
}

func NewTerminatorExpression

func NewTerminatorExpression(x Expression) *TerminatorExpression

func (TerminatorExpression) Generate

func (b TerminatorExpression) Generate(builder *Builder) error

type Update

type Update struct {
	Table     string
	Columns   []string
	Fields    []string
	PkColumns []string
	PkFields  []string
}

func (*Update) Generate

func (s *Update) Generate(builder *Builder) (err error)

type Variable

type Variable struct {
	Name string
}

Jump to

Keyboard shortcuts

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