mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-13 22:38:04 +00:00
infix reduce
This commit is contained in:
parent
3e5f7b147f
commit
b2317a14ef
@ -13,7 +13,7 @@ var pathTests = []struct {
|
|||||||
expectedPostFix []interface{}
|
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", "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"),
|
append(make([]interface{}, 0), "a", "GET_VARIABLE", "ASSIGN_VARIABLE", "0 (int64)", "SELF", "GET_VARIABLE", "ADD", "BLOCK", "REDUCE"),
|
||||||
},
|
},
|
||||||
|
@ -252,7 +252,7 @@ func initLexer() (*lex.Lexer, error) {
|
|||||||
lexer.Add([]byte(`or`), opToken(orOpType))
|
lexer.Add([]byte(`or`), opToken(orOpType))
|
||||||
lexer.Add([]byte(`and`), opToken(andOpType))
|
lexer.Add([]byte(`and`), opToken(andOpType))
|
||||||
lexer.Add([]byte(`not`), opToken(notOpType))
|
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(blockOpType))
|
||||||
lexer.Add([]byte(`\/\/`), opToken(alternativeOpType))
|
lexer.Add([]byte(`\/\/`), opToken(alternativeOpType))
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
var reduceOperatorScenarios = []expressionScenario{
|
var reduceOperatorScenarios = []expressionScenario{
|
||||||
{
|
{
|
||||||
document: `[10,2, 5, 3]`,
|
document: `[10,2, 5, 3]`,
|
||||||
expression: `.[] as $item reduce (0; . + $item)`,
|
expression: `.[] as $item ireduce (0; . + $item)`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
"D0, P[], (!!int)::20\n",
|
"D0, P[], (!!int)::20\n",
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user