@@ -32,86 +32,86 @@ func parseFilter(raw []byte, c config) (Expression, error) {
3232 return c .parseFilterOr (node )
3333}
3434
35- func (p config ) parseFilterOr (node * ast.Node ) (Expression , error ) {
36- if node .Type != typ .FilterOr {
37- return nil , invalidTypeError (typ .FilterOr , node .Type )
35+ func (p config ) parseFilterAnd (node * ast.Node ) (Expression , error ) {
36+ if node .Type != typ .FilterAnd {
37+ return nil , invalidTypeError (typ .FilterAnd , node .Type )
3838 }
3939
4040 children := node .Children ()
4141 if len (children ) == 0 {
42- return nil , invalidLengthError (typ .FilterOr , 1 , 0 )
42+ return nil , invalidLengthError (typ .FilterAnd , 1 , 0 )
4343 }
4444
4545 if len (children ) == 1 {
46- return p .parseFilterAnd (children [0 ])
46+ return p .parseFilterValue (children [0 ])
4747 }
4848
49- var or LogicalExpression
49+ var and LogicalExpression
5050 for _ , node := range children {
51- exp , err := p .parseFilterAnd (node )
51+ exp , err := p .parseFilterValue (node )
5252 if err != nil {
5353 return nil , err
5454 }
5555 switch {
56- case or .Left == nil :
57- or .Left = exp
58- case or .Right == nil :
59- or .Right = exp
60- or .Operator = OR
56+ case and .Left == nil :
57+ and .Left = exp
58+ case and .Right == nil :
59+ and .Right = exp
60+ and .Operator = AND
6161 default :
62- or = LogicalExpression {
62+ and = LogicalExpression {
6363 Left : & LogicalExpression {
64- Left : or .Left ,
65- Right : or .Right ,
66- Operator : OR ,
64+ Left : and .Left ,
65+ Right : and .Right ,
66+ Operator : AND ,
6767 },
6868 Right : exp ,
69- Operator : OR ,
69+ Operator : AND ,
7070 }
7171 }
7272 }
73- return & or , nil
73+ return & and , nil
7474}
7575
76- func (p config ) parseFilterAnd (node * ast.Node ) (Expression , error ) {
77- if node .Type != typ .FilterAnd {
78- return nil , invalidTypeError (typ .FilterAnd , node .Type )
76+ func (p config ) parseFilterOr (node * ast.Node ) (Expression , error ) {
77+ if node .Type != typ .FilterOr {
78+ return nil , invalidTypeError (typ .FilterOr , node .Type )
7979 }
8080
8181 children := node .Children ()
8282 if len (children ) == 0 {
83- return nil , invalidLengthError (typ .FilterAnd , 1 , 0 )
83+ return nil , invalidLengthError (typ .FilterOr , 1 , 0 )
8484 }
8585
8686 if len (children ) == 1 {
87- return p .parseFilterValue (children [0 ])
87+ return p .parseFilterAnd (children [0 ])
8888 }
8989
90- var and LogicalExpression
90+ var or LogicalExpression
9191 for _ , node := range children {
92- exp , err := p .parseFilterValue (node )
92+ exp , err := p .parseFilterAnd (node )
9393 if err != nil {
9494 return nil , err
9595 }
9696 switch {
97- case and .Left == nil :
98- and .Left = exp
99- case and .Right == nil :
100- and .Right = exp
101- and .Operator = AND
97+ case or .Left == nil :
98+ or .Left = exp
99+ case or .Right == nil :
100+ or .Right = exp
101+ or .Operator = OR
102102 default :
103- and = LogicalExpression {
103+ or = LogicalExpression {
104104 Left : & LogicalExpression {
105- Left : and .Left ,
106- Right : and .Right ,
107- Operator : AND ,
105+ Left : or .Left ,
106+ Right : or .Right ,
107+ Operator : OR ,
108108 },
109109 Right : exp ,
110- Operator : AND ,
110+ Operator : OR ,
111111 }
112112 }
113113 }
114- return & and , nil
114+ return & or , nil
115115}
116116
117117func (p config ) parseFilterValue (node * ast.Node ) (Expression , error ) {
0 commit comments