mirror of
				https://github.com/taigrr/yq
				synced 2025-01-18 04:53:17 -08:00 
			
		
		
		
	Fixing add,multiply,alternative operator precendences
This commit is contained in:
		
							parent
							
								
									c59209f041
								
							
						
					
					
						commit
						02ef99560d
					
				| @ -52,6 +52,21 @@ var pathTests = []struct { | ||||
| 		append(make([]interface{}, 0), "[", "3 (int64)", "]"), | ||||
| 		append(make([]interface{}, 0), "3 (int64)", "COLLECT", "SHORT_PIPE"), | ||||
| 	}, | ||||
| 	{ | ||||
| 		`.key.array + .key.array2`, | ||||
| 		append(make([]interface{}, 0), "key", "SHORT_PIPE", "array", "ADD", "key", "SHORT_PIPE", "array2"), | ||||
| 		append(make([]interface{}, 0), "key", "array", "SHORT_PIPE", "key", "array2", "SHORT_PIPE", "ADD"), | ||||
| 	}, | ||||
| 	{ | ||||
| 		`.key.array * .key.array2`, | ||||
| 		append(make([]interface{}, 0), "key", "SHORT_PIPE", "array", "MULTIPLY", "key", "SHORT_PIPE", "array2"), | ||||
| 		append(make([]interface{}, 0), "key", "array", "SHORT_PIPE", "key", "array2", "SHORT_PIPE", "MULTIPLY"), | ||||
| 	}, | ||||
| 	{ | ||||
| 		`.key.array // .key.array2`, | ||||
| 		append(make([]interface{}, 0), "key", "SHORT_PIPE", "array", "ALTERNATIVE", "key", "SHORT_PIPE", "array2"), | ||||
| 		append(make([]interface{}, 0), "key", "array", "SHORT_PIPE", "key", "array2", "SHORT_PIPE", "ALTERNATIVE"), | ||||
| 	}, | ||||
| 	{ | ||||
| 		`.a | .[].b == "apple"`, | ||||
| 		append(make([]interface{}, 0), "a", "PIPE", "TRAVERSE_ARRAY", "[", "]", "SHORT_PIPE", "b", "EQUALS", "apple (string)"), | ||||
|  | ||||
| @ -40,9 +40,9 @@ var assignCommentOpType = &operationType{Type: "ASSIGN_COMMENT", NumArgs: 2, Pre | ||||
| var assignAnchorOpType = &operationType{Type: "ASSIGN_ANCHOR", NumArgs: 2, Precedence: 40, Handler: assignAnchorOperator} | ||||
| var assignAliasOpType = &operationType{Type: "ASSIGN_ALIAS", NumArgs: 2, Precedence: 40, Handler: assignAliasOperator} | ||||
| 
 | ||||
| var multiplyOpType = &operationType{Type: "MULTIPLY", NumArgs: 2, Precedence: 45, Handler: multiplyOperator} | ||||
| var addOpType = &operationType{Type: "ADD", NumArgs: 2, Precedence: 45, Handler: addOperator} | ||||
| var alternativeOpType = &operationType{Type: "ALTERNATIVE", NumArgs: 2, Precedence: 45, Handler: alternativeOperator} | ||||
| var multiplyOpType = &operationType{Type: "MULTIPLY", NumArgs: 2, Precedence: 42, Handler: multiplyOperator} | ||||
| var addOpType = &operationType{Type: "ADD", NumArgs: 2, Precedence: 42, Handler: addOperator} | ||||
| var alternativeOpType = &operationType{Type: "ALTERNATIVE", NumArgs: 2, Precedence: 42, Handler: alternativeOperator} | ||||
| 
 | ||||
| var equalsOpType = &operationType{Type: "EQUALS", NumArgs: 2, Precedence: 40, Handler: equalsOperator} | ||||
| var createMapOpType = &operationType{Type: "CREATE_MAP", NumArgs: 2, Precedence: 40, Handler: createMapOperator} | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user