Commit b80b3a3 1 parent 78680a1 commit b80b3a3 Copy full SHA for b80b3a3
File tree 3 files changed +16
-6
lines changed
3 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -189,14 +189,21 @@ func (p *Expr) checkSyntax() error {
189
189
**/
190
190
191
191
func sortPriority (e ExprNode ) {
192
+ for subSortPriority (e ) {
193
+ }
194
+ }
195
+
196
+ func subSortPriority (e ExprNode ) bool {
192
197
if e == nil {
193
- return
198
+ return false
194
199
}
195
- sortPriority (e .LeftOperand ())
196
- sortPriority (e .RightOperand ())
200
+ leftChanged := subSortPriority (e .LeftOperand ())
201
+ rightChanged := subSortPriority (e .RightOperand ())
197
202
if getPriority (e ) > getPriority (e .LeftOperand ()) {
198
203
leftOperandToParent (e )
204
+ return true
199
205
}
206
+ return leftChanged || rightChanged
200
207
}
201
208
202
209
func getPriority (e ExprNode ) (i int ) {
Original file line number Diff line number Diff line change @@ -136,6 +136,7 @@ func TestPriority(t *testing.T) {
136
136
expr string
137
137
val interface {}
138
138
}{
139
+ {expr : "false||true&&8==8" , val : true },
139
140
{expr : "1+2>5-4" , val : true },
140
141
{expr : "1+2*4/2" , val : 5.0 },
141
142
{expr : "(true||false)&&false||false" , val : false },
Original file line number Diff line number Diff line change 14
14
15
15
package tagexpr
16
16
17
- import "math"
17
+ import (
18
+ "math"
19
+ )
18
20
19
21
// --------------------------- Operator ---------------------------
20
22
@@ -212,7 +214,7 @@ type andExprNode struct{ exprBackground }
212
214
func newAndExprNode () ExprNode { return & andExprNode {} }
213
215
214
216
func (ae * andExprNode ) Run (currField string , tagExpr * TagExpr ) interface {} {
215
- for _ , e := range []ExprNode {ae .leftOperand , ae .rightOperand } {
217
+ for _ , e := range [2 ]ExprNode {ae .leftOperand , ae .rightOperand } {
216
218
switch r := e .Run (currField , tagExpr ).(type ) {
217
219
case float64 :
218
220
if r == 0 {
@@ -240,7 +242,7 @@ type orExprNode struct{ exprBackground }
240
242
func newOrExprNode () ExprNode { return & orExprNode {} }
241
243
242
244
func (oe * orExprNode ) Run (currField string , tagExpr * TagExpr ) interface {} {
243
- for _ , e := range []ExprNode {oe .leftOperand , oe .rightOperand } {
245
+ for _ , e := range [2 ]ExprNode {oe .leftOperand , oe .rightOperand } {
244
246
switch r := e .Run (currField , tagExpr ).(type ) {
245
247
case float64 :
246
248
if r != 0 {
You can’t perform that action at this time.
0 commit comments