Documentation ¶
Index ¶
- Variables
- func EvalToGoValue(script Script, env *ScriptEnvironment) (interface{}, error)
- func ExpectApplyAtom(s Script) *apply
- func ExpectBoolAtom(s Script) bool
- func ExpectDict(s Script) map[string]interface{}
- func ExpectDictAtom(s Script) map[string]Script
- func ExpectFunctionAtom(s Script) scriptFuncType
- func ExpectIntegerAtom(s Script) int
- func ExpectLambdaAtom(v Script) *lambda
- func ExpectStringAtom(s Script) string
- func IsApplyAtom(s Script) bool
- func IsBoolAtom(s Script) (ok bool)
- func IsDictAtom(s Script) bool
- func IsFunctionAtom(s Script) bool
- func IsIntegerAtom(s Script) (ok bool)
- func IsLambdaAtom(v Script) bool
- func IsListAtom(s Script) (ok bool)
- func IsStringAtom(s Script) (ok bool)
- func ParseAndEvalToGoValue(scriptStr string, env *ScriptEnvironment) (interface{}, error)
- func ParseAndEvalToString(scriptStr string, env *ScriptEnvironment) (string, error)
- type Function
- type Script
- func ExpectListAtom(s Script) []Script
- func Lift(val interface{}) (Script, error)
- func LiftBool(b bool) Script
- func LiftDict(d map[string]Script) Script
- func LiftFunction(f scriptFuncType) Script
- func LiftGoFunc(f interface{}) Script
- func LiftInteger(i int) Script
- func LiftList(l []Script) Script
- func LiftString(s string) Script
- func NewApply(to Script, args []Script) Script
- func NewLambda(args []string, body Script) Script
- func ParseScript(str string) (Script, error)
- func ShouldLift(v interface{}) Script
- func ShouldParse(str string) Script
- type ScriptEnvironment
- type StdlibFunc
- type ValueType
Constants ¶
This section is empty.
Variables ¶
View Source
var Stdlib = []StdlibFunc{ StdlibFunc{"id", LiftFunction(builtinId), "Returns its argument", "everything", "parameter :: *"}, StdlibFunc{"equals", LiftFunction(builtinEquals), "Returns true if the arguments are of the same type and have the same value", "everything", "parameter :: *"}, StdlibFunc{"env_lookup", LiftFunction(builtinEnvLookup), "Lookup key in environment. Usually called implicitly when using '$'", "lists", "key :: string"}, StdlibFunc{"concat", LiftFunction(builtinConcat), "Concatate stringable arguments", "strings", "v1 :: string, v2 :: string, ..."}, StdlibFunc{"lower", ShouldLift(strings.ToLower), "Returns a copy of the string v with all Unicode characters mapped to their lower case", "strings", "v :: string"}, StdlibFunc{"upper", ShouldLift(strings.ToUpper), "Returns a copy of the string v with all Unicode characters mapped to their upper case", "strings", "v :: string"}, StdlibFunc{"title", ShouldLift(strings.ToTitle), "Returns a copy of the string v with all Unicode characters mapped to their title case", "strings", "v :: string"}, StdlibFunc{"split", ShouldLift(strings.Split), "Split slices s into all substrings separated by sep and returns a slice of the substrings between those separators. If sep is empty, Split splits after each UTF-8 sequence.", "strings", "sep :: string"}, StdlibFunc{"path_exists", ShouldLift(util.PathExists), "Returns true if the path exists, false if not", "strings", ""}, StdlibFunc{"file_exists", ShouldLift(util.FileExists), "Returns true if the path exists and if it's not a directory, false otherwise", "strings", ""}, StdlibFunc{"dir_exists", ShouldLift(util.IsDir), "Returns true if the path exists and if it is a directory, false otherwise", "strings", ""}, StdlibFunc{"join", ShouldLift(strings.Join), "Join concatenates the elements of a to create a single string. The separator string sep is placed between elements in the resulting string. ", "lists", "sep :: string"}, StdlibFunc{"replace", ShouldLift(strings.Replace), "Replace returns a copy of the string s with the first n non-overlapping instances of old replaced by new. If old is empty, it matches at the beginning of the string and after each UTF-8 sequence, yielding up to k+1 replacements for a k-rune string. If n < 0, there is no limit on the number of replacements.", "strings", "old :: string, new :: string, n :: integer"}, StdlibFunc{"base64_encode", ShouldLift(base64.StdEncoding.EncodeToString), "Encode string to base64", "strings", ""}, StdlibFunc{"base64_decode", ShouldLift(base64.StdEncoding.DecodeString), "Decode string from base64", "strings", ""}, StdlibFunc{"trim", ShouldLift(strings.TrimSpace), "Returns a slice of the string s, with all leading and trailing white space removed, as defined by Unicode. ", "strings", ""}, StdlibFunc{"list_index", LiftFunction(builtinListIndex), "Index a list at position `n`. Usually accessed implicitly using indexing syntax (eg. `list[0]`)", "lists", "n :: integer"}, StdlibFunc{"length", LiftFunction(builtinListLength), "Returns the length of the list", "lists", "n :: integer"}, StdlibFunc{"list_slice", LiftFunction(builtinListSlice), "Slice a list. Usually accessed implicitly using slice syntax (eg. `list[0:5]`)", "lists", "i :: integer, j :: integer"}, StdlibFunc{"add", ShouldLift(builtinAdd), "Add two integers", "integers", "y :: integer"}, StdlibFunc{"timestamp", ShouldLift(builtinTimestamp), "Returns a UNIX timestamp", "", ""}, StdlibFunc{"read_file", ShouldLift(builtinReadfile), "Read the contents of a file", "strings", ""}, StdlibFunc{"track_major_version", trackMajorVersion, "Track major version", "strings", ""}, StdlibFunc{"track_minor_version", trackMinorVersion, "Track minor version", "strings", ""}, StdlibFunc{"track_patch_version", trackPatchVersion, "Track patch version", "strings", ""}, StdlibFunc{"track_version", trackVersion, "Track version", "strings", ""}, StdlibFunc{"not", LiftFunction(builtinNOT), "Logical NOT operation", "bool", ""}, StdlibFunc{"and", LiftFunction(builtinAND), "Logical AND operation", "bool", "b2 :: bool"}, StdlibFunc{"or", LiftFunction(builtinOR), "Logical OR operation", "bool", "b2 :: bool"}, StdlibFunc{"lt", LiftFunction(builtinLT), "Returns true if first argument is less than the second argument", "integer", "i2 :: integer"}, StdlibFunc{"lte", LiftFunction(builtinLTE), "Returns true if first argument is less than or equal to the second argument", "integer", "i2 :: integer"}, StdlibFunc{"gt", LiftFunction(builtinGT), "Returns true if first argument is greater than second argument", "integer", "i2 :: integer"}, StdlibFunc{"gte", LiftFunction(builtinGTE), "Returns true if first argument is greater than or equal to second argument", "integer", "i2 :: integer"}, }
Functions ¶
func EvalToGoValue ¶
func EvalToGoValue(script Script, env *ScriptEnvironment) (interface{}, error)
func ExpectApplyAtom ¶
func ExpectApplyAtom(s Script) *apply
func ExpectBoolAtom ¶
func ExpectDict ¶
func ExpectDictAtom ¶
func ExpectFunctionAtom ¶
func ExpectFunctionAtom(s Script) scriptFuncType
func ExpectIntegerAtom ¶
func ExpectLambdaAtom ¶
func ExpectLambdaAtom(v Script) *lambda
func ExpectStringAtom ¶
func IsApplyAtom ¶
func IsBoolAtom ¶
func IsDictAtom ¶
func IsFunctionAtom ¶
func IsIntegerAtom ¶
func IsLambdaAtom ¶
func IsListAtom ¶
func IsStringAtom ¶
func ParseAndEvalToGoValue ¶
func ParseAndEvalToGoValue(scriptStr string, env *ScriptEnvironment) (interface{}, error)
func ParseAndEvalToString ¶
func ParseAndEvalToString(scriptStr string, env *ScriptEnvironment) (string, error)
Types ¶
type Function ¶
type Function struct { Func scriptFuncType Doc string }
Functions
func ExpectFunction ¶
type Script ¶
type Script interface { Eval(*ScriptEnvironment) (Script, error) Value() (interface{}, error) Type() ValueType Equals(Script) bool }
func ExpectListAtom ¶
func LiftFunction ¶
func LiftFunction(f scriptFuncType) Script
func LiftGoFunc ¶
func LiftGoFunc(f interface{}) Script
func LiftInteger ¶
func LiftString ¶
func ParseScript ¶
func ShouldLift ¶
func ShouldLift(v interface{}) Script
func ShouldParse ¶
type ScriptEnvironment ¶
func NewScriptEnvironment ¶
func NewScriptEnvironment() *ScriptEnvironment
func NewScriptEnvironmentFromMap ¶
func NewScriptEnvironmentFromMap(m map[string]Script) *ScriptEnvironment
func NewScriptEnvironmentWithGlobals ¶
func NewScriptEnvironmentWithGlobals(globals map[string]Script) *ScriptEnvironment
type StdlibFunc ¶
Click to show internal directories.
Click to hide internal directories.