Documentation ¶
Index ¶
- Constants
- type ArrayLiteral
- type AssignStatement
- type Base
- type BasicLit
- type Binary
- type BlockStatement
- type BreakContinueStatement
- type Call
- type Code
- type CodeBuilder
- type Conditional
- type Context
- type Cook
- type Delete
- type ElseStatement
- type Exit
- type ExprWrapperStatement
- type Fallback
- type ForStatement
- type Function
- type Ident
- func (id *Ident) Evaluate(ctx Context) (v interface{}, k reflect.Kind, err error)
- func (id *Ident) IsEqual(sn SettableNode) bool
- func (id *Ident) Set(ctx Context, v interface{}, k reflect.Kind, ...) (err error)
- func (id *Ident) String() string
- func (id *Ident) VariableName() string
- func (id *Ident) Visit(cb CodeBuilder)
- type IfStatement
- type IncDec
- type Index
- func (ix *Index) Evaluate(ctx Context) (interface{}, reflect.Kind, error)
- func (ix *Index) IsEqual(sn SettableNode) bool
- func (ix *Index) Set(ctx Context, v interface{}, k reflect.Kind, ...) (err error)
- func (ix *Index) String() string
- func (ix *Index) VariableName() string
- func (ix *Index) Visit(cb CodeBuilder)
- type Interval
- type IsType
- type MapLiteral
- type MergeMap
- type Node
- type Paren
- type ReadFrom
- type RedirectTo
- type ReturnStatement
- type Scope
- type SettableNode
- type SizeOf
- type Statement
- type StringInterpolation
- type StringInterpolationBuilder
- type StringTerminate
- type SubValue
- type Target
- type Targets
- type Transformation
- type TypeCast
- type Unary
Constants ¶
const ( StringTerminateNone StringTerminate = 0 StringTerminateBegin = 1 StringTerminateEnd = 2 StringTerminateBoth = StringTerminateBegin | StringTerminateEnd )
const ( TargetInitialize = "initialize" TargetFinalize = "finalize" TargetAll = "all" )
const ( TransformSlice reflect.Kind = reflect.UnsafePointer + 1000 + iota TransformMap )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayLiteral ¶
A node represent array or list literal
func (*ArrayLiteral) Evaluate ¶
func (al *ArrayLiteral) Evaluate(ctx Context) (v interface{}, k reflect.Kind, err error)
ArrayLiteral Evaluate return value of array or list
func (*ArrayLiteral) String ¶
func (al *ArrayLiteral) String() string
func (*ArrayLiteral) Visit ¶
func (al *ArrayLiteral) Visit(cb CodeBuilder)
type AssignStatement ¶
type AssignStatement struct { *Base Ident SettableNode Op token.Token Value Node }
AssignStatement implement Node and handle all assign operation
func (*AssignStatement) Evaluate ¶
func (as *AssignStatement) Evaluate(ctx Context) (err error)
func (*AssignStatement) String ¶
func (as *AssignStatement) String() string
func (*AssignStatement) Visit ¶
func (as *AssignStatement) Visit(cb CodeBuilder)
type BasicLit ¶
A node represent literal value
func (*BasicLit) Evaluate ¶
BasicLit Evaluate convert a string lit value to it corresponding type value such as integer, float, bool ...etc
func (*BasicLit) Visit ¶
func (bl *BasicLit) Visit(cb CodeBuilder)
type Binary ¶
A node represent binary tree operator
func (*Binary) Visit ¶
func (b *Binary) Visit(cb CodeBuilder)
type BlockStatement ¶
BlockStatement implement Node contain multiple Statement
func (*BlockStatement) Append ¶
func (bs *BlockStatement) Append(stmt Statement)
func (*BlockStatement) Evaluate ¶
func (bs *BlockStatement) Evaluate(ctx Context) (err error)
func (*BlockStatement) String ¶
func (bs *BlockStatement) String() string
func (*BlockStatement) Visit ¶
func (bs *BlockStatement) Visit(cb CodeBuilder)
type BreakContinueStatement ¶
func (*BreakContinueStatement) Evaluate ¶
func (bcs *BreakContinueStatement) Evaluate(ctx Context) error
func (*BreakContinueStatement) String ¶
func (bcs *BreakContinueStatement) String() string
func (*BreakContinueStatement) Visit ¶
func (bcs *BreakContinueStatement) Visit(cb CodeBuilder)
type Call ¶
type Call struct { *Base Kind token.Token Args []Node Name string OutputResult bool FuncLit *Function }
A node represent call expression or statement
func (*Call) Evaluate ¶
Call Evaluate execute one of the following type an external command line, a target or a function
func (*Call) Visit ¶
func (c *Call) Visit(cb CodeBuilder)
type Code ¶
type Code interface { String() string Visit(cb CodeBuilder) }
type CodeBuilder ¶
type CodeBuilder interface { String() string io.Writer io.ByteWriter io.StringWriter WriteRune(r rune) (int, error) WriteIndent() WriteQuoteString(s string, quote byte, stm StringTerminate) GetIdent() int SetIdent(c int) IdentBy(c int) Len() int }
func NewCodeBuilder ¶
func NewCodeBuilder(indent string, formatter bool, maxLength int) CodeBuilder
type Conditional ¶
A node represent short if or ternary expression
func (*Conditional) Evaluate ¶
func (cd *Conditional) Evaluate(ctx Context) (v interface{}, k reflect.Kind, err error)
Conditional Evaluate check the condition boolean result, if the result is true is return result of True expression's evaluation otherwise a result from False expression's evalute is return instread. This expression is known as short if or ternary expression.
func (*Conditional) String ¶
func (cd *Conditional) String() string
func (*Conditional) Visit ¶
func (cd *Conditional) Visit(cb CodeBuilder)
type Context ¶
type Context interface { Scope EnterBlock(forLoop bool, loopLabel string) (Scope, int) ExitBlock(index int) ShouldBreak(fromLoop bool) bool ResetBreakContinue() Break(label string) error Continue(label string) error GetCommand(name string) function.Function GetTarget(name string) *Target GetFunction(name string) *Function }
type Cook ¶
type Delete ¶
type Delete struct { *Base Indexes []Node End Node // if End is not nil, Var must be array and it's delete range. X *Ident }
A node represent delete statement
func (*Delete) Evaluate ¶
Delete Evaluate delete item from array or map. Delete return error if there is an error occorred otherwise the result value is always nil
func (*Delete) Visit ¶
func (d *Delete) Visit(cb CodeBuilder)
type ElseStatement ¶
type ElseStatement struct { *Base IfStmt *IfStatement Insts *BlockStatement }
func (*ElseStatement) Evaluate ¶
func (efst *ElseStatement) Evaluate(ctx Context) error
func (*ElseStatement) String ¶
func (efst *ElseStatement) String() string
func (*ElseStatement) Visit ¶
func (efst *ElseStatement) Visit(cb CodeBuilder)
type Exit ¶
A node represent exit expression statement
func (*Exit) Visit ¶
func (e *Exit) Visit(cb CodeBuilder)
type ExprWrapperStatement ¶
type ExprWrapperStatement struct {
X Node
}
func (*ExprWrapperStatement) ErrPos ¶
func (ews *ExprWrapperStatement) ErrPos() string
func (*ExprWrapperStatement) Evaluate ¶
func (ews *ExprWrapperStatement) Evaluate(ctx Context) (err error)
IncDecExpr Evaluate increase or delete value by 1
func (*ExprWrapperStatement) Position ¶
func (ews *ExprWrapperStatement) Position() token.Position
func (*ExprWrapperStatement) String ¶
func (ews *ExprWrapperStatement) String() string
func (*ExprWrapperStatement) Visit ¶
func (ews *ExprWrapperStatement) Visit(cb CodeBuilder)
type Fallback ¶
A node represent fallback expression
func (*Fallback) Visit ¶
func (fb *Fallback) Visit(cb CodeBuilder)
type ForStatement ¶
type ForStatement struct { *Base Label string I *Ident Value *Ident Oprnd Node // must be map, array or string Range *Interval // {1..2}, (0..3), [1..2]:1 Insts *BlockStatement }
func (*ForStatement) Evaluate ¶
func (fst *ForStatement) Evaluate(ctx Context) error
func (*ForStatement) String ¶
func (fst *ForStatement) String() string
func (*ForStatement) Visit ¶
func (fst *ForStatement) Visit(cb CodeBuilder)
type Function ¶
func (*Function) Visit ¶
func (fn *Function) Visit(cb CodeBuilder)
type Ident ¶
A node represent a variable
func (*Ident) Evaluate ¶
Ident Evaluate read value from current scope always to global scope. If no variable exist, it will look into environment varaible and return it value if founded otherwise a nil and invalid kind is return instead.
func (*Ident) IsEqual ¶
func (id *Ident) IsEqual(sn SettableNode) bool
func (*Ident) VariableName ¶
func (*Ident) Visit ¶
func (id *Ident) Visit(cb CodeBuilder)
type IfStatement ¶
type IfStatement struct { *Base Cond Node Insts *BlockStatement Else *ElseStatement }
func (*IfStatement) Evaluate ¶
func (ifst *IfStatement) Evaluate(ctx Context) error
func (*IfStatement) String ¶
func (ifst *IfStatement) String() string
func (*IfStatement) Visit ¶
func (ifst *IfStatement) Visit(cb CodeBuilder)
type IncDec ¶
A node represent incremenet or decrement expression
func (*IncDec) Visit ¶
func (idc *IncDec) Visit(cb CodeBuilder)
type Index ¶
A node represent index expression
func (*Index) IsEqual ¶
func (ix *Index) IsEqual(sn SettableNode) bool
func (*Index) VariableName ¶
func (*Index) Visit ¶
func (ix *Index) Visit(cb CodeBuilder)
type Interval ¶
A node represent range value
func (*Interval) Evaluate ¶
Range Evaluate return a result of slice of 2 items value if not error occurred during evaluation
func (*Interval) Visit ¶
func (r *Interval) Visit(cb CodeBuilder)
type IsType ¶
A node represent type check expression
func (*IsType) Evaluate ¶
IsType Evaluate return a boolean value. It return true if variable X value is satified the given type Token.
func (*IsType) Visit ¶
func (it *IsType) Visit(cb CodeBuilder)
type MapLiteral ¶
A node represent map literal
func (*MapLiteral) Evaluate ¶
func (ml *MapLiteral) Evaluate(ctx Context) (interface{}, reflect.Kind, error)
MapLiteral Evaluate return value of map or directionary
func (*MapLiteral) String ¶
func (ml *MapLiteral) String() string
func (*MapLiteral) Visit ¶
func (ml *MapLiteral) Visit(cb CodeBuilder)
type MergeMap ¶
type MergeMap struct { *Base Op token.Token // must be < or ? Value Node // either a variable holding map or a map literal }
A new represent map merge operation A += < {...} or A += ? {...}
func (*MergeMap) VariableName ¶
func (*MergeMap) Visit ¶
func (mm *MergeMap) Visit(cb CodeBuilder)
type Paren ¶
A node represent parenthese expression
func (*Paren) Visit ¶
func (p *Paren) Visit(cb CodeBuilder)
type ReadFrom ¶
A node represent redirect read file expression <
func (*ReadFrom) Visit ¶
func (rf *ReadFrom) Visit(cb CodeBuilder)
type RedirectTo ¶
A node represent redirect write to or append to one or more file expression
func (*RedirectTo) Evaluate ¶
func (rt *RedirectTo) Evaluate(ctx Context) (interface{}, reflect.Kind, error)
WriteTo Evaluate write/append the data to the file
func (*RedirectTo) String ¶
func (rt *RedirectTo) String() string
func (*RedirectTo) Visit ¶
func (rt *RedirectTo) Visit(cb CodeBuilder)
type ReturnStatement ¶
A statement represent return expression return
func (*ReturnStatement) Evaluate ¶
func (r *ReturnStatement) Evaluate(ctx Context) error
Return Evaluate return/forward value of a literal value or a value of a variable
func (*ReturnStatement) String ¶
func (rs *ReturnStatement) String() string
func (*ReturnStatement) Visit ¶
func (rs *ReturnStatement) Visit(cb CodeBuilder)
type Scope ¶
type Scope interface { GetVariable(name string) (value interface{}, kind reflect.Kind, fromEnv bool) SetVariable(name string, value interface{}, kind reflect.Kind, bubble func(v interface{}, k reflect.Kind) error) bool SetReturnValue(v interface{}, kind reflect.Kind) GetReturnValue() (v interface{}, kind reflect.Kind) }
type SettableNode ¶
type SizeOf ¶
A node represent size of a variable or literal value expression
func (*SizeOf) Evaluate ¶
SizeOf Evaluate return size of variable or literal value such as string, array, map
func (*SizeOf) Visit ¶
func (sf *SizeOf) Visit(cb CodeBuilder)
type StringInterpolation ¶
type StringInterpolation struct { *Base // contains filtered or unexported fields }
func (*StringInterpolation) Evaluate ¶
func (si *StringInterpolation) Evaluate(ctx Context) (interface{}, reflect.Kind, error)
func (*StringInterpolation) String ¶
func (si *StringInterpolation) String() string
func (*StringInterpolation) Visit ¶
func (si *StringInterpolation) Visit(cb CodeBuilder)
type StringInterpolationBuilder ¶
type StringInterpolationBuilder interface { io.StringWriter AddExpression(node Node) Build(offset int, file *token.File) Node }
func NewStringInterpolationBuilder ¶
func NewStringInterpolationBuilder(mark byte) StringInterpolationBuilder
type StringTerminate ¶
type StringTerminate uint8
type SubValue ¶
A node represent sub value of original value
func (*SubValue) Visit ¶
func (sv *SubValue) Visit(cb CodeBuilder)
type Target ¶
type Target struct { *Base Insts *BlockStatement // contains filtered or unexported fields }
func (*Target) SetCallAll ¶
func (t *Target) SetCallAll()
func (*Target) Visit ¶
func (t *Target) Visit(cb CodeBuilder)
func (*Target) Vist ¶
func (t *Target) Vist(cb CodeBuilder)
type Transformation ¶
type Transformation struct { *Base Ident SettableNode Fn *Function // contains filtered or unexported fields }
A node represent a transform expression
func (*Transformation) Evaluate ¶
func (t *Transformation) Evaluate(ctx Context) (interface{}, reflect.Kind, error)
Transformation Evaluate apply tranform on an array or map
func (*Transformation) String ¶
func (t *Transformation) String() string
func (*Transformation) Visit ¶
func (t *Transformation) Visit(cb CodeBuilder)
type TypeCast ¶
A node represent type cast expression
func (*TypeCast) Evaluate ¶
TypeCast Evaluate return convertible value converted from string to string
func (*TypeCast) Visit ¶
func (tc *TypeCast) Visit(cb CodeBuilder)