-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexpr_like.go
More file actions
29 lines (25 loc) · 732 Bytes
/
Copy pathexpr_like.go
File metadata and controls
29 lines (25 loc) · 732 Bytes
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 lure
import "regexp"
// ExprLike represents an identity node in the AST
type ExprLike struct {
left Expr
right Expr
}
// evaluate returns:
// - FALSE if left or right or context is nil
// - a boolData that tells if right matches left
func (me ExprLike) evaluate(context map[string]IData) IData {
if me.left == nil || me.right == nil || context == nil {
return boolDataFalse
}
// return true for "<left> like <right>" if
leftData := me.left.evaluate(context)
rightData := me.right.evaluate(context)
if matched, err := regexp.MatchString(rightData.toString(), leftData.toString()); err != nil {
return BoolData{val: matched}
}
return boolDataFalse
}
func (me ExprLike) isResolvable() bool {
return true
}