flowscript

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2018 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuiltinFunctions = map[string]*ScriptFunction{
	"basename": &ScriptFunction{ScriptFunctionCallBasename, "basename", 1, 2},
	"dirname":  &ScriptFunction{ScriptFunctionCallDirname, "dirname", 1, 1},
	"prefix":   &ScriptFunction{ScriptFunctionCallPrefix, "prefix", 2, 2},
	"zip":      &ScriptFunction{ScriptFunctionCallZip, "zip", 2, 2},
}

Functions

func IsDigit

func IsDigit(ch rune) bool

func IsWhiteSpace

func IsWhiteSpace(ch rune) bool

func IsWordCharacter

func IsWordCharacter(ch rune) bool

func SplitToken

func SplitToken(data []byte, atEOF bool) (advance int, token []byte, err error)

Types

type ArrayAccess

type ArrayAccess struct {
	Array      Evaluable
	ArrayIndex Evaluable
}

func (*ArrayAccess) Evaluate

func (v *ArrayAccess) Evaluate(env Environment) (Value, error)

func (*ArrayAccess) String

func (v *ArrayAccess) String() string

func (*ArrayAccess) SubEvaluable

func (x *ArrayAccess) SubEvaluable() []Evaluable

type ArrayExpression

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

func (*ArrayExpression) Evaluate

func (v *ArrayExpression) Evaluate(env Environment) (Value, error)

func (*ArrayExpression) String

func (v *ArrayExpression) String() string

func (*ArrayExpression) SubEvaluable

func (x *ArrayExpression) SubEvaluable() []Evaluable

type ArrayValue

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

func CreateArrayValue2

func CreateArrayValue2(v1 Value, v2 Value) ArrayValue

func (ArrayValue) AsArray

func (v ArrayValue) AsArray() ([]string, error)

func (ArrayValue) AsInt

func (v ArrayValue) AsInt() (int64, error)

func (ArrayValue) AsRawArray

func (v ArrayValue) AsRawArray() []Value

func (ArrayValue) AsString

func (v ArrayValue) AsString() (string, error)

func (ArrayValue) String

func (v ArrayValue) String() string

func (ArrayValue) Value

func (v ArrayValue) Value() []Value

type AssignExpression

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

func (*AssignExpression) Evaluate

func (v *AssignExpression) Evaluate(env Environment) (Value, error)

func (*AssignExpression) String

func (v *AssignExpression) String() string

func (*AssignExpression) SubEvaluable

func (x *AssignExpression) SubEvaluable() []Evaluable

type BadEvaluable

type BadEvaluable struct{}

func (BadEvaluable) Evaluate

func (x BadEvaluable) Evaluate(env Environment) (Value, error)

func (BadEvaluable) String

func (x BadEvaluable) String() string

func (BadEvaluable) SubEvaluable

func (x BadEvaluable) SubEvaluable() []Evaluable

type Environment

type Environment interface {
	// Get value of variable
	Value(key string) (Value, error)
	Assign(key string, value Value) error
	// Get parent environment
	ParentEnvironment() Environment
}

Environment contains variable values

func CreateMixedEnvironment

func CreateMixedEnvironment(e Environment, m map[string]Value) Environment

func CreateSubEnvironment

func CreateSubEnvironment(e Environment) Environment

func NewGlobalEnvironment

func NewGlobalEnvironment() Environment

type Evaluable

type Evaluable interface {
	Evaluate(env Environment) (Value, error)
	String() string
	SubEvaluable() []Evaluable
}

Evaluable is interface of evaluable blocks

func ParseAsArray

func ParseAsArray(tokenizer *LookAheadScanner) (eval Evaluable, err error)

func ParseAsArrayAccessOrArray

func ParseAsArrayAccessOrArray(tokenizer *LookAheadScanner) (eval Evaluable, err error)

func ParseAsExp

func ParseAsExp(tokenizer *LookAheadScanner) (eval Evaluable, err error)

func ParseAsFactor0

func ParseAsFactor0(tokenizer *LookAheadScanner) (eval Evaluable, err error)

