@@ -23,9 +23,7 @@ type Logic struct {
23
23
payloadOnce sync.Once
24
24
}
25
25
26
- type ParseRuleFunc func (tp , payload , target string , params []string , subRules map [string ][]C.Rule ) (C.Rule , error )
27
-
28
- func NewSubRule (payload , adapter string , subRules map [string ][]C.Rule , parseRule ParseRuleFunc ) (* Logic , error ) {
26
+ func NewSubRule (payload , adapter string , subRules map [string ][]C.Rule , parseRule common.ParseRuleFunc ) (* Logic , error ) {
29
27
logic := & Logic {Base : & common.Base {}, payload : payload , adapter : adapter , ruleType : C .SubRules , subRules : subRules }
30
28
err := logic .parsePayload (fmt .Sprintf ("(%s)" , payload ), parseRule )
31
29
if err != nil {
@@ -38,7 +36,7 @@ func NewSubRule(payload, adapter string, subRules map[string][]C.Rule, parseRule
38
36
return logic , nil
39
37
}
40
38
41
- func NewNOT (payload string , adapter string , parseRule ParseRuleFunc ) (* Logic , error ) {
39
+ func NewNOT (payload string , adapter string , parseRule common. ParseRuleFunc ) (* Logic , error ) {
42
40
logic := & Logic {Base : & common.Base {}, payload : payload , adapter : adapter , ruleType : C .NOT }
43
41
err := logic .parsePayload (payload , parseRule )
44
42
if err != nil {
@@ -51,7 +49,7 @@ func NewNOT(payload string, adapter string, parseRule ParseRuleFunc) (*Logic, er
51
49
return logic , nil
52
50
}
53
51
54
- func NewOR (payload string , adapter string , parseRule ParseRuleFunc ) (* Logic , error ) {
52
+ func NewOR (payload string , adapter string , parseRule common. ParseRuleFunc ) (* Logic , error ) {
55
53
logic := & Logic {Base : & common.Base {}, payload : payload , adapter : adapter , ruleType : C .OR }
56
54
err := logic .parsePayload (payload , parseRule )
57
55
if err != nil {
@@ -60,7 +58,7 @@ func NewOR(payload string, adapter string, parseRule ParseRuleFunc) (*Logic, err
60
58
return logic , nil
61
59
}
62
60
63
- func NewAND (payload string , adapter string , parseRule ParseRuleFunc ) (* Logic , error ) {
61
+ func NewAND (payload string , adapter string , parseRule common. ParseRuleFunc ) (* Logic , error ) {
64
62
logic := & Logic {Base : & common.Base {}, payload : payload , adapter : adapter , ruleType : C .AND }
65
63
err := logic .parsePayload (payload , parseRule )
66
64
if err != nil {
@@ -79,7 +77,7 @@ func (r Range) containRange(preStart, preEnd int) bool {
79
77
return preStart < r .start && preEnd > r .end
80
78
}
81
79
82
- func (logic * Logic ) payloadToRule (subPayload string , parseRule ParseRuleFunc ) (C.Rule , error ) {
80
+ func (logic * Logic ) payloadToRule (subPayload string , parseRule common. ParseRuleFunc ) (C.Rule , error ) {
83
81
splitStr := strings .SplitN (subPayload , "," , 2 )
84
82
if len (splitStr ) < 2 {
85
83
return nil , fmt .Errorf ("[%s] format is error" , subPayload )
@@ -160,7 +158,7 @@ func (logic *Logic) findSubRuleRange(payload string, ruleRanges []Range) []Range
160
158
return subRuleRange
161
159
}
162
160
163
- func (logic * Logic ) parsePayload (payload string , parseRule ParseRuleFunc ) error {
161
+ func (logic * Logic ) parsePayload (payload string , parseRule common. ParseRuleFunc ) error {
164
162
regex , err := regexp .Compile ("\\ (.*\\ )" )
165
163
if err != nil {
166
164
return err
0 commit comments