ast

package
v0.0.0-...-6ae0033 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var False = Bool{Value: false}
View Source
var True = Bool{Value: true}

Functions

This section is empty.

Types

type ASTMarshaler

type ASTMarshaler interface {
	MarshalJSON() ([]byte, error)
}

type Access

type Access struct {
	Name Ident
	Key  interface{}
	Meta Meta
}

func NewAccess

func NewAccess(i Ident, key interface{}) (Access, error)

func (Access) Exec

func (a Access) Exec(c *Context) (interface{}, error)

func (Access) Format

func (a Access) Format(st fmt.State, verb rune)

func (Access) MarshalJSON

func (a Access) MarshalJSON() ([]byte, error)

func (Access) String

func (a Access) String() string

type Array

type Array struct {
	Value []interface{}
	Meta  Meta
}

func NewArray

func NewArray(ii []interface{}) (Array, error)

func (Array) Bool

func (a Array) Bool(c *Context) (bool, error)

func (Array) Exec

func (a Array) Exec(c *Context) (interface{}, error)

func (Array) Format

func (s Array) Format(st fmt.State, verb rune)

func (Array) GoString

func (a Array) GoString() string

func (Array) Interface

func (a Array) Interface() interface{}

func (Array) Len

func (a Array) Len() int

func (Array) Less

func (a Array) Less(i, j int) bool

func (Array) LushString

func (a Array) LushString() string

func (Array) MarshalJSON

func (a Array) MarshalJSON() ([]byte, error)

func (Array) Slice

func (a Array) Slice() []interface{}

func (Array) String

func (a Array) String() string

func (Array) Swap

func (a Array) Swap(i, j int)

type Assign

type Assign struct {
	Name  Node
	Value Node
	Meta  Meta
}

func NewAssign

func NewAssign(name Node, value Node) (*Assign, error)

func (*Assign) Exec

func (l *Assign) Exec(c *Context) (interface{}, error)

func (Assign) Format

func (a Assign) Format(st fmt.State, verb rune)

func (Assign) MarshalJSON

func (a Assign) MarshalJSON() ([]byte, error)

func (Assign) String

func (l Assign) String() string

type Block

type Block struct {
	Nodes
	Meta Meta
}

func NewBlock

func NewBlock(stmts ...Node) (*Block, error)

func (Block) Format

func (a Block) Format(st fmt.State, verb rune)

func (Block) MarshalJSON

func (a Block) MarshalJSON() ([]byte, error)

func (Block) String

func (b Block) String() string

type Bool

type Bool struct {
	Value bool
	Meta  Meta
}

func NewBool

func NewBool(b []byte) (Bool, error)

func (Bool) Bool

func (b Bool) Bool(c *Context) (bool, error)

func (Bool) Exec

func (b Bool) Exec(c *Context) (interface{}, error)

func (Bool) Format

func (a Bool) Format(st fmt.State, verb rune)

func (Bool) Interface

func (b Bool) Interface() interface{}

func (Bool) MarshalJSON

func (a Bool) MarshalJSON() ([]byte, error)

func (Bool) String

func (b Bool) String() string

type Boolable

type Boolable interface {
	Bool(*Context) (bool, error)
}

type Break

type Break struct {
	Meta Meta
}

func (Break) Format

func (a Break) Format(st fmt.State, verb rune)

func (Break) MarshalJSON

func (a Break) MarshalJSON() ([]byte, error)

func (Break) String

func (Break) String() string

type Call

type Call struct {
	Name      Node
	FName     Ident
	Arguments Nodes
	Block     *Block
	Meta      Meta
}

func NewCall

func NewCall(n Node, y interface{}, args Nodes, b *Block) (Call, error)

func (Call) Exec

func (f Call) Exec(c *Context) (interface{}, error)

func (Call) Format

func (f Call) Format(st fmt.State, verb rune)

func (Call) MarshalJSON

func (f Call) MarshalJSON() ([]byte, error)

func (Call) String

func (f Call) String() string

type Comment

type Comment struct {
	Value string
	Meta  Meta
}

func NewComment

func NewComment(b []byte) (Comment, error)

func (Comment) Format

func (a Comment) Format(st fmt.State, verb rune)

func (Comment) MarshalJSON

func (a Comment) MarshalJSON() ([]byte, error)

func (Comment) String

func (c Comment) String() string

type Context

type Context struct {
	context.Context
	io.Writer
	Block *Block

	Imports sync.Map
	// contains filtered or unexported fields
}

func NewContext

func NewContext(ctx context.Context, w io.Writer) *Context

func (*Context) Clone

func (c *Context) Clone() *Context

func (*Context) Has

func (c *Context) Has(key string) bool

func (*Context) Set

func (c *Context) Set(key string, value interface{})

func (*Context) Value