func ParseAsFactor1

func ParseAsFactor1(tokenizer *LookAheadScanner) (eval Evaluable, err error)

func ParseAsFactor2

func ParseAsFactor2(tokenizer *LookAheadScanner) (eval Evaluable, err error)

func ParseAsFactor3

func ParseAsFactor3(tokenizer *LookAheadScanner) (eval Evaluable, err error)

func ParseAsFunctionCall

func ParseAsFunctionCall(tokenizer *LookAheadScanner) (eval Evaluable, err error)

func ParseAsNumber

func ParseAsNumber(tokenizer *LookAheadScanner) (eval Evaluable, err error)

func ParseAsString

func ParseAsString(tokenizer *LookAheadScanner) (eval Evaluable, err error)

func ParseAsVariable

func ParseAsVariable(tokenizer *LookAheadScanner) (eval Evaluable, err error)

func ParseScript

func ParseScript(text string) (Evaluable, error)

type FunctionCall

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

func (*FunctionCall) Evaluate

func (v *FunctionCall) Evaluate(env Environment) (Value, error)

func (*FunctionCall) String

func (v *FunctionCall) String() string

func (*FunctionCall) SubEvaluable

func (x *FunctionCall) SubEvaluable() []Evaluable

type FunctionValue

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

func (FunctionValue) AsInt

func (v FunctionValue) AsInt() (int64, error)

func (FunctionValue) AsString

func (v FunctionValue) AsString() (string, error)

func (FunctionValue) String

func (v FunctionValue) String() string

func (FunctionValue) Value

func (v FunctionValue) Value() *ScriptFunction

type GlobalEnvironment

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

GlobalEnvironment is Global environment container

func (*GlobalEnvironment) Assign

func (ge *GlobalEnvironment) Assign(key string, value Value) error

func (*GlobalEnvironment) ParentEnvironment

func (ge *GlobalEnvironment) ParentEnvironment() Environment

func (*GlobalEnvironment) Value

func (ge *GlobalEnvironment) Value(key string) (Value, error)

Value gets real value from global environment

type IntValue

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

func NewIntValue

func NewIntValue(val int64) IntValue

func (IntValue) AsInt

func (v IntValue) AsInt() (int64, error)

func (IntValue) AsString

func (v IntValue) AsString() (string, error)

func (IntValue) String

func (v IntValue) String() string

func (IntValue) Value

func (v IntValue) Value() int64

type JoinedExpression

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

func (*JoinedExpression) Evaluate

func (v *JoinedExpression) Evaluate(env Environment) (Value, error)

func (*JoinedExpression) String

func (v *JoinedExpression) String() string

func (*JoinedExpression) SubEvaluable

func (x *JoinedExpression) SubEvaluable() []Evaluable

type LookAheadScanner

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

func NewLookAheadScanner

func NewLookAheadScanner(scanner *bufio.Scanner) *LookAheadScanner

func NewTokenizer

func NewTokenizer(r io.Reader) *LookAheadScanner

func NewTokenizerFromText

func NewTokenizerFromText(text string) *LookAheadScanner

func (*LookAheadScanner) Bytes

func (s *LookAheadScanner) Bytes() []byte

func (*LookAheadScanner) Err

func (s *LookAheadScanner) Err() error

func (*LookAheadScanner) LookAheadBytes

func (s *LookAheadScanner) LookAheadBytes(i int) []byte

func (*LookAheadScanner) LookAheadText

func (s *LookAheadScanner) LookAheadText(i int) string

func (*LookAheadScanner) Scan

func (s *LookAheadScanner) Scan() bool

func (*LookAheadScanner) Text

func (s *LookAheadScanner) Text() string

type MapValue

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

func (MapValue) AsInt

func (v MapValue) AsInt() (int64, error)

func (MapValue) AsString

func (v MapValue) AsString() (string, error)

func (MapValue) String

func (v MapValue) String() string

func (MapValue) Value

func (v MapValue) Value() map[string]Value

type NumericOperationExpression

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

func (*NumericOperationExpression) Evaluate

