Skip to content

Commit 19be641

Browse files
committed
add comments
1 parent c245100 commit 19be641

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

expr.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"reflect"
99
)
1010

11+
// Eval parses, compiles and runs given input.
1112
func Eval(input string, env interface{}) (interface{}, error) {
1213
node, err := parser.Parse(input)
1314
if err != nil {
@@ -49,6 +50,7 @@ func Env(i interface{}) OptionFn {
4950
}
5051
}
5152

53+
// CompileType compiles input and returns program with output type, if Env was specified.
5254
func CompileType(input string, ops ...OptionFn) (*vm.Program, reflect.Type, error) {
5355
c := &config{}
5456

@@ -82,11 +84,13 @@ func CompileType(input string, ops ...OptionFn) (*vm.Program, reflect.Type, erro
8284
return program, t, nil
8385
}
8486

87+
// Compile parses and compiles given input expression to bytecode program.
8588
func Compile(input string, ops ...OptionFn) (*vm.Program, error) {
8689
program, _, err := CompileType(input, ops...)
8790
return program, err
8891
}
8992

93+
// Run evaluates given bytecode program.
9094
func Run(program *vm.Program, env interface{}) (interface{}, error) {
9195
return vm.Run(program, env)
9296
}

0 commit comments

Comments
 (0)