func (f *Context) Value(key interface{}) interface{}

type Continue

type Continue struct {
	Meta Meta
}

func (Continue) Format

func (a Continue) Format(st fmt.State, verb rune)

func (Continue) MarshalJSON

func (a Continue) MarshalJSON() ([]byte, error)

func (Continue) String

func (Continue) String() string

type Current

type Current struct {
	Meta Meta
}

func (Current) Exec

func (Current) Exec(c *Context) (interface{}, error)

func (Current) Format

func (c Current) Format(st fmt.State, verb rune)

func (Current) String

func (Current) String() string

type Else

type Else struct {
	Block *Block
	Meta  Meta
}

func NewElse

func NewElse(b *Block) (Else, error)

func (Else) Bool

func (i Else) Bool(c *Context) (bool, error)

func (Else) Exec

func (i Else) Exec(c *Context) (interface{}, error)

func (Else) Format

func (i Else) Format(st fmt.State, verb rune)

func (Else) GoString

func (i Else) GoString() string

func (Else) MarshalJSON

func (i Else) MarshalJSON() ([]byte, error)

func (Else) String

func (i Else) String() string

type ElseIf

type ElseIf struct {
	If
}

func NewElseIf

func NewElseIf(fi If) (ElseIf, error)

func (ElseIf) Format

func (e ElseIf) Format(st fmt.State, verb rune)

func (ElseIf) GoString

func (e ElseIf) GoString() string

func (ElseIf) MarshalJSON

func (e ElseIf) MarshalJSON() ([]byte, error)

func (ElseIf) String

func (e ElseIf) String() string

type Execable

type Execable interface {
	Exec(*Context) (interface{}, error)
}

type ExecableNode

type ExecableNode interface {
	Execable
	Node
}

type Expression

type Expression interface {
	Node
	Bool(c *Context) (bool, error)
}

type Float

type Float struct {
	Value float64
	Meta  Meta
}

func NewFloat

func NewFloat(f float64) (Float, error)

func (Float) Exec

func (n Float) Exec(c *Context) (interface{}, error)

func (Float) Float

func (d Float) Float() float64

func (Float) Format

func (n Float) Format(st fmt.State, verb rune)

func (Float) Interface

func (d Float) Interface() interface{}

func (Float) MarshalJSON

func (n Float) MarshalJSON() ([]byte, error)

func (Float) String

func (n Float) String() string

type For

type For struct {
	Name  ExecableNode
	Args  Idents
	Block *Block
	Meta  Meta
	// contains filtered or unexported fields
}

func NewFor

func NewFor(n ExecableNode, args interface{}, b *Block) (For, error)

func (For) Exec

func (f For) Exec(c *Context) (interface{}, error)

func (For) Format

func (f For) Format(st fmt.State, verb rune)

func (For) GoString

func (f For) GoString() string

func (For) MarshalJSON

func (f For) MarshalJSON() ([]byte, error)

func (For) String

func (f For) String() string

type Func

type Func struct {
	Arguments Idents
	Block     *Block
	Meta      Meta
}

func NewFunc

func NewFunc(ax interface{}, b *Block) (Func, error)

func (Func) Format

func (f Func) Format(st fmt.State, verb rune)

func (Func) GoString

func (f Func) GoString() string

func (Func) MarshalJSON

func (f Func) MarshalJSON() ([]byte, error)

func (Func) String

func (f Func) String() string

type Goroutine

type Goroutine struct {
	Call Call
}

func NewGoroutine

func NewGoroutine(c Call) (Goroutine, error)

func (Goroutine) Exec

func (g Goroutine) Exec(c *Context) (interface{}, error)

func (Goroutine) Format

func (g Goroutine) Format(st fmt.State, verb rune)

func (Goroutine) MarshalJSON

func (g Goroutine) MarshalJSON() ([]byte, error)

func (Goroutine) String

func (g Goroutine) String() string

type Ident

type Ident struct {
	Name string
	Meta Meta
}

func NewIdent

func NewIdent(b []byte) (Ident, error)

func (Ident) Bool

func (i Ident) Bool(c *Context) (bool, error)

func (Ident) Exec

func (i Ident) Exec(c *Context) (interface{}, error)

func (Ident) Format

func (a Ident) Format(st fmt.State, verb rune)

func (Ident) IsZero

func (i Ident) IsZero() bool

func (Ident) MapKey

func (i Ident) MapKey() string

func (Ident) MarshalJSON

func (a Ident) MarshalJSON() ([]byte, error)

func (Ident) String

func (i Ident) String() string

type Idents

type Idents []Ident

func (Idents) String

func (ids Idents) String() string

type If

type If struct {
	PreCondition Node
	Expression   Expression
	Clause       Node
	Block        *Block
	Meta         Meta
}

func NewIf

