diff --git a/pkg/yqlib/expression_processing_test.go b/pkg/yqlib/expression_processing_test.go index 296c174..d7ebbd0 100644 --- a/pkg/yqlib/expression_processing_test.go +++ b/pkg/yqlib/expression_processing_test.go @@ -13,7 +13,7 @@ var pathTests = []struct { expectedPostFix []interface{} }{ { - `.a as $item reduce (0; . + $item)`, // note - add code to shuffle reduce to this position for postfix + `.a as $item ireduce (0; . + $item)`, // note - add code to shuffle reduce to this position for postfix append(make([]interface{}, 0), "a", "ASSIGN_VARIABLE", "GET_VARIABLE", "REDUCE", "(", "0 (int64)", "BLOCK", "SELF", "ADD", "GET_VARIABLE", ")"), append(make([]interface{}, 0), "a", "GET_VARIABLE", "ASSIGN_VARIABLE", "0 (int64)", "SELF", "GET_VARIABLE", "ADD", "BLOCK", "REDUCE"), }, diff --git a/pkg/yqlib/expression_tokeniser.go b/pkg/yqlib/expression_tokeniser.go index 2f84cd4..b8b0683 100644 --- a/pkg/yqlib/expression_tokeniser.go +++ b/pkg/yqlib/expression_tokeniser.go @@ -252,7 +252,7 @@ func initLexer() (*lex.Lexer, error) { lexer.Add([]byte(`or`), opToken(orOpType)) lexer.Add([]byte(`and`), opToken(andOpType)) lexer.Add([]byte(`not`), opToken(notOpType)) - lexer.Add([]byte(`reduce`), opToken(reduceOpType)) + lexer.Add([]byte(`ireduce`), opToken(reduceOpType)) lexer.Add([]byte(`;`), opToken(blockOpType)) lexer.Add([]byte(`\/\/`), opToken(alternativeOpType)) diff --git a/pkg/yqlib/operator_reduce_test.go b/pkg/yqlib/operator_reduce_test.go index 7e9500d..acff721 100644 --- a/pkg/yqlib/operator_reduce_test.go +++ b/pkg/yqlib/operator_reduce_test.go @@ -7,7 +7,7 @@ import ( var reduceOperatorScenarios = []expressionScenario{ { document: `[10,2, 5, 3]`, - expression: `.[] as $item reduce (0; . + $item)`, + expression: `.[] as $item ireduce (0; . + $item)`, expected: []string{ "D0, P[], (!!int)::20\n", },