/
statement.go
29 lines (23 loc) 路 916 Bytes
/
statement.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package q
// Statement represents a single discreet operation in the engine.
type Statement struct {
// VariableName must be unique amongst other variables and must not be the
// name of an existing function. The name is also allow to be empty which
// means that the result cannot be referenced in other expressions.
VariableName string
// Expressions are separated by pipes. The result of each evaluated
// expressions is used as the input to the next expressions. The input value
// for the first expression is the gedcom.Document.
Expressions []Expression
}
// Evaluate executes all of the expressions and returns the final result.
func (v *Statement) Evaluate(engine *Engine, input interface{}) (interface{}, error) {
var err error
for _, expression := range v.Expressions {
input, err = expression.Evaluate(engine, input, nil)
if err != nil {
return nil, err
}
}
return input, nil
}