func NewIf(p Node, e Expression, b *Block, elsa Node) (If, error)

func (If) Bool

func (i If) Bool(c *Context) (bool, error)

func (If) Exec

func (i If) Exec(c *Context) (interface{}, error)

func (If) Format

func (i If) Format(st fmt.State, verb rune)

func (If) GoString

func (i If) GoString() string

func (If) MarshalJSON

func (i If) MarshalJSON() ([]byte, error)

func (If) String

func (i If) String() string

type Import

type Import struct {
	Name string
	Meta Meta
}

func NewImport

func NewImport(s string) (Import, error)

func (Import) Exec

func (i Import) Exec(c *Context) (interface{}, error)

func (Import) Format

func (i Import) Format(st fmt.State, verb rune)

func (Import) MarshalJSON

func (i Import) MarshalJSON() ([]byte, error)

func (Import) String

func (i Import) String() string

type Integer

type Integer struct {
	Value int
	Meta  Meta
}

func NewInteger

func NewInteger(i int) (Integer, error)

func (Integer) Bool

func (d Integer) Bool(c *Context) (bool, error)

func (Integer) Exec

func (d Integer) Exec(c *Context) (interface{}, error)

func (Integer) Format

func (a Integer) Format(st fmt.State, verb rune)

func (Integer) GoString

func (a Integer) GoString() string

func (Integer) Int

func (d Integer) Int() int

func (Integer) Interface

func (d Integer) Interface() interface{}

func (Integer) MarshalJSON

func (a Integer) MarshalJSON() ([]byte, error)

func (Integer) String

func (d Integer) String() string

type Iterator

type Iterator interface {
	Next() interface{}
}

Iterator type can be implemented and used by the `for` command to build loops in templates

type Let

type Let struct {
	Name  Ident
	Value Node
	Meta  Meta
}

func NewLet

func NewLet(name Ident, value Node) (*Let, error)

func (*Let) Exec

func (l *Let) Exec(c *Context) (interface{}, error)

func (Let) Format

func (l Let) Format(st fmt.State, verb rune)

func (Let) GoString

func (l Let) GoString() string

func (Let) MarshalJSON

func (l Let) MarshalJSON() ([]byte, error)

func (Let) String

func (l Let) String() string

type LushStringer

type LushStringer interface {
	LushString() string
}

LushStringer is implemented by any value that has a LushString method, which defines the Lush syntax for that value. The LushString method is used to print values passed as an operand to a %*v format.

type Map

type Map struct {
	Values map[string]interface{}
	Meta   Meta
}

func NewMap

func NewMap(vals interface{}) (Map, error)

func (Map) Bool

func (m Map) Bool(c *Context) (bool, error)

func (Map) Exec

func (m Map) Exec(c *Context) (interface{}, error)

func (Map) Format

func (a Map) Format(st fmt.State, verb rune)

func (Map) GoString

func (m Map) GoString() string

func (Map) Interface

func (m Map) Interface() interface{}

func (Map) Map

func (m Map) Map() map[string]interface{}

func (Map) MarshalJSON

func (m Map) MarshalJSON() ([]byte, error)

func (Map) String

func (m Map) String() string

type Meta

type Meta struct {
	Filename string
	Line     int
	Col      int
	Offset   int
	Original string
}

func (Meta) Errorf

func (m Meta) Errorf(format string, args ...interface{}) error

func (Meta) Format

func (a Meta) Format(st fmt.State, verb rune)

func (Meta) MarshalJSON

func (a Meta) MarshalJSON() ([]byte, error)

func (Meta) String

func (m Meta) String() string

func (Meta) Wrap

func (m Meta) Wrap(err error) error

type Nil

type Nil struct {
	Meta Meta
}

func (Nil) Bool

func (i Nil) Bool(c *Context) (bool, error)

func (Nil) Exec

func (i Nil) Exec(c *Context) (interface{}, error)

func (Nil) Format

func (a Nil) Format(st fmt.State, verb rune)

func (Nil) Interface

func (i Nil) Interface() interface{}

func (Nil) IsZero

func (i Nil) IsZero() bool

func (Nil) MarshalJSON

func (a Nil) MarshalJSON() ([]byte, error)

func (Nil) String

func (i Nil) String() string

type Node

type Node interface {
	fmt.Stringer
}

type Nodes

type Nodes []Node

func NewNodes

func NewNodes(i interface{}) (Nodes, error)

func (*Nodes) Append

func (t *Nodes) Append(s Node, err error) error

func (Nodes) Exec

func (st Nodes) Exec(c *Context) (interface{}, error)

func (Nodes) Format

func (i Nodes) Format(st fmt.State, verb rune)

func (Nodes) MarshalJSON

func (st Nodes) MarshalJSON() ([]byte, error)

func (Nodes) String

func (t Nodes) String() string

type Noop