func (v *NumericOperationExpression) Evaluate(env Environment) (Value, error)

func (*NumericOperationExpression) String

func (v *NumericOperationExpression) String() string

func (*NumericOperationExpression) SubEvaluable

func (x *NumericOperationExpression) SubEvaluable() []Evaluable

type PlusExpression

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

func (*PlusExpression) Evaluate

func (v *PlusExpression) Evaluate(env Environment) (Value, error)

func (*PlusExpression) String

func (v *PlusExpression) String() string

func (*PlusExpression) SubEvaluable

func (x *PlusExpression) SubEvaluable() []Evaluable

type RuneCheck

type RuneCheck func(ch rune) (match bool)

type ScriptFunction

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

func (ScriptFunction) String

func (s ScriptFunction) String() string

type ScriptFunctionCall

type ScriptFunctionCall func(args []Value) (Value, error)

type StringSet

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

func NewStringSet

func NewStringSet() StringSet

func NewStringSetWithValues

func NewStringSetWithValues(values ...string) StringSet

func SearchCreatedVariables

func SearchCreatedVariables(evaluable Evaluable) StringSet

func SearchDependentVariables

func SearchDependentVariables(evaluable Evaluable) StringSet

func (StringSet) Add

func (v StringSet) Add(s string)

func (StringSet) AddAll

func (v StringSet) AddAll(s StringSet)

func (StringSet) Array

func (v StringSet) Array() []string

func (StringSet) Contains

func (v StringSet) Contains(s string) bool

func (StringSet) Intersect

func (v StringSet) Intersect(x StringSet) StringSet

func (StringSet) MarshalJSON

func (v StringSet) MarshalJSON() ([]byte, error)

func (StringSet) Remove

func (v StringSet) Remove(s string)

func (StringSet) Size

func (v StringSet) Size() int

func (*StringSet) UnmarshalJSON

func (v *StringSet) UnmarshalJSON(data []byte) error

type StringValue

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

func NewStringValue

func NewStringValue(str string) StringValue

func (StringValue) AsInt

func (v StringValue) AsInt() (int64, error)

func (StringValue) AsString

func (v StringValue) AsString() (string, error)

func (StringValue) String

func (v StringValue) String() string

func (StringValue) Value

func (v StringValue) Value() string

type SubEnvironment

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

func (*SubEnvironment) Assign

func (se *SubEnvironment) Assign(key string, value Value) error

func (*SubEnvironment) ParentEnvironment

func (se *SubEnvironment) ParentEnvironment() Environment

func (*SubEnvironment) Value

func (se *SubEnvironment) Value(key string) (Value, error)

type Value

type Value interface {
	// String representation of value for debug
	String() string
	// Convert to string to embed
	AsString() (string, error)
	// Convert to int
	AsInt() (int64, error)
}

Value representation in flowscript

func EvaluateScript

func EvaluateScript(text string, env Environment) (Value, error)

func ScriptFunctionCallBasename

func ScriptFunctionCallBasename(args []Value) (Value, error)

func ScriptFunctionCallDirname

func ScriptFunctionCallDirname(args []Value) (Value, error)

func ScriptFunctionCallPrefix

func ScriptFunctionCallPrefix(args []Value) (Value, error)

func ScriptFunctionCallZip

func ScriptFunctionCallZip(args []Value) (Value, error)

type ValueEvaluable

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

func (ValueEvaluable) Evaluate

func (x ValueEvaluable) Evaluate(env Environment) (Value, error)

func (ValueEvaluable) String

func (x ValueEvaluable) String() string

func (ValueEvaluable) SubEvaluable

func (x ValueEvaluable) SubEvaluable() []Evaluable

type Variable

type Variable struct {
	Name string
}

Variable is one of Evaluable value

func (*Variable) Evaluate

func (v *Variable) Evaluate(env Environment) (Value, error)

Evaluate variable and get value

func (*Variable) String

func (v *Variable) String() string

func (Variable) SubEvaluable

func (x Variable) SubEvaluable() []Evaluable

Jump to

Keyboard shortcuts

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