type Noop struct {
	Text string
	Meta Meta
}

func NewNoop

func NewNoop(b []byte) (Noop, error)

func (Noop) Format

func (n Noop) Format(st fmt.State, verb rune)

func (Noop) MarshalJSON

func (n Noop) MarshalJSON() ([]byte, error)

func (Noop) String

func (n Noop) String() string

type OpExpression

type OpExpression struct {
	A    Node
	B    Node
	Op   string
	Meta Meta
	// contains filtered or unexported fields
}

func NewOpExpression

func NewOpExpression(a Node, op string, b Node) (*OpExpression, error)

func NewPopExpression

func NewPopExpression(a Node, op string, b Node) (*OpExpression, error)

func (OpExpression) Add

func (e OpExpression) Add(c *Context) (interface{}, error)

func (OpExpression) And

func (e OpExpression) And(c *Context) (bool, error)

func (OpExpression) Bool

func (e OpExpression) Bool(c *Context) (bool, error)

func (OpExpression) Divide

func (e OpExpression) Divide(c *Context) (interface{}, error)

func (OpExpression) Exec

func (e OpExpression) Exec(c *Context) (interface{}, error)

func (OpExpression) Format

func (e OpExpression) Format(st fmt.State, verb rune)

func (OpExpression) MarshalJSON

func (e OpExpression) MarshalJSON() ([]byte, error)

func (OpExpression) Modulus

func (e OpExpression) Modulus(c *Context) (interface{}, error)

func (OpExpression) Multiply

func (e OpExpression) Multiply(c *Context) (interface{}, error)

func (OpExpression) Or

func (e OpExpression) Or(c *Context) (bool, error)

func (OpExpression) String

func (e OpExpression) String() string

func (OpExpression) Sub

func (e OpExpression) Sub(c *Context) (interface{}, error)

type Range

type Range struct {
	For
	Meta Meta
}

func NewRange

func NewRange(n ExecableNode, args interface{}, b *Block) (Range, error)

func (Range) Format

func (f Range) Format(st fmt.State, verb rune)

func (Range) GoString

func (f Range) GoString() string

func (Range) MarshalJSON

func (f Range) MarshalJSON() ([]byte, error)

func (Range) String

func (f Range) String() string

type Return

type Return struct {
	Nodes Nodes
	Meta  Meta
}

func NewReturn

func NewReturn(s Nodes) (Return, error)

func (Return) Exec

func (r Return) Exec(c *Context) (interface{}, error)

func (Return) Format

func (r Return) Format(st fmt.State, verb rune)

func (Return) MarshalJSON

func (r Return) MarshalJSON() ([]byte, error)

func (Return) String

func (r Return) String() string

type Returned

type Returned struct {
	Value interface{}
	// contains filtered or unexported fields
}

func NewReturned

func NewReturned(i interface{}) (ret Returned)

func (Returned) Err

func (r Returned) Err() error

func (Returned) String

func (r Returned) String() string

type Script

type Script struct {
	Nodes Nodes
}

func (Script) Exec

func (s Script) Exec(c *Context) (*Returned, error)

func (Script) Format

func (a Script) Format(st fmt.State, verb rune)

func (Script) MarshalJSON

func (a Script) MarshalJSON() ([]byte, error)

func (Script) String

func (s Script) String() string

type Shebang

type Shebang struct {
	Value string
	Meta  Meta
}

func NewShebang

func NewShebang(b []byte) (Shebang, error)

func (Shebang) Format

func (a Shebang) Format(st fmt.State, verb rune)

func (Shebang) MarshalJSON

func (a Shebang) MarshalJSON() ([]byte, error)

func (Shebang) String

func (c Shebang) String() string

type String

type String struct {
	Original    string
	QuoteFormat string
	Meta        Meta
}

func NewString

func NewString(b []byte) (String, error)

func (String) Bool

func (s String) Bool(c *Context) (bool, error)

func (String) Exec

func (s String) Exec(c *Context) (interface{}, error)

func (String) Format

func (a String) Format(st fmt.State, verb rune)

func (String) Interface

func (s String) Interface() interface{}

func (String) MapKey

func (s String) MapKey() string

func (String) MarshalJSON

func (a String) MarshalJSON() ([]byte, error)

func (String) String

func (s String) String() string

type Var

type Var struct {
	Name  Ident
	Value Node
	Meta  Meta
}

func NewVar

func NewVar(name Ident, value Node) (*Var, error)

func (*Var) Exec

func (l *Var) Exec(c *Context) (interface{}, error)

func (Var) Format

func (l Var) Format(st fmt.State, verb rune)

func (Var) GoString

func (l Var) GoString() string

func (Var) MarshalJSON

func (l Var) MarshalJSON() ([]byte, error)

func (Var) String

func (l Var) String() string

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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