From b2e3a483bff050bdf207bf15a18c5a22357ec00b Mon Sep 17 00:00:00 2001 From: Uwe Krueger Date: Mon, 14 Oct 2019 21:24:36 +0200 Subject: [PATCH] named and indexed arguments --- Gopkg.lock | 10 +- README.md | 113 +- dynaml/call.go | 42 +- dynaml/catch.go | 2 +- dynaml/dynaml.peg | 9 +- dynaml/dynaml.peg.go | 2109 +++++++++++++++++++----------------- dynaml/expression.go | 11 +- dynaml/lambda.go | 128 ++- dynaml/listexpansion.go | 41 + dynaml/mapping.go | 4 +- dynaml/parser.go | 30 +- dynaml/parser_test.go | 61 +- dynaml/replace.go | 2 +- dynaml/sort.go | 2 +- dynaml/sum.go | 4 +- dynaml/sync.go | 4 +- dynaml/validate.go | 2 +- dynaml/varargs.go | 38 - flow/cascade_test.go | 19 +- flow/flow_namedarg_test.go | 264 +++++ 20 files changed, 1790 insertions(+), 1105 deletions(-) create mode 100644 dynaml/listexpansion.go delete mode 100644 dynaml/varargs.go create mode 100644 flow/flow_namedarg_test.go diff --git a/Gopkg.lock b/Gopkg.lock index cecabb8..6d91168 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -184,12 +184,19 @@ [[projects]] branch = "master" - digest = "1:68344dbfaa4179bb50a583eb8172ace3f1edaf3aebc24e68c03f549f6e6b60dc" + digest = "1:10995dafbbb8715bfdd3df05e8eefa5d4284441f8e70a54e88416a60c85c751e" name = "golang.org/x/crypto" packages = [ "bcrypt", "blowfish", + "curve25519", + "ed25519", + "ed25519/internal/edwards25519", + "internal/chacha20", + "internal/subtle", "md4", + "poly1305", + "ssh", ] pruneopts = "UT" revision = "a4c6cb3142f211c99e4bf4cd769535b29a9b616f" @@ -281,6 +288,7 @@ "github.com/spf13/viper", "golang.org/x/crypto/bcrypt", "golang.org/x/crypto/md4", + "golang.org/x/crypto/ssh", ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/README.md b/README.md index 867c842..20a4d7d 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,7 @@ Contents: - [(( x509publickey(key) ))](#-x509publickeykey-) - [(( x509cert(spec) ))](#-x509certspec-) - [(( lambda |x|->x ":" port ))](#-lambda-x-x--port-) + - [Positional versus Named Argunments](#positional-versus-named-arguments) - [Scopes and Lambda Expressions](#scopes-and-lambda-expressions) - [Optional Parameters (( |x,y=2|-> x * y ))](#optional-parameters) - [Variable Argument Lists (( |x,y...|-> x y ))](#variable-argument-lists) @@ -3314,7 +3315,10 @@ cert: ## `(( lambda |x|->x ":" port ))` -Lambda expressions can be used to define additional anonymous functions. They can be assigned to yaml nodes as values and referenced with path expressions to call the function with approriate arguments in other dynaml expressions. For the final document they are mapped to string values. +Lambda expressions can be used to define additional anonymous functions. They +can be assigned to yaml nodes as values and referenced with path expressions +to call the function with approriate arguments in other dynaml expressions. +For the final document they are mapped to string values. There are two forms of lambda expressions. While @@ -3361,6 +3365,49 @@ for complex scoped and curried functions this is not possible. Therefore function nodes should always be _temporary_ or _local_ to be available during processing or merging, but being omitted for the final document. + +### Positional versus Named Arguments + +A typical function call uses positional arguments. Here the given arguments +satisfy the declared function parameters in the given order. +For lambda values it is also possible to use named arguments in the call +expression. Here an argument is assigned to a dedicated parameter as declared +by the lambda expression. The order of named arguments can be arbitrarily chosen. + +e.g.: + +```yaml +func: (( |a,b,c|->{$a=a, $b=b, $c=c } )) +result: (( .func(c=1, b=2, a=1) )) +``` + +It is also posible to combine named with positional arguments. Hereby the +positional arguments must follow the named ones. + +e.g.: + +```yaml +func: (( |a,b,c|->{$a=a, $b=b, $c=c } )) +result: (( .func(c=1, 1, 2) )) +``` + +The same argument MUST NOT be satified by both, a named and a positional +argument. + +Instead of using the parameter name it is also possible to use the parameter +index, instead. + +e.g.: + +```yaml +func: (( |a,b,c|->{$a=a, $b=b, $c=c } )) +result: (( .func(3=1, 1) )) +``` + +As such, this feature seems to be quite useless, but it shows its power if +combined with [optional parameters](#optional-parameters) or +[currying](#currying) as shown in the next paragraphs. + ### Scopes and Lambda Expressions A lambda expression might refer to absolute or relative nodes of the actual yaml document of the call. Relative references are evaluated in the context of the function call. Therefore @@ -3464,9 +3511,28 @@ It is possible to default all parameters of a lambda expression. The function can then be called without arguments. There might be no non-defaulted parameters after a defaulted one. -A call may only omit arguments for optional parameters from right to left. If -there should be an explicit argument for the right most parameter, arguments for -all parameters must be specified. Cherry-picking is not possible. +A call with positional arguments may only omit arguments for optional parameters +from right to left. If there should be an explicit argument for the right most +parameter, arguments for all parameters must be specified or +[named arguments](#positional-versus-named-arguments) must be used. +Here the desired optional parameter can explicitly be set prior to the regular +positional arguments. + +e.g.: + +```yaml +func: (( |a,b=1,c=2|->{$a=a, $b=b, $c=c } )) +result: (( .func(c=3, 2) )) +``` + +evaluates `result` to + +```yaml +result: + a: 2 + b: 1 + c: 3 +``` The expression for the default does not need to be a constant value or even expression, it might refer to other nodes in the yaml document. The default @@ -3512,6 +3578,8 @@ If no argument is given for the _varargs_ parameter its value is the empty list. The `...` operator can also be used for [inline list expansion](#inline-list-expansion). +If a vararg parameter should be set by a [named argument](#positional-versus-named-arguments) +its value must be a list. ### Currying @@ -3565,6 +3633,43 @@ There are several builtin functions acting on unevaluated or unevaluatable arguments, like [`defined`](#-definedfoobar-). For these functions currying is not possible. +Using positional arguments currying is only possible from right to left. +But currying can also be done for [named arguments](#positional-versus-named-arguments). +Here any parameter combination, regardless of the position in the parameter +list, can be preset. The resulting function then has the unsatisfied parameters +in their original order. Switching the parameter order is not possible. + +e.g.: + +```yaml +func: (( |a,b=1,c=2|->{$a=a, $b=b, $c=c } )) +curry: (( .func(c=3, 2) )) + +result: (( .curry(5) )) +``` + +evalutes `result` to + +```yaml +result: + a: 2 + b: 5 + c: 3 +``` + +The resulting function keeps the parameter `b`. Hereby the default value will +be kept. Therefore it can just be called without argument (`.curry()`), which +would produce + +```yaml +result: + a: 2 + b: 1 + c: 3 +``` + +**Attention**: + For compatibility reasons currying is also done, if a lambda function without defaulted parameters is called with less arguments than declared parameters. diff --git a/dynaml/call.go b/dynaml/call.go index 4b850f8..a28b92d 100644 --- a/dynaml/call.go +++ b/dynaml/call.go @@ -2,6 +2,7 @@ package dynaml import ( "fmt" + "github.com/mandelsoft/spiff/yaml" "strings" "github.com/mandelsoft/spiff/debug" @@ -15,6 +16,15 @@ func RegisterFunction(name string, f Function) { functions[name] = f } +type NameArgument struct { + Name string + Expression +} + +func (a NameArgument) String() string { + return fmt.Sprintf("%s=%s", a.Name, a.Expression) +} + type CallExpr struct { Function Expression Arguments []Expression @@ -83,16 +93,33 @@ func (e CallExpr) Evaluate(binding Binding, locally bool) (interface{}, Evaluati return e, info, true } + named := map[string]yaml.Node{} + found := -1 + for i := range e.Arguments { + if n, ok := e.Arguments[i].(NameArgument); ok { + named[n.Name] = NewNode(values[i], binding) + found = i + } else { + break + } + } + if found >= 0 { + values = values[found+1:] + } + var result interface{} var sub EvaluationInfo + if funcName != "" && len(named) > 0 { + return info.Error("no named arguments for builtin function (%s)", e.Function) + } if funcName != "" && e.Curry { params := []Parameter{Parameter{Name: "__args"}} args := make([]Expression, len(values)+1) for i, v := range values { args[i] = ValueExpr{v} } - args[len(values)] = VarArgsExpr{ReferenceExpr{[]string{"__args"}}} + args[len(values)] = ListExpansionExpr{ReferenceExpr{[]string{"__args"}}} expr := CallExpr{ Function: ReferenceExpr{[]string{funcName}}, Arguments: args, @@ -103,7 +130,7 @@ func (e CallExpr) Evaluate(binding Binding, locally bool) (interface{}, Evaluati switch funcName { case "": debug.Debug("calling lambda function %#v\n", value) - resolved, result, sub, ok = value.(LambdaValue).Evaluate(false, e.Curry, true, values, binding, false) + resolved, result, sub, ok = value.(LambdaValue).Evaluate(false, e.Curry, true, named, values, binding, false) case "static_ips": result, sub, ok = func_static_ips(e.Arguments, binding) @@ -289,9 +316,12 @@ func (e CallExpr) Evaluate(binding Binding, locally bool) (interface{}, Evaluati func (e CallExpr) String() string { args := make([]string, len(e.Arguments)) - for i, e := range e.Arguments { - args[i] = fmt.Sprintf("%s", e) + for i, a := range e.Arguments { + args[i] = fmt.Sprintf("%s", a) } - - return fmt.Sprintf("%s(%s)", e.Function, strings.Join(args, ", ")) + curry := "" + if e.Curry { + curry = "*" + } + return fmt.Sprintf("%s%s(%s)", e.Function, curry, strings.Join(args, ", ")) } diff --git a/dynaml/catch.go b/dynaml/catch.go index b1c9705..8f303cd 100644 --- a/dynaml/catch.go +++ b/dynaml/catch.go @@ -97,7 +97,7 @@ func (e CatchExpr) Evaluate(binding Binding, locally bool) (interface{}, Evaluat return info.Error("lambda expression for sync condition must take one or two arguments, found %d", len(lambda.lambda.Parameters)) } - resolved, mapped, info, ok := lambda.Evaluate(inline, false, false, inp, binding, false) + resolved, mapped, info, ok := lambda.Evaluate(inline, false, false, nil, inp, binding, false) if !ok { debug.Debug("catch lambda failed\n") return nil, info, false diff --git a/dynaml/dynaml.peg b/dynaml/dynaml.peg index 082bcdc..4d4857f 100644 --- a/dynaml/dynaml.peg +++ b/dynaml/dynaml.peg @@ -52,11 +52,14 @@ ChainedRef <- PathComponent FollowUpRef ChainedDynRef <- '.'? '[' Expression ']' Slice <- Range Currying <- '*' ChainedCall -ChainedCall <- StartArguments ExpressionList? ')' +ChainedCall <- StartArguments NameArgumentList? ')' StartArguments <- '(' ws +NameArgumentList <- (( NextNameArgument ( ',' NextNameArgument)* ) / NextExpression) ( ',' NextExpression)* +NextNameArgument <- ws Name ws '=' ws Expression ws + ExpressionList <- NextExpression ( ',' NextExpression)* -NextExpression <- Expression VarArgs? -VarArgs <- '...' ws +NextExpression <- Expression ListExpansion? +ListExpansion <- '...' ws Projection <- '.'? ( '[*]' / Slice ) ProjectionValue ChainedQualifiedExpression* ProjectionValue <- {} diff --git a/dynaml/dynaml.peg.go b/dynaml/dynaml.peg.go index 1611456..037bb15 100644 --- a/dynaml/dynaml.peg.go +++ b/dynaml/dynaml.peg.go @@ -53,9 +53,11 @@ const ( ruleCurrying ruleChainedCall ruleStartArguments + ruleNameArgumentList + ruleNextNameArgument ruleExpressionList ruleNextExpression - ruleVarArgs + ruleListExpansion ruleProjection ruleProjectionValue ruleSubstitution @@ -161,9 +163,11 @@ var rul3s = [...]string{ "Currying", "ChainedCall", "StartArguments", + "NameArgumentList", + "NextNameArgument", "ExpressionList", "NextExpression", - "VarArgs", + "ListExpansion", "Projection", "ProjectionValue", "Substitution", @@ -540,7 +544,7 @@ func (t *tokens32) Expand(index int) tokenTree { type DynamlGrammar struct { Buffer string buffer []rune - rules [101]func() bool + rules [103]func() bool Parse func(rule ...int) error Reset func() Pretty bool @@ -2156,7 +2160,7 @@ func (p *DynamlGrammar) Init() { position, tokenIndex, depth = position155, tokenIndex155, depth155 return false }, - /* 37 ChainedCall <- <(StartArguments ExpressionList? ')')> */ + /* 37 ChainedCall <- <(StartArguments NameArgumentList? ')')> */ func() bool { position157, tokenIndex157, depth157 := position, tokenIndex, depth { @@ -2167,7 +2171,7 @@ func (p *DynamlGrammar) Init() { } { position159, tokenIndex159, depth159 := position, tokenIndex, depth - if !_rules[ruleExpressionList]() { + if !_rules[ruleNameArgumentList]() { goto l159 } goto l160 @@ -2208,2406 +2212,2497 @@ func (p *DynamlGrammar) Init() { position, tokenIndex, depth = position161, tokenIndex161, depth161 return false }, - /* 39 ExpressionList <- <(NextExpression (',' NextExpression)*)> */ + /* 39 NameArgumentList <- <(((NextNameArgument (',' NextNameArgument)*) / NextExpression) (',' NextExpression)*)> */ func() bool { position163, tokenIndex163, depth163 := position, tokenIndex, depth { position164 := position depth++ - if !_rules[ruleNextExpression]() { - goto l163 + { + position165, tokenIndex165, depth165 := position, tokenIndex, depth + if !_rules[ruleNextNameArgument]() { + goto l166 + } + l167: + { + position168, tokenIndex168, depth168 := position, tokenIndex, depth + if buffer[position] != rune(',') { + goto l168 + } + position++ + if !_rules[ruleNextNameArgument]() { + goto l168 + } + goto l167 + l168: + position, tokenIndex, depth = position168, tokenIndex168, depth168 + } + goto l165 + l166: + position, tokenIndex, depth = position165, tokenIndex165, depth165 + if !_rules[ruleNextExpression]() { + goto l163 + } } l165: + l169: { - position166, tokenIndex166, depth166 := position, tokenIndex, depth + position170, tokenIndex170, depth170 := position, tokenIndex, depth if buffer[position] != rune(',') { - goto l166 + goto l170 } position++ if !_rules[ruleNextExpression]() { - goto l166 + goto l170 } - goto l165 - l166: - position, tokenIndex, depth = position166, tokenIndex166, depth166 + goto l169 + l170: + position, tokenIndex, depth = position170, tokenIndex170, depth170 } depth-- - add(ruleExpressionList, position164) + add(ruleNameArgumentList, position164) } return true l163: position, tokenIndex, depth = position163, tokenIndex163, depth163 return false }, - /* 40 NextExpression <- <(Expression VarArgs?)> */ + /* 40 NextNameArgument <- <(ws Name ws '=' ws Expression ws)> */ func() bool { - position167, tokenIndex167, depth167 := position, tokenIndex, depth + position171, tokenIndex171, depth171 := position, tokenIndex, depth { - position168 := position + position172 := position depth++ + if !_rules[rulews]() { + goto l171 + } + if !_rules[ruleName]() { + goto l171 + } + if !_rules[rulews]() { + goto l171 + } + if buffer[position] != rune('=') { + goto l171 + } + position++ + if !_rules[rulews]() { + goto l171 + } if !_rules[ruleExpression]() { - goto l167 + goto l171 } + if !_rules[rulews]() { + goto l171 + } + depth-- + add(ruleNextNameArgument, position172) + } + return true + l171: + position, tokenIndex, depth = position171, tokenIndex171, depth171 + return false + }, + /* 41 ExpressionList <- <(NextExpression (',' NextExpression)*)> */ + func() bool { + position173, tokenIndex173, depth173 := position, tokenIndex, depth + { + position174 := position + depth++ + if !_rules[ruleNextExpression]() { + goto l173 + } + l175: { - position169, tokenIndex169, depth169 := position, tokenIndex, depth - if !_rules[ruleVarArgs]() { - goto l169 + position176, tokenIndex176, depth176 := position, tokenIndex, depth + if buffer[position] != rune(',') { + goto l176 + } + position++ + if !_rules[ruleNextExpression]() { + goto l176 } - goto l170 - l169: - position, tokenIndex, depth = position169, tokenIndex169, depth169 + goto l175 + l176: + position, tokenIndex, depth = position176, tokenIndex176, depth176 } - l170: depth-- - add(ruleNextExpression, position168) + add(ruleExpressionList, position174) } return true - l167: - position, tokenIndex, depth = position167, tokenIndex167, depth167 + l173: + position, tokenIndex, depth = position173, tokenIndex173, depth173 return false }, - /* 41 VarArgs <- <('.' '.' '.' ws)> */ + /* 42 NextExpression <- <(Expression ListExpansion?)> */ func() bool { - position171, tokenIndex171, depth171 := position, tokenIndex, depth + position177, tokenIndex177, depth177 := position, tokenIndex, depth { - position172 := position + position178 := position + depth++ + if !_rules[ruleExpression]() { + goto l177 + } + { + position179, tokenIndex179, depth179 := position, tokenIndex, depth + if !_rules[ruleListExpansion]() { + goto l179 + } + goto l180 + l179: + position, tokenIndex, depth = position179, tokenIndex179, depth179 + } + l180: + depth-- + add(ruleNextExpression, position178) + } + return true + l177: + position, tokenIndex, depth = position177, tokenIndex177, depth177 + return false + }, + /* 43 ListExpansion <- <('.' '.' '.' ws)> */ + func() bool { + position181, tokenIndex181, depth181 := position, tokenIndex, depth + { + position182 := position depth++ if buffer[position] != rune('.') { - goto l171 + goto l181 } position++ if buffer[position] != rune('.') { - goto l171 + goto l181 } position++ if buffer[position] != rune('.') { - goto l171 + goto l181 } position++ if !_rules[rulews]() { - goto l171 + goto l181 } depth-- - add(ruleVarArgs, position172) + add(ruleListExpansion, position182) } return true - l171: - position, tokenIndex, depth = position171, tokenIndex171, depth171 + l181: + position, tokenIndex, depth = position181, tokenIndex181, depth181 return false }, - /* 42 Projection <- <('.'? (('[' '*' ']') / Slice) ProjectionValue ChainedQualifiedExpression*)> */ + /* 44 Projection <- <('.'? (('[' '*' ']') / Slice) ProjectionValue ChainedQualifiedExpression*)> */ func() bool { - position173, tokenIndex173, depth173 := position, tokenIndex, depth + position183, tokenIndex183, depth183 := position, tokenIndex, depth { - position174 := position + position184 := position depth++ { - position175, tokenIndex175, depth175 := position, tokenIndex, depth + position185, tokenIndex185, depth185 := position, tokenIndex, depth if buffer[position] != rune('.') { - goto l175 + goto l185 } position++ - goto l176 - l175: - position, tokenIndex, depth = position175, tokenIndex175, depth175 + goto l186 + l185: + position, tokenIndex, depth = position185, tokenIndex185, depth185 } - l176: + l186: { - position177, tokenIndex177, depth177 := position, tokenIndex, depth + position187, tokenIndex187, depth187 := position, tokenIndex, depth if buffer[position] != rune('[') { - goto l178 + goto l188 } position++ if buffer[position] != rune('*') { - goto l178 + goto l188 } position++ if buffer[position] != rune(']') { - goto l178 + goto l188 } position++ - goto l177 - l178: - position, tokenIndex, depth = position177, tokenIndex177, depth177 + goto l187 + l188: + position, tokenIndex, depth = position187, tokenIndex187, depth187 if !_rules[ruleSlice]() { - goto l173 + goto l183 } } - l177: + l187: if !_rules[ruleProjectionValue]() { - goto l173 + goto l183 } - l179: + l189: { - position180, tokenIndex180, depth180 := position, tokenIndex, depth + position190, tokenIndex190, depth190 := position, tokenIndex, depth if !_rules[ruleChainedQualifiedExpression]() { - goto l180 + goto l190 } - goto l179 - l180: - position, tokenIndex, depth = position180, tokenIndex180, depth180 + goto l189 + l190: + position, tokenIndex, depth = position190, tokenIndex190, depth190 } depth-- - add(ruleProjection, position174) + add(ruleProjection, position184) } return true - l173: - position, tokenIndex, depth = position173, tokenIndex173, depth173 + l183: + position, tokenIndex, depth = position183, tokenIndex183, depth183 return false }, - /* 43 ProjectionValue <- */ + /* 45 ProjectionValue <- */ func() bool { - position181, tokenIndex181, depth181 := position, tokenIndex, depth + position191, tokenIndex191, depth191 := position, tokenIndex, depth { - position182 := position + position192 := position depth++ if !_rules[ruleAction0]() { - goto l181 + goto l191 } depth-- - add(ruleProjectionValue, position182) + add(ruleProjectionValue, position192) } return true - l181: - position, tokenIndex, depth = position181, tokenIndex181, depth181 + l191: + position, tokenIndex, depth = position191, tokenIndex191, depth191 return false }, - /* 44 Substitution <- <('*' Level0)> */ + /* 46 Substitution <- <('*' Level0)> */ func() bool { - position183, tokenIndex183, depth183 := position, tokenIndex, depth + position193, tokenIndex193, depth193 := position, tokenIndex, depth { - position184 := position + position194 := position depth++ if buffer[position] != rune('*') { - goto l183 + goto l193 } position++ if !_rules[ruleLevel0]() { - goto l183 + goto l193 } depth-- - add(ruleSubstitution, position184) + add(ruleSubstitution, position194) } return true - l183: - position, tokenIndex, depth = position183, tokenIndex183, depth183 + l193: + position, tokenIndex, depth = position193, tokenIndex193, depth193 return false }, - /* 45 Not <- <('!' ws Level0)> */ + /* 47 Not <- <('!' ws Level0)> */ func() bool { - position185, tokenIndex185, depth185 := position, tokenIndex, depth + position195, tokenIndex195, depth195 := position, tokenIndex, depth { - position186 := position + position196 := position depth++ if buffer[position] != rune('!') { - goto l185 + goto l195 } position++ if !_rules[rulews]() { - goto l185 + goto l195 } if !_rules[ruleLevel0]() { - goto l185 + goto l195 } depth-- - add(ruleNot, position186) + add(ruleNot, position196) } return true - l185: - position, tokenIndex, depth = position185, tokenIndex185, depth185 + l195: + position, tokenIndex, depth = position195, tokenIndex195, depth195 return false }, - /* 46 Grouped <- <('(' Expression ')')> */ + /* 48 Grouped <- <('(' Expression ')')> */ func() bool { - position187, tokenIndex187, depth187 := position, tokenIndex, depth + position197, tokenIndex197, depth197 := position, tokenIndex, depth { - position188 := position + position198 := position depth++ if buffer[position] != rune('(') { - goto l187 + goto l197 } position++ if !_rules[ruleExpression]() { - goto l187 + goto l197 } if buffer[position] != rune(')') { - goto l187 + goto l197 } position++ depth-- - add(ruleGrouped, position188) + add(ruleGrouped, position198) } return true - l187: - position, tokenIndex, depth = position187, tokenIndex187, depth187 + l197: + position, tokenIndex, depth = position197, tokenIndex197, depth197 return false }, - /* 47 Range <- <(StartRange Expression? RangeOp Expression? ']')> */ + /* 49 Range <- <(StartRange Expression? RangeOp Expression? ']')> */ func() bool { - position189, tokenIndex189, depth189 := position, tokenIndex, depth + position199, tokenIndex199, depth199 := position, tokenIndex, depth { - position190 := position + position200 := position depth++ if !_rules[ruleStartRange]() { - goto l189 + goto l199 } { - position191, tokenIndex191, depth191 := position, tokenIndex, depth + position201, tokenIndex201, depth201 := position, tokenIndex, depth if !_rules[ruleExpression]() { - goto l191 + goto l201 } - goto l192 - l191: - position, tokenIndex, depth = position191, tokenIndex191, depth191 + goto l202 + l201: + position, tokenIndex, depth = position201, tokenIndex201, depth201 } - l192: + l202: if !_rules[ruleRangeOp]() { - goto l189 + goto l199 } { - position193, tokenIndex193, depth193 := position, tokenIndex, depth + position203, tokenIndex203, depth203 := position, tokenIndex, depth if !_rules[ruleExpression]() { - goto l193 + goto l203 } - goto l194 - l193: - position, tokenIndex, depth = position193, tokenIndex193, depth193 + goto l204 + l203: + position, tokenIndex, depth = position203, tokenIndex203, depth203 } - l194: + l204: if buffer[position] != rune(']') { - goto l189 + goto l199 } position++ depth-- - add(ruleRange, position190) + add(ruleRange, position200) } return true - l189: - position, tokenIndex, depth = position189, tokenIndex189, depth189 + l199: + position, tokenIndex, depth = position199, tokenIndex199, depth199 return false }, - /* 48 StartRange <- <'['> */ + /* 50 StartRange <- <'['> */ func() bool { - position195, tokenIndex195, depth195 := position, tokenIndex, depth + position205, tokenIndex205, depth205 := position, tokenIndex, depth { - position196 := position + position206 := position depth++ if buffer[position] != rune('[') { - goto l195 + goto l205 } position++ depth-- - add(ruleStartRange, position196) + add(ruleStartRange, position206) } return true - l195: - position, tokenIndex, depth = position195, tokenIndex195, depth195 + l205: + position, tokenIndex, depth = position205, tokenIndex205, depth205 return false }, - /* 49 RangeOp <- <('.' '.')> */ + /* 51 RangeOp <- <('.' '.')> */ func() bool { - position197, tokenIndex197, depth197 := position, tokenIndex, depth + position207, tokenIndex207, depth207 := position, tokenIndex, depth { - position198 := position + position208 := position depth++ if buffer[position] != rune('.') { - goto l197 + goto l207 } position++ if buffer[position] != rune('.') { - goto l197 + goto l207 } position++ depth-- - add(ruleRangeOp, position198) + add(ruleRangeOp, position208) } return true - l197: - position, tokenIndex, depth = position197, tokenIndex197, depth197 + l207: + position, tokenIndex, depth = position207, tokenIndex207, depth207 return false }, - /* 50 Integer <- <('-'? [0-9] ([0-9] / '_')*)> */ + /* 52 Integer <- <('-'? [0-9] ([0-9] / '_')*)> */ func() bool { - position199, tokenIndex199, depth199 := position, tokenIndex, depth + position209, tokenIndex209, depth209 := position, tokenIndex, depth { - position200 := position + position210 := position depth++ { - position201, tokenIndex201, depth201 := position, tokenIndex, depth + position211, tokenIndex211, depth211 := position, tokenIndex, depth if buffer[position] != rune('-') { - goto l201 + goto l211 } position++ - goto l202 - l201: - position, tokenIndex, depth = position201, tokenIndex201, depth201 + goto l212 + l211: + position, tokenIndex, depth = position211, tokenIndex211, depth211 } - l202: + l212: if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l199 + goto l209 } position++ - l203: + l213: { - position204, tokenIndex204, depth204 := position, tokenIndex, depth + position214, tokenIndex214, depth214 := position, tokenIndex, depth { - position205, tokenIndex205, depth205 := position, tokenIndex, depth + position215, tokenIndex215, depth215 := position, tokenIndex, depth if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l206 + goto l216 } position++ - goto l205 - l206: - position, tokenIndex, depth = position205, tokenIndex205, depth205 + goto l215 + l216: + position, tokenIndex, depth = position215, tokenIndex215, depth215 if buffer[position] != rune('_') { - goto l204 + goto l214 } position++ } - l205: - goto l203 - l204: - position, tokenIndex, depth = position204, tokenIndex204, depth204 + l215: + goto l213 + l214: + position, tokenIndex, depth = position214, tokenIndex214, depth214 } depth-- - add(ruleInteger, position200) + add(ruleInteger, position210) } return true - l199: - position, tokenIndex, depth = position199, tokenIndex199, depth199 + l209: + position, tokenIndex, depth = position209, tokenIndex209, depth209 return false }, - /* 51 String <- <('"' (('\\' '"') / (!'"' .))* '"')> */ + /* 53 String <- <('"' (('\\' '"') / (!'"' .))* '"')> */ func() bool { - position207, tokenIndex207, depth207 := position, tokenIndex, depth + position217, tokenIndex217, depth217 := position, tokenIndex, depth { - position208 := position + position218 := position depth++ if buffer[position] != rune('"') { - goto l207 + goto l217 } position++ - l209: + l219: { - position210, tokenIndex210, depth210 := position, tokenIndex, depth + position220, tokenIndex220, depth220 := position, tokenIndex, depth { - position211, tokenIndex211, depth211 := position, tokenIndex, depth + position221, tokenIndex221, depth221 := position, tokenIndex, depth if buffer[position] != rune('\\') { - goto l212 + goto l222 } position++ if buffer[position] != rune('"') { - goto l212 + goto l222 } position++ - goto l211 - l212: - position, tokenIndex, depth = position211, tokenIndex211, depth211 + goto l221 + l222: + position, tokenIndex, depth = position221, tokenIndex221, depth221 { - position213, tokenIndex213, depth213 := position, tokenIndex, depth + position223, tokenIndex223, depth223 := position, tokenIndex, depth if buffer[position] != rune('"') { - goto l213 + goto l223 } position++ - goto l210 - l213: - position, tokenIndex, depth = position213, tokenIndex213, depth213 + goto l220 + l223: + position, tokenIndex, depth = position223, tokenIndex223, depth223 } if !matchDot() { - goto l210 + goto l220 } } - l211: - goto l209 - l210: - position, tokenIndex, depth = position210, tokenIndex210, depth210 + l221: + goto l219 + l220: + position, tokenIndex, depth = position220, tokenIndex220, depth220 } if buffer[position] != rune('"') { - goto l207 + goto l217 } position++ depth-- - add(ruleString, position208) + add(ruleString, position218) } return true - l207: - position, tokenIndex, depth = position207, tokenIndex207, depth207 + l217: + position, tokenIndex, depth = position217, tokenIndex217, depth217 return false }, - /* 52 Boolean <- <(('t' 'r' 'u' 'e') / ('f' 'a' 'l' 's' 'e'))> */ + /* 54 Boolean <- <(('t' 'r' 'u' 'e') / ('f' 'a' 'l' 's' 'e'))> */ func() bool { - position214, tokenIndex214, depth214 := position, tokenIndex, depth + position224, tokenIndex224, depth224 := position, tokenIndex, depth { - position215 := position + position225 := position depth++ { - position216, tokenIndex216, depth216 := position, tokenIndex, depth + position226, tokenIndex226, depth226 := position, tokenIndex, depth if buffer[position] != rune('t') { - goto l217 + goto l227 } position++ if buffer[position] != rune('r') { - goto l217 + goto l227 } position++ if buffer[position] != rune('u') { - goto l217 + goto l227 } position++ if buffer[position] != rune('e') { - goto l217 + goto l227 } position++ - goto l216 - l217: - position, tokenIndex, depth = position216, tokenIndex216, depth216 + goto l226 + l227: + position, tokenIndex, depth = position226, tokenIndex226, depth226 if buffer[position] != rune('f') { - goto l214 + goto l224 } position++ if buffer[position] != rune('a') { - goto l214 + goto l224 } position++ if buffer[position] != rune('l') { - goto l214 + goto l224 } position++ if buffer[position] != rune('s') { - goto l214 + goto l224 } position++ if buffer[position] != rune('e') { - goto l214 + goto l224 } position++ } - l216: + l226: depth-- - add(ruleBoolean, position215) + add(ruleBoolean, position225) } return true - l214: - position, tokenIndex, depth = position214, tokenIndex214, depth214 + l224: + position, tokenIndex, depth = position224, tokenIndex224, depth224 return false }, - /* 53 Nil <- <(('n' 'i' 'l') / '~')> */ + /* 55 Nil <- <(('n' 'i' 'l') / '~')> */ func() bool { - position218, tokenIndex218, depth218 := position, tokenIndex, depth + position228, tokenIndex228, depth228 := position, tokenIndex, depth { - position219 := position + position229 := position depth++ { - position220, tokenIndex220, depth220 := position, tokenIndex, depth + position230, tokenIndex230, depth230 := position, tokenIndex, depth if buffer[position] != rune('n') { - goto l221 + goto l231 } position++ if buffer[position] != rune('i') { - goto l221 + goto l231 } position++ if buffer[position] != rune('l') { - goto l221 + goto l231 } position++ - goto l220 - l221: - position, tokenIndex, depth = position220, tokenIndex220, depth220 + goto l230 + l231: + position, tokenIndex, depth = position230, tokenIndex230, depth230 if buffer[position] != rune('~') { - goto l218 + goto l228 } position++ } - l220: + l230: depth-- - add(ruleNil, position219) + add(ruleNil, position229) } return true - l218: - position, tokenIndex, depth = position218, tokenIndex218, depth218 + l228: + position, tokenIndex, depth = position228, tokenIndex228, depth228 return false }, - /* 54 Undefined <- <('~' '~')> */ + /* 56 Undefined <- <('~' '~')> */ func() bool { - position222, tokenIndex222, depth222 := position, tokenIndex, depth + position232, tokenIndex232, depth232 := position, tokenIndex, depth { - position223 := position + position233 := position depth++ if buffer[position] != rune('~') { - goto l222 + goto l232 } position++ if buffer[position] != rune('~') { - goto l222 + goto l232 } position++ depth-- - add(ruleUndefined, position223) + add(ruleUndefined, position233) } return true - l222: - position, tokenIndex, depth = position222, tokenIndex222, depth222 + l232: + position, tokenIndex, depth = position232, tokenIndex232, depth232 return false }, - /* 55 Symbol <- <('$' Name)> */ + /* 57 Symbol <- <('$' Name)> */ func() bool { - position224, tokenIndex224, depth224 := position, tokenIndex, depth + position234, tokenIndex234, depth234 := position, tokenIndex, depth { - position225 := position + position235 := position depth++ if buffer[position] != rune('$') { - goto l224 + goto l234 } position++ if !_rules[ruleName]() { - goto l224 + goto l234 } depth-- - add(ruleSymbol, position225) + add(ruleSymbol, position235) } return true - l224: - position, tokenIndex, depth = position224, tokenIndex224, depth224 + l234: + position, tokenIndex, depth = position234, tokenIndex234, depth234 return false }, - /* 56 List <- <(StartList ExpressionList? ']')> */ + /* 58 List <- <(StartList ExpressionList? ']')> */ func() bool { - position226, tokenIndex226, depth226 := position, tokenIndex, depth + position236, tokenIndex236, depth236 := position, tokenIndex, depth { - position227 := position + position237 := position depth++ if !_rules[ruleStartList]() { - goto l226 + goto l236 } { - position228, tokenIndex228, depth228 := position, tokenIndex, depth + position238, tokenIndex238, depth238 := position, tokenIndex, depth if !_rules[ruleExpressionList]() { - goto l228 + goto l238 } - goto l229 - l228: - position, tokenIndex, depth = position228, tokenIndex228, depth228 + goto l239 + l238: + position, tokenIndex, depth = position238, tokenIndex238, depth238 } - l229: + l239: if buffer[position] != rune(']') { - goto l226 + goto l236 } position++ depth-- - add(ruleList, position227) + add(ruleList, position237) } return true - l226: - position, tokenIndex, depth = position226, tokenIndex226, depth226 + l236: + position, tokenIndex, depth = position236, tokenIndex236, depth236 return false }, - /* 57 StartList <- <('[' ws)> */ + /* 59 StartList <- <('[' ws)> */ func() bool { - position230, tokenIndex230, depth230 := position, tokenIndex, depth + position240, tokenIndex240, depth240 := position, tokenIndex, depth { - position231 := position + position241 := position depth++ if buffer[position] != rune('[') { - goto l230 + goto l240 } position++ if !_rules[rulews]() { - goto l230 + goto l240 } depth-- - add(ruleStartList, position231) + add(ruleStartList, position241) } return true - l230: - position, tokenIndex, depth = position230, tokenIndex230, depth230 + l240: + position, tokenIndex, depth = position240, tokenIndex240, depth240 return false }, - /* 58 Map <- <(CreateMap ws Assignments? '}')> */ + /* 60 Map <- <(CreateMap ws Assignments? '}')> */ func() bool { - position232, tokenIndex232, depth232 := position, tokenIndex, depth + position242, tokenIndex242, depth242 := position, tokenIndex, depth { - position233 := position + position243 := position depth++ if !_rules[ruleCreateMap]() { - goto l232 + goto l242 } if !_rules[rulews]() { - goto l232 + goto l242 } { - position234, tokenIndex234, depth234 := position, tokenIndex, depth + position244, tokenIndex244, depth244 := position, tokenIndex, depth if !_rules[ruleAssignments]() { - goto l234 + goto l244 } - goto l235 - l234: - position, tokenIndex, depth = position234, tokenIndex234, depth234 + goto l245 + l244: + position, tokenIndex, depth = position244, tokenIndex244, depth244 } - l235: + l245: if buffer[position] != rune('}') { - goto l232 + goto l242 } position++ depth-- - add(ruleMap, position233) + add(ruleMap, position243) } return true - l232: - position, tokenIndex, depth = position232, tokenIndex232, depth232 + l242: + position, tokenIndex, depth = position242, tokenIndex242, depth242 return false }, - /* 59 CreateMap <- <'{'> */ + /* 61 CreateMap <- <'{'> */ func() bool { - position236, tokenIndex236, depth236 := position, tokenIndex, depth + position246, tokenIndex246, depth246 := position, tokenIndex, depth { - position237 := position + position247 := position depth++ if buffer[position] != rune('{') { - goto l236 + goto l246 } position++ depth-- - add(ruleCreateMap, position237) + add(ruleCreateMap, position247) } return true - l236: - position, tokenIndex, depth = position236, tokenIndex236, depth236 + l246: + position, tokenIndex, depth = position246, tokenIndex246, depth246 return false }, - /* 60 Assignments <- <(Assignment (',' Assignment)*)> */ + /* 62 Assignments <- <(Assignment (',' Assignment)*)> */ func() bool { - position238, tokenIndex238, depth238 := position, tokenIndex, depth + position248, tokenIndex248, depth248 := position, tokenIndex, depth { - position239 := position + position249 := position depth++ if !_rules[ruleAssignment]() { - goto l238 + goto l248 } - l240: + l250: { - position241, tokenIndex241, depth241 := position, tokenIndex, depth + position251, tokenIndex251, depth251 := position, tokenIndex, depth if buffer[position] != rune(',') { - goto l241 + goto l251 } position++ if !_rules[ruleAssignment]() { - goto l241 + goto l251 } - goto l240 - l241: - position, tokenIndex, depth = position241, tokenIndex241, depth241 + goto l250 + l251: + position, tokenIndex, depth = position251, tokenIndex251, depth251 } depth-- - add(ruleAssignments, position239) + add(ruleAssignments, position249) } return true - l238: - position, tokenIndex, depth = position238, tokenIndex238, depth238 + l248: + position, tokenIndex, depth = position248, tokenIndex248, depth248 return false }, - /* 61 Assignment <- <(Expression '=' Expression)> */ + /* 63 Assignment <- <(Expression '=' Expression)> */ func() bool { - position242, tokenIndex242, depth242 := position, tokenIndex, depth + position252, tokenIndex252, depth252 := position, tokenIndex, depth { - position243 := position + position253 := position depth++ if !_rules[ruleExpression]() { - goto l242 + goto l252 } if buffer[position] != rune('=') { - goto l242 + goto l252 } position++ if !_rules[ruleExpression]() { - goto l242 + goto l252 } depth-- - add(ruleAssignment, position243) + add(ruleAssignment, position253) } return true - l242: - position, tokenIndex, depth = position242, tokenIndex242, depth242 + l252: + position, tokenIndex, depth = position252, tokenIndex252, depth252 return false }, - /* 62 Merge <- <(RefMerge / SimpleMerge)> */ + /* 64 Merge <- <(RefMerge / SimpleMerge)> */ func() bool { - position244, tokenIndex244, depth244 := position, tokenIndex, depth + position254, tokenIndex254, depth254 := position, tokenIndex, depth { - position245 := position + position255 := position depth++ { - position246, tokenIndex246, depth246 := position, tokenIndex, depth + position256, tokenIndex256, depth256 := position, tokenIndex, depth if !_rules[ruleRefMerge]() { - goto l247 + goto l257 } - goto l246 - l247: - position, tokenIndex, depth = position246, tokenIndex246, depth246 + goto l256 + l257: + position, tokenIndex, depth = position256, tokenIndex256, depth256 if !_rules[ruleSimpleMerge]() { - goto l244 + goto l254 } } - l246: + l256: depth-- - add(ruleMerge, position245) + add(ruleMerge, position255) } return true - l244: - position, tokenIndex, depth = position244, tokenIndex244, depth244 + l254: + position, tokenIndex, depth = position254, tokenIndex254, depth254 return false }, - /* 63 RefMerge <- <('m' 'e' 'r' 'g' 'e' !(req_ws Required) (req_ws (Replace / On))? req_ws Reference)> */ + /* 65 RefMerge <- <('m' 'e' 'r' 'g' 'e' !(req_ws Required) (req_ws (Replace / On))? req_ws Reference)> */ func() bool { - position248, tokenIndex248, depth248 := position, tokenIndex, depth + position258, tokenIndex258, depth258 := position, tokenIndex, depth { - position249 := position + position259 := position depth++ if buffer[position] != rune('m') { - goto l248 + goto l258 } position++ if buffer[position] != rune('e') { - goto l248 + goto l258 } position++ if buffer[position] != rune('r') { - goto l248 + goto l258 } position++ if buffer[position] != rune('g') { - goto l248 + goto l258 } position++ if buffer[position] != rune('e') { - goto l248 + goto l258 } position++ { - position250, tokenIndex250, depth250 := position, tokenIndex, depth + position260, tokenIndex260, depth260 := position, tokenIndex, depth if !_rules[rulereq_ws]() { - goto l250 + goto l260 } if !_rules[ruleRequired]() { - goto l250 + goto l260 } - goto l248 - l250: - position, tokenIndex, depth = position250, tokenIndex250, depth250 + goto l258 + l260: + position, tokenIndex, depth = position260, tokenIndex260, depth260 } { - position251, tokenIndex251, depth251 := position, tokenIndex, depth + position261, tokenIndex261, depth261 := position, tokenIndex, depth if !_rules[rulereq_ws]() { - goto l251 + goto l261 } { - position253, tokenIndex253, depth253 := position, tokenIndex, depth + position263, tokenIndex263, depth263 := position, tokenIndex, depth if !_rules[ruleReplace]() { - goto l254 + goto l264 } - goto l253 - l254: - position, tokenIndex, depth = position253, tokenIndex253, depth253 + goto l263 + l264: + position, tokenIndex, depth = position263, tokenIndex263, depth263 if !_rules[ruleOn]() { - goto l251 + goto l261 } } - l253: - goto l252 - l251: - position, tokenIndex, depth = position251, tokenIndex251, depth251 + l263: + goto l262 + l261: + position, tokenIndex, depth = position261, tokenIndex261, depth261 } - l252: + l262: if !_rules[rulereq_ws]() { - goto l248 + goto l258 } if !_rules[ruleReference]() { - goto l248 + goto l258 } depth-- - add(ruleRefMerge, position249) + add(ruleRefMerge, position259) } return true - l248: - position, tokenIndex, depth = position248, tokenIndex248, depth248 + l258: + position, tokenIndex, depth = position258, tokenIndex258, depth258 return false }, - /* 64 SimpleMerge <- <('m' 'e' 'r' 'g' 'e' !'(' (req_ws (Replace / Required / On))?)> */ + /* 66 SimpleMerge <- <('m' 'e' 'r' 'g' 'e' !'(' (req_ws (Replace / Required / On))?)> */ func() bool { - position255, tokenIndex255, depth255 := position, tokenIndex, depth + position265, tokenIndex265, depth265 := position, tokenIndex, depth { - position256 := position + position266 := position depth++ if buffer[position] != rune('m') { - goto l255 + goto l265 } position++ if buffer[position] != rune('e') { - goto l255 + goto l265 } position++ if buffer[position] != rune('r') { - goto l255 + goto l265 } position++ if buffer[position] != rune('g') { - goto l255 + goto l265 } position++ if buffer[position] != rune('e') { - goto l255 + goto l265 } position++ { - position257, tokenIndex257, depth257 := position, tokenIndex, depth + position267, tokenIndex267, depth267 := position, tokenIndex, depth if buffer[position] != rune('(') { - goto l257 + goto l267 } position++ - goto l255 - l257: - position, tokenIndex, depth = position257, tokenIndex257, depth257 + goto l265 + l267: + position, tokenIndex, depth = position267, tokenIndex267, depth267 } { - position258, tokenIndex258, depth258 := position, tokenIndex, depth + position268, tokenIndex268, depth268 := position, tokenIndex, depth if !_rules[rulereq_ws]() { - goto l258 + goto l268 } { - position260, tokenIndex260, depth260 := position, tokenIndex, depth + position270, tokenIndex270, depth270 := position, tokenIndex, depth if !_rules[ruleReplace]() { - goto l261 + goto l271 } - goto l260 - l261: - position, tokenIndex, depth = position260, tokenIndex260, depth260 + goto l270 + l271: + position, tokenIndex, depth = position270, tokenIndex270, depth270 if !_rules[ruleRequired]() { - goto l262 + goto l272 } - goto l260 - l262: - position, tokenIndex, depth = position260, tokenIndex260, depth260 + goto l270 + l272: + position, tokenIndex, depth = position270, tokenIndex270, depth270 if !_rules[ruleOn]() { - goto l258 + goto l268 } } - l260: - goto l259 - l258: - position, tokenIndex, depth = position258, tokenIndex258, depth258 + l270: + goto l269 + l268: + position, tokenIndex, depth = position268, tokenIndex268, depth268 } - l259: + l269: depth-- - add(ruleSimpleMerge, position256) + add(ruleSimpleMerge, position266) } return true - l255: - position, tokenIndex, depth = position255, tokenIndex255, depth255 + l265: + position, tokenIndex, depth = position265, tokenIndex265, depth265 return false }, - /* 65 Replace <- <('r' 'e' 'p' 'l' 'a' 'c' 'e')> */ + /* 67 Replace <- <('r' 'e' 'p' 'l' 'a' 'c' 'e')> */ func() bool { - position263, tokenIndex263, depth263 := position, tokenIndex, depth + position273, tokenIndex273, depth273 := position, tokenIndex, depth { - position264 := position + position274 := position depth++ if buffer[position] != rune('r') { - goto l263 + goto l273 } position++ if buffer[position] != rune('e') { - goto l263 + goto l273 } position++ if buffer[position] != rune('p') { - goto l263 + goto l273 } position++ if buffer[position] != rune('l') { - goto l263 + goto l273 } position++ if buffer[position] != rune('a') { - goto l263 + goto l273 } position++ if buffer[position] != rune('c') { - goto l263 + goto l273 } position++ if buffer[position] != rune('e') { - goto l263 + goto l273 } position++ depth-- - add(ruleReplace, position264) + add(ruleReplace, position274) } return true - l263: - position, tokenIndex, depth = position263, tokenIndex263, depth263 + l273: + position, tokenIndex, depth = position273, tokenIndex273, depth273 return false }, - /* 66 Required <- <('r' 'e' 'q' 'u' 'i' 'r' 'e' 'd')> */ + /* 68 Required <- <('r' 'e' 'q' 'u' 'i' 'r' 'e' 'd')> */ func() bool { - position265, tokenIndex265, depth265 := position, tokenIndex, depth + position275, tokenIndex275, depth275 := position, tokenIndex, depth { - position266 := position + position276 := position depth++ if buffer[position] != rune('r') { - goto l265 + goto l275 } position++ if buffer[position] != rune('e') { - goto l265 + goto l275 } position++ if buffer[position] != rune('q') { - goto l265 + goto l275 } position++ if buffer[position] != rune('u') { - goto l265 + goto l275 } position++ if buffer[position] != rune('i') { - goto l265 + goto l275 } position++ if buffer[position] != rune('r') { - goto l265 + goto l275 } position++ if buffer[position] != rune('e') { - goto l265 + goto l275 } position++ if buffer[position] != rune('d') { - goto l265 + goto l275 } position++ depth-- - add(ruleRequired, position266) + add(ruleRequired, position276) } return true - l265: - position, tokenIndex, depth = position265, tokenIndex265, depth265 + l275: + position, tokenIndex, depth = position275, tokenIndex275, depth275 return false }, - /* 67 On <- <('o' 'n' req_ws Name)> */ + /* 69 On <- <('o' 'n' req_ws Name)> */ func() bool { - position267, tokenIndex267, depth267 := position, tokenIndex, depth + position277, tokenIndex277, depth277 := position, tokenIndex, depth { - position268 := position + position278 := position depth++ if buffer[position] != rune('o') { - goto l267 + goto l277 } position++ if buffer[position] != rune('n') { - goto l267 + goto l277 } position++ if !_rules[rulereq_ws]() { - goto l267 + goto l277 } if !_rules[ruleName]() { - goto l267 + goto l277 } depth-- - add(ruleOn, position268) + add(ruleOn, position278) } return true - l267: - position, tokenIndex, depth = position267, tokenIndex267, depth267 + l277: + position, tokenIndex, depth = position277, tokenIndex277, depth277 return false }, - /* 68 Auto <- <('a' 'u' 't' 'o')> */ + /* 70 Auto <- <('a' 'u' 't' 'o')> */ func() bool { - position269, tokenIndex269, depth269 := position, tokenIndex, depth + position279, tokenIndex279, depth279 := position, tokenIndex, depth { - position270 := position + position280 := position depth++ if buffer[position] != rune('a') { - goto l269 + goto l279 } position++ if buffer[position] != rune('u') { - goto l269 + goto l279 } position++ if buffer[position] != rune('t') { - goto l269 + goto l279 } position++ if buffer[position] != rune('o') { - goto l269 + goto l279 } position++ depth-- - add(ruleAuto, position270) + add(ruleAuto, position280) } return true - l269: - position, tokenIndex, depth = position269, tokenIndex269, depth269 + l279: + position, tokenIndex, depth = position279, tokenIndex279, depth279 return false }, - /* 69 Default <- */ + /* 71 Default <- */ func() bool { - position271, tokenIndex271, depth271 := position, tokenIndex, depth + position281, tokenIndex281, depth281 := position, tokenIndex, depth { - position272 := position + position282 := position depth++ if !_rules[ruleAction1]() { - goto l271 + goto l281 } depth-- - add(ruleDefault, position272) + add(ruleDefault, position282) } return true - l271: - position, tokenIndex, depth = position271, tokenIndex271, depth271 + l281: + position, tokenIndex, depth = position281, tokenIndex281, depth281 return false }, - /* 70 Sync <- <('s' 'y' 'n' 'c' '[' Level7 ((((LambdaExpr LambdaExt) / (LambdaOrExpr LambdaOrExpr)) (('|' Expression) / Default)) / (LambdaOrExpr Default Default)) ']')> */ + /* 72 Sync <- <('s' 'y' 'n' 'c' '[' Level7 ((((LambdaExpr LambdaExt) / (LambdaOrExpr LambdaOrExpr)) (('|' Expression) / Default)) / (LambdaOrExpr Default Default)) ']')> */ func() bool { - position273, tokenIndex273, depth273 := position, tokenIndex, depth + position283, tokenIndex283, depth283 := position, tokenIndex, depth { - position274 := position + position284 := position depth++ if buffer[position] != rune('s') { - goto l273 + goto l283 } position++ if buffer[position] != rune('y') { - goto l273 + goto l283 } position++ if buffer[position] != rune('n') { - goto l273 + goto l283 } position++ if buffer[position] != rune('c') { - goto l273 + goto l283 } position++ if buffer[position] != rune('[') { - goto l273 + goto l283 } position++ if !_rules[ruleLevel7]() { - goto l273 + goto l283 } { - position275, tokenIndex275, depth275 := position, tokenIndex, depth + position285, tokenIndex285, depth285 := position, tokenIndex, depth { - position277, tokenIndex277, depth277 := position, tokenIndex, depth + position287, tokenIndex287, depth287 := position, tokenIndex, depth if !_rules[ruleLambdaExpr]() { - goto l278 + goto l288 } if !_rules[ruleLambdaExt]() { - goto l278 + goto l288 } - goto l277 - l278: - position, tokenIndex, depth = position277, tokenIndex277, depth277 + goto l287 + l288: + position, tokenIndex, depth = position287, tokenIndex287, depth287 if !_rules[ruleLambdaOrExpr]() { - goto l276 + goto l286 } if !_rules[ruleLambdaOrExpr]() { - goto l276 + goto l286 } } - l277: + l287: { - position279, tokenIndex279, depth279 := position, tokenIndex, depth + position289, tokenIndex289, depth289 := position, tokenIndex, depth if buffer[position] != rune('|') { - goto l280 + goto l290 } position++ if !_rules[ruleExpression]() { - goto l280 + goto l290 } - goto l279 - l280: - position, tokenIndex, depth = position279, tokenIndex279, depth279 + goto l289 + l290: + position, tokenIndex, depth = position289, tokenIndex289, depth289 if !_rules[ruleDefault]() { - goto l276 + goto l286 } } - l279: - goto l275 - l276: - position, tokenIndex, depth = position275, tokenIndex275, depth275 + l289: + goto l285 + l286: + position, tokenIndex, depth = position285, tokenIndex285, depth285 if !_rules[ruleLambdaOrExpr]() { - goto l273 + goto l283 } if !_rules[ruleDefault]() { - goto l273 + goto l283 } if !_rules[ruleDefault]() { - goto l273 + goto l283 } } - l275: + l285: if buffer[position] != rune(']') { - goto l273 + goto l283 } position++ depth-- - add(ruleSync, position274) + add(ruleSync, position284) } return true - l273: - position, tokenIndex, depth = position273, tokenIndex273, depth273 + l283: + position, tokenIndex, depth = position283, tokenIndex283, depth283 return false }, - /* 71 LambdaExt <- <(',' Expression)> */ + /* 73 LambdaExt <- <(',' Expression)> */ func() bool { - position281, tokenIndex281, depth281 := position, tokenIndex, depth + position291, tokenIndex291, depth291 := position, tokenIndex, depth { - position282 := position + position292 := position depth++ if buffer[position] != rune(',') { - goto l281 + goto l291 } position++ if !_rules[ruleExpression]() { - goto l281 + goto l291 } depth-- - add(ruleLambdaExt, position282) + add(ruleLambdaExt, position292) } return true - l281: - position, tokenIndex, depth = position281, tokenIndex281, depth281 + l291: + position, tokenIndex, depth = position291, tokenIndex291, depth291 return false }, - /* 72 LambdaOrExpr <- <(LambdaExpr / ('|' Expression))> */ + /* 74 LambdaOrExpr <- <(LambdaExpr / ('|' Expression))> */ func() bool { - position283, tokenIndex283, depth283 := position, tokenIndex, depth + position293, tokenIndex293, depth293 := position, tokenIndex, depth { - position284 := position + position294 := position depth++ { - position285, tokenIndex285, depth285 := position, tokenIndex, depth + position295, tokenIndex295, depth295 := position, tokenIndex, depth if !_rules[ruleLambdaExpr]() { - goto l286 + goto l296 } - goto l285 - l286: - position, tokenIndex, depth = position285, tokenIndex285, depth285 + goto l295 + l296: + position, tokenIndex, depth = position295, tokenIndex295, depth295 if buffer[position] != rune('|') { - goto l283 + goto l293 } position++ if !_rules[ruleExpression]() { - goto l283 + goto l293 } } - l285: + l295: depth-- - add(ruleLambdaOrExpr, position284) + add(ruleLambdaOrExpr, position294) } return true - l283: - position, tokenIndex, depth = position283, tokenIndex283, depth283 + l293: + position, tokenIndex, depth = position293, tokenIndex293, depth293 return false }, - /* 73 Catch <- <('c' 'a' 't' 'c' 'h' '[' Level7 LambdaOrExpr ']')> */ + /* 75 Catch <- <('c' 'a' 't' 'c' 'h' '[' Level7 LambdaOrExpr ']')> */ func() bool { - position287, tokenIndex287, depth287 := position, tokenIndex, depth + position297, tokenIndex297, depth297 := position, tokenIndex, depth { - position288 := position + position298 := position depth++ if buffer[position] != rune('c') { - goto l287 + goto l297 } position++ if buffer[position] != rune('a') { - goto l287 + goto l297 } position++ if buffer[position] != rune('t') { - goto l287 + goto l297 } position++ if buffer[position] != rune('c') { - goto l287 + goto l297 } position++ if buffer[position] != rune('h') { - goto l287 + goto l297 } position++ if buffer[position] != rune('[') { - goto l287 + goto l297 } position++ if !_rules[ruleLevel7]() { - goto l287 + goto l297 } if !_rules[ruleLambdaOrExpr]() { - goto l287 + goto l297 } if buffer[position] != rune(']') { - goto l287 + goto l297 } position++ depth-- - add(ruleCatch, position288) + add(ruleCatch, position298) } return true - l287: - position, tokenIndex, depth = position287, tokenIndex287, depth287 + l297: + position, tokenIndex, depth = position297, tokenIndex297, depth297 return false }, - /* 74 MapMapping <- <('m' 'a' 'p' '{' Level7 LambdaOrExpr '}')> */ + /* 76 MapMapping <- <('m' 'a' 'p' '{' Level7 LambdaOrExpr '}')> */ func() bool { - position289, tokenIndex289, depth289 := position, tokenIndex, depth + position299, tokenIndex299, depth299 := position, tokenIndex, depth { - position290 := position + position300 := position depth++ if buffer[position] != rune('m') { - goto l289 + goto l299 } position++ if buffer[position] != rune('a') { - goto l289 + goto l299 } position++ if buffer[position] != rune('p') { - goto l289 + goto l299 } position++ if buffer[position] != rune('{') { - goto l289 + goto l299 } position++ if !_rules[ruleLevel7]() { - goto l289 + goto l299 } if !_rules[ruleLambdaOrExpr]() { - goto l289 + goto l299 } if buffer[position] != rune('}') { - goto l289 + goto l299 } position++ depth-- - add(ruleMapMapping, position290) + add(ruleMapMapping, position300) } return true - l289: - position, tokenIndex, depth = position289, tokenIndex289, depth289 + l299: + position, tokenIndex, depth = position299, tokenIndex299, depth299 return false }, - /* 75 Mapping <- <('m' 'a' 'p' '[' Level7 LambdaOrExpr ']')> */ + /* 77 Mapping <- <('m' 'a' 'p' '[' Level7 LambdaOrExpr ']')> */ func() bool { - position291, tokenIndex291, depth291 := position, tokenIndex, depth + position301, tokenIndex301, depth301 := position, tokenIndex, depth { - position292 := position + position302 := position depth++ if buffer[position] != rune('m') { - goto l291 + goto l301 } position++ if buffer[position] != rune('a') { - goto l291 + goto l301 } position++ if buffer[position] != rune('p') { - goto l291 + goto l301 } position++ if buffer[position] != rune('[') { - goto l291 + goto l301 } position++ if !_rules[ruleLevel7]() { - goto l291 + goto l301 } if !_rules[ruleLambdaOrExpr]() { - goto l291 + goto l301 } if buffer[position] != rune(']') { - goto l291 + goto l301 } position++ depth-- - add(ruleMapping, position292) + add(ruleMapping, position302) } return true - l291: - position, tokenIndex, depth = position291, tokenIndex291, depth291 + l301: + position, tokenIndex, depth = position301, tokenIndex301, depth301 return false }, - /* 76 MapSelection <- <('s' 'e' 'l' 'e' 'c' 't' '{' Level7 LambdaOrExpr '}')> */ + /* 78 MapSelection <- <('s' 'e' 'l' 'e' 'c' 't' '{' Level7 LambdaOrExpr '}')> */ func() bool { - position293, tokenIndex293, depth293 := position, tokenIndex, depth + position303, tokenIndex303, depth303 := position, tokenIndex, depth { - position294 := position + position304 := position depth++ if buffer[position] != rune('s') { - goto l293 + goto l303 } position++ if buffer[position] != rune('e') { - goto l293 + goto l303 } position++ if buffer[position] != rune('l') { - goto l293 + goto l303 } position++ if buffer[position] != rune('e') { - goto l293 + goto l303 } position++ if buffer[position] != rune('c') { - goto l293 + goto l303 } position++ if buffer[position] != rune('t') { - goto l293 + goto l303 } position++ if buffer[position] != rune('{') { - goto l293 + goto l303 } position++ if !_rules[ruleLevel7]() { - goto l293 + goto l303 } if !_rules[ruleLambdaOrExpr]() { - goto l293 + goto l303 } if buffer[position] != rune('}') { - goto l293 + goto l303 } position++ depth-- - add(ruleMapSelection, position294) + add(ruleMapSelection, position304) } return true - l293: - position, tokenIndex, depth = position293, tokenIndex293, depth293 + l303: + position, tokenIndex, depth = position303, tokenIndex303, depth303 return false }, - /* 77 Selection <- <('s' 'e' 'l' 'e' 'c' 't' '[' Level7 LambdaOrExpr ']')> */ + /* 79 Selection <- <('s' 'e' 'l' 'e' 'c' 't' '[' Level7 LambdaOrExpr ']')> */ func() bool { - position295, tokenIndex295, depth295 := position, tokenIndex, depth + position305, tokenIndex305, depth305 := position, tokenIndex, depth { - position296 := position + position306 := position depth++ if buffer[position] != rune('s') { - goto l295 + goto l305 } position++ if buffer[position] != rune('e') { - goto l295 + goto l305 } position++ if buffer[position] != rune('l') { - goto l295 + goto l305 } position++ if buffer[position] != rune('e') { - goto l295 + goto l305 } position++ if buffer[position] != rune('c') { - goto l295 + goto l305 } position++ if buffer[position] != rune('t') { - goto l295 + goto l305 } position++ if buffer[position] != rune('[') { - goto l295 + goto l305 } position++ if !_rules[ruleLevel7]() { - goto l295 + goto l305 } if !_rules[ruleLambdaOrExpr]() { - goto l295 + goto l305 } if buffer[position] != rune(']') { - goto l295 + goto l305 } position++ depth-- - add(ruleSelection, position296) + add(ruleSelection, position306) } return true - l295: - position, tokenIndex, depth = position295, tokenIndex295, depth295 + l305: + position, tokenIndex, depth = position305, tokenIndex305, depth305 return false }, - /* 78 Sum <- <('s' 'u' 'm' '[' Level7 '|' Level7 LambdaOrExpr ']')> */ + /* 80 Sum <- <('s' 'u' 'm' '[' Level7 '|' Level7 LambdaOrExpr ']')> */ func() bool { - position297, tokenIndex297, depth297 := position, tokenIndex, depth + position307, tokenIndex307, depth307 := position, tokenIndex, depth { - position298 := position + position308 := position depth++ if buffer[position] != rune('s') { - goto l297 + goto l307 } position++ if buffer[position] != rune('u') { - goto l297 + goto l307 } position++ if buffer[position] != rune('m') { - goto l297 + goto l307 } position++ if buffer[position] != rune('[') { - goto l297 + goto l307 } position++ if !_rules[ruleLevel7]() { - goto l297 + goto l307 } if buffer[position] != rune('|') { - goto l297 + goto l307 } position++ if !_rules[ruleLevel7]() { - goto l297 + goto l307 } if !_rules[ruleLambdaOrExpr]() { - goto l297 + goto l307 } if buffer[position] != rune(']') { - goto l297 + goto l307 } position++ depth-- - add(ruleSum, position298) + add(ruleSum, position308) } return true - l297: - position, tokenIndex, depth = position297, tokenIndex297, depth297 + l307: + position, tokenIndex, depth = position307, tokenIndex307, depth307 return false }, - /* 79 Lambda <- <('l' 'a' 'm' 'b' 'd' 'a' (LambdaRef / LambdaExpr))> */ + /* 81 Lambda <- <('l' 'a' 'm' 'b' 'd' 'a' (LambdaRef / LambdaExpr))> */ func() bool { - position299, tokenIndex299, depth299 := position, tokenIndex, depth + position309, tokenIndex309, depth309 := position, tokenIndex, depth { - position300 := position + position310 := position depth++ if buffer[position] != rune('l') { - goto l299 + goto l309 } position++ if buffer[position] != rune('a') { - goto l299 + goto l309 } position++ if buffer[position] != rune('m') { - goto l299 + goto l309 } position++ if buffer[position] != rune('b') { - goto l299 + goto l309 } position++ if buffer[position] != rune('d') { - goto l299 + goto l309 } position++ if buffer[position] != rune('a') { - goto l299 + goto l309 } position++ { - position301, tokenIndex301, depth301 := position, tokenIndex, depth + position311, tokenIndex311, depth311 := position, tokenIndex, depth if !_rules[ruleLambdaRef]() { - goto l302 + goto l312 } - goto l301 - l302: - position, tokenIndex, depth = position301, tokenIndex301, depth301 + goto l311 + l312: + position, tokenIndex, depth = position311, tokenIndex311, depth311 if !_rules[ruleLambdaExpr]() { - goto l299 + goto l309 } } - l301: + l311: depth-- - add(ruleLambda, position300) + add(ruleLambda, position310) } return true - l299: - position, tokenIndex, depth = position299, tokenIndex299, depth299 + l309: + position, tokenIndex, depth = position309, tokenIndex309, depth309 return false }, - /* 80 LambdaRef <- <(req_ws Expression)> */ + /* 82 LambdaRef <- <(req_ws Expression)> */ func() bool { - position303, tokenIndex303, depth303 := position, tokenIndex, depth + position313, tokenIndex313, depth313 := position, tokenIndex, depth { - position304 := position + position314 := position depth++ if !_rules[rulereq_ws]() { - goto l303 + goto l313 } if !_rules[ruleExpression]() { - goto l303 + goto l313 } depth-- - add(ruleLambdaRef, position304) + add(ruleLambdaRef, position314) } return true - l303: - position, tokenIndex, depth = position303, tokenIndex303, depth303 + l313: + position, tokenIndex, depth = position313, tokenIndex313, depth313 return false }, - /* 81 LambdaExpr <- <(ws Params ws ('-' '>') Expression)> */ + /* 83 LambdaExpr <- <(ws Params ws ('-' '>') Expression)> */ func() bool { - position305, tokenIndex305, depth305 := position, tokenIndex, depth + position315, tokenIndex315, depth315 := position, tokenIndex, depth { - position306 := position + position316 := position depth++ if !_rules[rulews]() { - goto l305 + goto l315 } if !_rules[ruleParams]() { - goto l305 + goto l315 } if !_rules[rulews]() { - goto l305 + goto l315 } if buffer[position] != rune('-') { - goto l305 + goto l315 } position++ if buffer[position] != rune('>') { - goto l305 + goto l315 } position++ if !_rules[ruleExpression]() { - goto l305 + goto l315 } depth-- - add(ruleLambdaExpr, position306) + add(ruleLambdaExpr, position316) } return true - l305: - position, tokenIndex, depth = position305, tokenIndex305, depth305 + l315: + position, tokenIndex, depth = position315, tokenIndex315, depth315 return false }, - /* 82 Params <- <('|' StartParams ws Names? '|')> */ + /* 84 Params <- <('|' StartParams ws Names? '|')> */ func() bool { - position307, tokenIndex307, depth307 := position, tokenIndex, depth + position317, tokenIndex317, depth317 := position, tokenIndex, depth { - position308 := position + position318 := position depth++ if buffer[position] != rune('|') { - goto l307 + goto l317 } position++ if !_rules[ruleStartParams]() { - goto l307 + goto l317 } if !_rules[rulews]() { - goto l307 + goto l317 } { - position309, tokenIndex309, depth309 := position, tokenIndex, depth + position319, tokenIndex319, depth319 := position, tokenIndex, depth if !_rules[ruleNames]() { - goto l309 + goto l319 } - goto l310 - l309: - position, tokenIndex, depth = position309, tokenIndex309, depth309 + goto l320 + l319: + position, tokenIndex, depth = position319, tokenIndex319, depth319 } - l310: + l320: if buffer[position] != rune('|') { - goto l307 + goto l317 } position++ depth-- - add(ruleParams, position308) + add(ruleParams, position318) } return true - l307: - position, tokenIndex, depth = position307, tokenIndex307, depth307 + l317: + position, tokenIndex, depth = position317, tokenIndex317, depth317 return false }, - /* 83 StartParams <- */ + /* 85 StartParams <- */ func() bool { - position311, tokenIndex311, depth311 := position, tokenIndex, depth + position321, tokenIndex321, depth321 := position, tokenIndex, depth { - position312 := position + position322 := position depth++ if !_rules[ruleAction2]() { - goto l311 + goto l321 } depth-- - add(ruleStartParams, position312) + add(ruleStartParams, position322) } return true - l311: - position, tokenIndex, depth = position311, tokenIndex311, depth311 + l321: + position, tokenIndex, depth = position321, tokenIndex321, depth321 return false }, - /* 84 Names <- <(NextName (',' NextName)* DefaultValue? (',' NextName DefaultValue)* VarParams?)> */ + /* 86 Names <- <(NextName (',' NextName)* DefaultValue? (',' NextName DefaultValue)* VarParams?)> */ func() bool { - position313, tokenIndex313, depth313 := position, tokenIndex, depth + position323, tokenIndex323, depth323 := position, tokenIndex, depth { - position314 := position + position324 := position depth++ if !_rules[ruleNextName]() { - goto l313 + goto l323 } - l315: + l325: { - position316, tokenIndex316, depth316 := position, tokenIndex, depth + position326, tokenIndex326, depth326 := position, tokenIndex, depth if buffer[position] != rune(',') { - goto l316 + goto l326 } position++ if !_rules[ruleNextName]() { - goto l316 + goto l326 } - goto l315 - l316: - position, tokenIndex, depth = position316, tokenIndex316, depth316 + goto l325 + l326: + position, tokenIndex, depth = position326, tokenIndex326, depth326 } { - position317, tokenIndex317, depth317 := position, tokenIndex, depth + position327, tokenIndex327, depth327 := position, tokenIndex, depth if !_rules[ruleDefaultValue]() { - goto l317 + goto l327 } - goto l318 - l317: - position, tokenIndex, depth = position317, tokenIndex317, depth317 + goto l328 + l327: + position, tokenIndex, depth = position327, tokenIndex327, depth327 } - l318: - l319: + l328: + l329: { - position320, tokenIndex320, depth320 := position, tokenIndex, depth + position330, tokenIndex330, depth330 := position, tokenIndex, depth if buffer[position] != rune(',') { - goto l320 + goto l330 } position++ if !_rules[ruleNextName]() { - goto l320 + goto l330 } if !_rules[ruleDefaultValue]() { - goto l320 + goto l330 } - goto l319 - l320: - position, tokenIndex, depth = position320, tokenIndex320, depth320 + goto l329 + l330: + position, tokenIndex, depth = position330, tokenIndex330, depth330 } { - position321, tokenIndex321, depth321 := position, tokenIndex, depth + position331, tokenIndex331, depth331 := position, tokenIndex, depth if !_rules[ruleVarParams]() { - goto l321 + goto l331 } - goto l322 - l321: - position, tokenIndex, depth = position321, tokenIndex321, depth321 + goto l332 + l331: + position, tokenIndex, depth = position331, tokenIndex331, depth331 } - l322: + l332: depth-- - add(ruleNames, position314) + add(ruleNames, position324) } return true - l313: - position, tokenIndex, depth = position313, tokenIndex313, depth313 + l323: + position, tokenIndex, depth = position323, tokenIndex323, depth323 return false }, - /* 85 NextName <- <(ws Name ws)> */ + /* 87 NextName <- <(ws Name ws)> */ func() bool { - position323, tokenIndex323, depth323 := position, tokenIndex, depth + position333, tokenIndex333, depth333 := position, tokenIndex, depth { - position324 := position + position334 := position depth++ if !_rules[rulews]() { - goto l323 + goto l333 } if !_rules[ruleName]() { - goto l323 + goto l333 } if !_rules[rulews]() { - goto l323 + goto l333 } depth-- - add(ruleNextName, position324) + add(ruleNextName, position334) } return true - l323: - position, tokenIndex, depth = position323, tokenIndex323, depth323 + l333: + position, tokenIndex, depth = position333, tokenIndex333, depth333 return false }, - /* 86 Name <- <([a-z] / [A-Z] / [0-9] / '_')+> */ + /* 88 Name <- <([a-z] / [A-Z] / [0-9] / '_')+> */ func() bool { - position325, tokenIndex325, depth325 := position, tokenIndex, depth + position335, tokenIndex335, depth335 := position, tokenIndex, depth { - position326 := position + position336 := position depth++ { - position329, tokenIndex329, depth329 := position, tokenIndex, depth + position339, tokenIndex339, depth339 := position, tokenIndex, depth if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l330 + goto l340 } position++ - goto l329 - l330: - position, tokenIndex, depth = position329, tokenIndex329, depth329 + goto l339 + l340: + position, tokenIndex, depth = position339, tokenIndex339, depth339 if c := buffer[position]; c < rune('A') || c > rune('Z') { - goto l331 + goto l341 } position++ - goto l329 - l331: - position, tokenIndex, depth = position329, tokenIndex329, depth329 + goto l339 + l341: + position, tokenIndex, depth = position339, tokenIndex339, depth339 if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l332 + goto l342 } position++ - goto l329 - l332: - position, tokenIndex, depth = position329, tokenIndex329, depth329 + goto l339 + l342: + position, tokenIndex, depth = position339, tokenIndex339, depth339 if buffer[position] != rune('_') { - goto l325 + goto l335 } position++ } - l329: - l327: + l339: + l337: { - position328, tokenIndex328, depth328 := position, tokenIndex, depth + position338, tokenIndex338, depth338 := position, tokenIndex, depth { - position333, tokenIndex333, depth333 := position, tokenIndex, depth + position343, tokenIndex343, depth343 := position, tokenIndex, depth if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l334 + goto l344 } position++ - goto l333 - l334: - position, tokenIndex, depth = position333, tokenIndex333, depth333 + goto l343 + l344: + position, tokenIndex, depth = position343, tokenIndex343, depth343 if c := buffer[position]; c < rune('A') || c > rune('Z') { - goto l335 + goto l345 } position++ - goto l333 - l335: - position, tokenIndex, depth = position333, tokenIndex333, depth333 + goto l343 + l345: + position, tokenIndex, depth = position343, tokenIndex343, depth343 if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l336 + goto l346 } position++ - goto l333 - l336: - position, tokenIndex, depth = position333, tokenIndex333, depth333 + goto l343 + l346: + position, tokenIndex, depth = position343, tokenIndex343, depth343 if buffer[position] != rune('_') { - goto l328 + goto l338 } position++ } - l333: - goto l327 - l328: - position, tokenIndex, depth = position328, tokenIndex328, depth328 + l343: + goto l337 + l338: + position, tokenIndex, depth = position338, tokenIndex338, depth338 } depth-- - add(ruleName, position326) + add(ruleName, position336) } return true - l325: - position, tokenIndex, depth = position325, tokenIndex325, depth325 + l335: + position, tokenIndex, depth = position335, tokenIndex335, depth335 return false }, - /* 87 DefaultValue <- <('=' Expression)> */ + /* 89 DefaultValue <- <('=' Expression)> */ func() bool { - position337, tokenIndex337, depth337 := position, tokenIndex, depth + position347, tokenIndex347, depth347 := position, tokenIndex, depth { - position338 := position + position348 := position depth++ if buffer[position] != rune('=') { - goto l337 + goto l347 } position++ if !_rules[ruleExpression]() { - goto l337 + goto l347 } depth-- - add(ruleDefaultValue, position338) + add(ruleDefaultValue, position348) } return true - l337: - position, tokenIndex, depth = position337, tokenIndex337, depth337 + l347: + position, tokenIndex, depth = position347, tokenIndex347, depth347 return false }, - /* 88 VarParams <- <('.' '.' '.' ws)> */ + /* 90 VarParams <- <('.' '.' '.' ws)> */ func() bool { - position339, tokenIndex339, depth339 := position, tokenIndex, depth + position349, tokenIndex349, depth349 := position, tokenIndex, depth { - position340 := position + position350 := position depth++ if buffer[position] != rune('.') { - goto l339 + goto l349 } position++ if buffer[position] != rune('.') { - goto l339 + goto l349 } position++ if buffer[position] != rune('.') { - goto l339 + goto l349 } position++ if !_rules[rulews]() { - goto l339 + goto l349 } depth-- - add(ruleVarParams, position340) + add(ruleVarParams, position350) } return true - l339: - position, tokenIndex, depth = position339, tokenIndex339, depth339 + l349: + position, tokenIndex, depth = position349, tokenIndex349, depth349 return false }, - /* 89 Reference <- <('.'? Key FollowUpRef)> */ + /* 91 Reference <- <('.'? Key FollowUpRef)> */ func() bool { - position341, tokenIndex341, depth341 := position, tokenIndex, depth + position351, tokenIndex351, depth351 := position, tokenIndex, depth { - position342 := position + position352 := position depth++ { - position343, tokenIndex343, depth343 := position, tokenIndex, depth + position353, tokenIndex353, depth353 := position, tokenIndex, depth if buffer[position] != rune('.') { - goto l343 + goto l353 } position++ - goto l344 - l343: - position, tokenIndex, depth = position343, tokenIndex343, depth343 + goto l354 + l353: + position, tokenIndex, depth = position353, tokenIndex353, depth353 } - l344: + l354: if !_rules[ruleKey]() { - goto l341 + goto l351 } if !_rules[ruleFollowUpRef]() { - goto l341 + goto l351 } depth-- - add(ruleReference, position342) + add(ruleReference, position352) } return true - l341: - position, tokenIndex, depth = position341, tokenIndex341, depth341 + l351: + position, tokenIndex, depth = position351, tokenIndex351, depth351 return false }, - /* 90 FollowUpRef <- */ + /* 92 FollowUpRef <- */ func() bool { { - position346 := position + position356 := position depth++ - l347: + l357: { - position348, tokenIndex348, depth348 := position, tokenIndex, depth + position358, tokenIndex358, depth358 := position, tokenIndex, depth if !_rules[rulePathComponent]() { - goto l348 + goto l358 } - goto l347 - l348: - position, tokenIndex, depth = position348, tokenIndex348, depth348 + goto l357 + l358: + position, tokenIndex, depth = position358, tokenIndex358, depth358 } depth-- - add(ruleFollowUpRef, position346) + add(ruleFollowUpRef, position356) } return true }, - /* 91 PathComponent <- <(('.' Key) / ('.'? Index))> */ + /* 93 PathComponent <- <(('.' Key) / ('.'? Index))> */ func() bool { - position349, tokenIndex349, depth349 := position, tokenIndex, depth + position359, tokenIndex359, depth359 := position, tokenIndex, depth { - position350 := position + position360 := position depth++ { - position351, tokenIndex351, depth351 := position, tokenIndex, depth + position361, tokenIndex361, depth361 := position, tokenIndex, depth if buffer[position] != rune('.') { - goto l352 + goto l362 } position++ if !_rules[ruleKey]() { - goto l352 + goto l362 } - goto l351 - l352: - position, tokenIndex, depth = position351, tokenIndex351, depth351 + goto l361 + l362: + position, tokenIndex, depth = position361, tokenIndex361, depth361 { - position353, tokenIndex353, depth353 := position, tokenIndex, depth + position363, tokenIndex363, depth363 := position, tokenIndex, depth if buffer[position] != rune('.') { - goto l353 + goto l363 } position++ - goto l354 - l353: - position, tokenIndex, depth = position353, tokenIndex353, depth353 + goto l364 + l363: + position, tokenIndex, depth = position363, tokenIndex363, depth363 } - l354: + l364: if !_rules[ruleIndex]() { - goto l349 + goto l359 } } - l351: + l361: depth-- - add(rulePathComponent, position350) + add(rulePathComponent, position360) } return true - l349: - position, tokenIndex, depth = position349, tokenIndex349, depth349 + l359: + position, tokenIndex, depth = position359, tokenIndex359, depth359 return false }, - /* 92 Key <- <(([a-z] / [A-Z] / [0-9] / '_') ([a-z] / [A-Z] / [0-9] / '_' / '-')* (':' ([a-z] / [A-Z] / [0-9] / '_') ([a-z] / [A-Z] / [0-9] / '_' / '-')*)?)> */ + /* 94 Key <- <(([a-z] / [A-Z] / [0-9] / '_') ([a-z] / [A-Z] / [0-9] / '_' / '-')* (':' ([a-z] / [A-Z] / [0-9] / '_') ([a-z] / [A-Z] / [0-9] / '_' / '-')*)?)> */ func() bool { - position355, tokenIndex355, depth355 := position, tokenIndex, depth + position365, tokenIndex365, depth365 := position, tokenIndex, depth { - position356 := position + position366 := position depth++ { - position357, tokenIndex357, depth357 := position, tokenIndex, depth + position367, tokenIndex367, depth367 := position, tokenIndex, depth if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l358 + goto l368 } position++ - goto l357 - l358: - position, tokenIndex, depth = position357, tokenIndex357, depth357 + goto l367 + l368: + position, tokenIndex, depth = position367, tokenIndex367, depth367 if c := buffer[position]; c < rune('A') || c > rune('Z') { - goto l359 + goto l369 } position++ - goto l357 - l359: - position, tokenIndex, depth = position357, tokenIndex357, depth357 + goto l367 + l369: + position, tokenIndex, depth = position367, tokenIndex367, depth367 if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l360 + goto l370 } position++ - goto l357 - l360: - position, tokenIndex, depth = position357, tokenIndex357, depth357 + goto l367 + l370: + position, tokenIndex, depth = position367, tokenIndex367, depth367 if buffer[position] != rune('_') { - goto l355 + goto l365 } position++ } - l357: - l361: + l367: + l371: { - position362, tokenIndex362, depth362 := position, tokenIndex, depth + position372, tokenIndex372, depth372 := position, tokenIndex, depth { - position363, tokenIndex363, depth363 := position, tokenIndex, depth + position373, tokenIndex373, depth373 := position, tokenIndex, depth if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l364 + goto l374 } position++ - goto l363 - l364: - position, tokenIndex, depth = position363, tokenIndex363, depth363 + goto l373 + l374: + position, tokenIndex, depth = position373, tokenIndex373, depth373 if c := buffer[position]; c < rune('A') || c > rune('Z') { - goto l365 + goto l375 } position++ - goto l363 - l365: - position, tokenIndex, depth = position363, tokenIndex363, depth363 + goto l373 + l375: + position, tokenIndex, depth = position373, tokenIndex373, depth373 if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l366 + goto l376 } position++ - goto l363 - l366: - position, tokenIndex, depth = position363, tokenIndex363, depth363 + goto l373 + l376: + position, tokenIndex, depth = position373, tokenIndex373, depth373 if buffer[position] != rune('_') { - goto l367 + goto l377 } position++ - goto l363 - l367: - position, tokenIndex, depth = position363, tokenIndex363, depth363 + goto l373 + l377: + position, tokenIndex, depth = position373, tokenIndex373, depth373 if buffer[position] != rune('-') { - goto l362 + goto l372 } position++ } - l363: - goto l361 - l362: - position, tokenIndex, depth = position362, tokenIndex362, depth362 + l373: + goto l371 + l372: + position, tokenIndex, depth = position372, tokenIndex372, depth372 } { - position368, tokenIndex368, depth368 := position, tokenIndex, depth + position378, tokenIndex378, depth378 := position, tokenIndex, depth if buffer[position] != rune(':') { - goto l368 + goto l378 } position++ { - position370, tokenIndex370, depth370 := position, tokenIndex, depth + position380, tokenIndex380, depth380 := position, tokenIndex, depth if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l371 + goto l381 } position++ - goto l370 - l371: - position, tokenIndex, depth = position370, tokenIndex370, depth370 + goto l380 + l381: + position, tokenIndex, depth = position380, tokenIndex380, depth380 if c := buffer[position]; c < rune('A') || c > rune('Z') { - goto l372 + goto l382 } position++ - goto l370 - l372: - position, tokenIndex, depth = position370, tokenIndex370, depth370 + goto l380 + l382: + position, tokenIndex, depth = position380, tokenIndex380, depth380 if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l373 + goto l383 } position++ - goto l370 - l373: - position, tokenIndex, depth = position370, tokenIndex370, depth370 + goto l380 + l383: + position, tokenIndex, depth = position380, tokenIndex380, depth380 if buffer[position] != rune('_') { - goto l368 + goto l378 } position++ } - l370: - l374: + l380: + l384: { - position375, tokenIndex375, depth375 := position, tokenIndex, depth + position385, tokenIndex385, depth385 := position, tokenIndex, depth { - position376, tokenIndex376, depth376 := position, tokenIndex, depth + position386, tokenIndex386, depth386 := position, tokenIndex, depth if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l377 + goto l387 } position++ - goto l376 - l377: - position, tokenIndex, depth = position376, tokenIndex376, depth376 + goto l386 + l387: + position, tokenIndex, depth = position386, tokenIndex386, depth386 if c := buffer[position]; c < rune('A') || c > rune('Z') { - goto l378 + goto l388 } position++ - goto l376 - l378: - position, tokenIndex, depth = position376, tokenIndex376, depth376 + goto l386 + l388: + position, tokenIndex, depth = position386, tokenIndex386, depth386 if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l379 + goto l389 } position++ - goto l376 - l379: - position, tokenIndex, depth = position376, tokenIndex376, depth376 + goto l386 + l389: + position, tokenIndex, depth = position386, tokenIndex386, depth386 if buffer[position] != rune('_') { - goto l380 + goto l390 } position++ - goto l376 - l380: - position, tokenIndex, depth = position376, tokenIndex376, depth376 + goto l386 + l390: + position, tokenIndex, depth = position386, tokenIndex386, depth386 if buffer[position] != rune('-') { - goto l375 + goto l385 } position++ } - l376: - goto l374 - l375: - position, tokenIndex, depth = position375, tokenIndex375, depth375 + l386: + goto l384 + l385: + position, tokenIndex, depth = position385, tokenIndex385, depth385 } - goto l369 - l368: - position, tokenIndex, depth = position368, tokenIndex368, depth368 + goto l379 + l378: + position, tokenIndex, depth = position378, tokenIndex378, depth378 } - l369: + l379: depth-- - add(ruleKey, position356) + add(ruleKey, position366) } return true - l355: - position, tokenIndex, depth = position355, tokenIndex355, depth355 + l365: + position, tokenIndex, depth = position365, tokenIndex365, depth365 return false }, - /* 93 Index <- <('[' '-'? [0-9]+ ']')> */ + /* 95 Index <- <('[' '-'? [0-9]+ ']')> */ func() bool { - position381, tokenIndex381, depth381 := position, tokenIndex, depth + position391, tokenIndex391, depth391 := position, tokenIndex, depth { - position382 := position + position392 := position depth++ if buffer[position] != rune('[') { - goto l381 + goto l391 } position++ { - position383, tokenIndex383, depth383 := position, tokenIndex, depth + position393, tokenIndex393, depth393 := position, tokenIndex, depth if buffer[position] != rune('-') { - goto l383 + goto l393 } position++ - goto l384 - l383: - position, tokenIndex, depth = position383, tokenIndex383, depth383 + goto l394 + l393: + position, tokenIndex, depth = position393, tokenIndex393, depth393 } - l384: + l394: if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l381 + goto l391 } position++ - l385: + l395: { - position386, tokenIndex386, depth386 := position, tokenIndex, depth + position396, tokenIndex396, depth396 := position, tokenIndex, depth if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l386 + goto l396 } position++ - goto l385 - l386: - position, tokenIndex, depth = position386, tokenIndex386, depth386 + goto l395 + l396: + position, tokenIndex, depth = position396, tokenIndex396, depth396 } if buffer[position] != rune(']') { - goto l381 + goto l391 } position++ depth-- - add(ruleIndex, position382) + add(ruleIndex, position392) } return true - l381: - position, tokenIndex, depth = position381, tokenIndex381, depth381 + l391: + position, tokenIndex, depth = position391, tokenIndex391, depth391 return false }, - /* 94 IP <- <([0-9]+ '.' [0-9]+ '.' [0-9]+ '.' [0-9]+)> */ + /* 96 IP <- <([0-9]+ '.' [0-9]+ '.' [0-9]+ '.' [0-9]+)> */ func() bool { - position387, tokenIndex387, depth387 := position, tokenIndex, depth + position397, tokenIndex397, depth397 := position, tokenIndex, depth { - position388 := position + position398 := position depth++ if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l387 + goto l397 } position++ - l389: + l399: { - position390, tokenIndex390, depth390 := position, tokenIndex, depth + position400, tokenIndex400, depth400 := position, tokenIndex, depth if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l390 + goto l400 } position++ - goto l389 - l390: - position, tokenIndex, depth = position390, tokenIndex390, depth390 + goto l399 + l400: + position, tokenIndex, depth = position400, tokenIndex400, depth400 } if buffer[position] != rune('.') { - goto l387 + goto l397 } position++ if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l387 + goto l397 } position++ - l391: + l401: { - position392, tokenIndex392, depth392 := position, tokenIndex, depth + position402, tokenIndex402, depth402 := position, tokenIndex, depth if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l392 + goto l402 } position++ - goto l391 - l392: - position, tokenIndex, depth = position392, tokenIndex392, depth392 + goto l401 + l402: + position, tokenIndex, depth = position402, tokenIndex402, depth402 } if buffer[position] != rune('.') { - goto l387 + goto l397 } position++ if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l387 + goto l397 } position++ - l393: + l403: { - position394, tokenIndex394, depth394 := position, tokenIndex, depth + position404, tokenIndex404, depth404 := position, tokenIndex, depth if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l394 + goto l404 } position++ - goto l393 - l394: - position, tokenIndex, depth = position394, tokenIndex394, depth394 + goto l403 + l404: + position, tokenIndex, depth = position404, tokenIndex404, depth404 } if buffer[position] != rune('.') { - goto l387 + goto l397 } position++ if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l387 + goto l397 } position++ - l395: + l405: { - position396, tokenIndex396, depth396 := position, tokenIndex, depth + position406, tokenIndex406, depth406 := position, tokenIndex, depth if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l396 + goto l406 } position++ - goto l395 - l396: - position, tokenIndex, depth = position396, tokenIndex396, depth396 + goto l405 + l406: + position, tokenIndex, depth = position406, tokenIndex406, depth406 } depth-- - add(ruleIP, position388) + add(ruleIP, position398) } return true - l387: - position, tokenIndex, depth = position387, tokenIndex387, depth387 + l397: + position, tokenIndex, depth = position397, tokenIndex397, depth397 return false }, - /* 95 ws <- <(' ' / '\t' / '\n' / '\r')*> */ + /* 97 ws <- <(' ' / '\t' / '\n' / '\r')*> */ func() bool { { - position398 := position + position408 := position depth++ - l399: + l409: { - position400, tokenIndex400, depth400 := position, tokenIndex, depth + position410, tokenIndex410, depth410 := position, tokenIndex, depth { - position401, tokenIndex401, depth401 := position, tokenIndex, depth + position411, tokenIndex411, depth411 := position, tokenIndex, depth if buffer[position] != rune(' ') { - goto l402 + goto l412 } position++ - goto l401 - l402: - position, tokenIndex, depth = position401, tokenIndex401, depth401 + goto l411 + l412: + position, tokenIndex, depth = position411, tokenIndex411, depth411 if buffer[position] != rune('\t') { - goto l403 + goto l413 } position++ - goto l401 - l403: - position, tokenIndex, depth = position401, tokenIndex401, depth401 + goto l411 + l413: + position, tokenIndex, depth = position411, tokenIndex411, depth411 if buffer[position] != rune('\n') { - goto l404 + goto l414 } position++ - goto l401 - l404: - position, tokenIndex, depth = position401, tokenIndex401, depth401 + goto l411 + l414: + position, tokenIndex, depth = position411, tokenIndex411, depth411 if buffer[position] != rune('\r') { - goto l400 + goto l410 } position++ } - l401: - goto l399 - l400: - position, tokenIndex, depth = position400, tokenIndex400, depth400 + l411: + goto l409 + l410: + position, tokenIndex, depth = position410, tokenIndex410, depth410 } depth-- - add(rulews, position398) + add(rulews, position408) } return true }, - /* 96 req_ws <- <(' ' / '\t' / '\n' / '\r')+> */ + /* 98 req_ws <- <(' ' / '\t' / '\n' / '\r')+> */ func() bool { - position405, tokenIndex405, depth405 := position, tokenIndex, depth + position415, tokenIndex415, depth415 := position, tokenIndex, depth { - position406 := position + position416 := position depth++ { - position409, tokenIndex409, depth409 := position, tokenIndex, depth + position419, tokenIndex419, depth419 := position, tokenIndex, depth if buffer[position] != rune(' ') { - goto l410 + goto l420 } position++ - goto l409 - l410: - position, tokenIndex, depth = position409, tokenIndex409, depth409 + goto l419 + l420: + position, tokenIndex, depth = position419, tokenIndex419, depth419 if buffer[position] != rune('\t') { - goto l411 + goto l421 } position++ - goto l409 - l411: - position, tokenIndex, depth = position409, tokenIndex409, depth409 + goto l419 + l421: + position, tokenIndex, depth = position419, tokenIndex419, depth419 if buffer[position] != rune('\n') { - goto l412 + goto l422 } position++ - goto l409 - l412: - position, tokenIndex, depth = position409, tokenIndex409, depth409 + goto l419 + l422: + position, tokenIndex, depth = position419, tokenIndex419, depth419 if buffer[position] != rune('\r') { - goto l405 + goto l415 } position++ } - l409: - l407: + l419: + l417: { - position408, tokenIndex408, depth408 := position, tokenIndex, depth + position418, tokenIndex418, depth418 := position, tokenIndex, depth { - position413, tokenIndex413, depth413 := position, tokenIndex, depth + position423, tokenIndex423, depth423 := position, tokenIndex, depth if buffer[position] != rune(' ') { - goto l414 + goto l424 } position++ - goto l413 - l414: - position, tokenIndex, depth = position413, tokenIndex413, depth413 + goto l423 + l424: + position, tokenIndex, depth = position423, tokenIndex423, depth423 if buffer[position] != rune('\t') { - goto l415 + goto l425 } position++ - goto l413 - l415: - position, tokenIndex, depth = position413, tokenIndex413, depth413 + goto l423 + l425: + position, tokenIndex, depth = position423, tokenIndex423, depth423 if buffer[position] != rune('\n') { - goto l416 + goto l426 } position++ - goto l413 - l416: - position, tokenIndex, depth = position413, tokenIndex413, depth413 + goto l423 + l426: + position, tokenIndex, depth = position423, tokenIndex423, depth423 if buffer[position] != rune('\r') { - goto l408 + goto l418 } position++ } - l413: - goto l407 - l408: - position, tokenIndex, depth = position408, tokenIndex408, depth408 + l423: + goto l417 + l418: + position, tokenIndex, depth = position418, tokenIndex418, depth418 } depth-- - add(rulereq_ws, position406) + add(rulereq_ws, position416) } return true - l405: - position, tokenIndex, depth = position405, tokenIndex405, depth405 + l415: + position, tokenIndex, depth = position415, tokenIndex415, depth415 return false }, - /* 98 Action0 <- <{}> */ + /* 100 Action0 <- <{}> */ func() bool { { add(ruleAction0, position) } return true }, - /* 99 Action1 <- <{}> */ + /* 101 Action1 <- <{}> */ func() bool { { add(ruleAction1, position) } return true }, - /* 100 Action2 <- <{}> */ + /* 102 Action2 <- <{}> */ func() bool { { add(ruleAction2, position) diff --git a/dynaml/expression.go b/dynaml/expression.go index 27ebd1a..2b6dff2 100644 --- a/dynaml/expression.go +++ b/dynaml/expression.go @@ -210,7 +210,7 @@ func ResolveExpressionOrPushEvaluation(e *Expression, resolved *bool, info *Eval } if v, ok := val.(Expression); ok { - *e = KeepVarArg(v, *e) + *e = KeepArgWrapper(v, *e) *resolved = false return nil, infoe, true } else { @@ -238,7 +238,7 @@ func ResolveExpressionListOrPushEvaluation(list *[]Expression, resolved *bool, i values := make([]interface{}, len(*list)) pushed := make([]Expression, len(*list)) infoe := EvaluationInfo{} - varargs := false + expand := false ok := true copy(pushed, *list) @@ -246,15 +246,16 @@ func ResolveExpressionListOrPushEvaluation(list *[]Expression, resolved *bool, i for i, _ := range pushed { values[i], infoe, ok = ResolveExpressionOrPushEvaluation(&pushed[i], resolved, info, binding, locally) info = &infoe - varargs = varargs || IsVarArg(pushed[i]) + expand = expand || IsListExpansion(pushed[i]) if !ok { return nil, infoe, false } } - if varargs { + + if expand { vlist := []interface{}{} for i, v := range values { - if IsVarArg(pushed[i]) { + if IsListExpansion(pushed[i]) { list, ok := v.([]yaml.Node) if !ok { _, infoe, ok := infoe.Error("argument expansion required list argument") diff --git a/dynaml/lambda.go b/dynaml/lambda.go index 781c806..11a8602 100644 --- a/dynaml/lambda.go +++ b/dynaml/lambda.go @@ -5,6 +5,7 @@ import ( "github.com/mandelsoft/spiff/debug" "github.com/mandelsoft/spiff/yaml" "reflect" + "strconv" ) func staticScope(binding Binding) Binding { @@ -151,6 +152,15 @@ type LambdaValue struct { var _ StaticallyScopedValue = LambdaValue{} var _ yaml.ComparableValue = TemplateValue{} +func (e LambdaValue) ParameterIndex(name string) int { + for i, p := range e.Parameters { + if p.Name == name { + return i + } + } + return -1 +} + func (e LambdaValue) StaticResolver() Binding { return e.resolver } @@ -198,6 +208,18 @@ func (e LambdaValue) String() string { return fmt.Sprintf("%s%s", shorten(binding), e.lambda) } +func (e LambdaValue) NumOptional() int { + for i, p := range e.Parameters { + if p.Default != nil { + return len(e.Parameters) - i + } + } + if e.lambda.VarArgs { + return 1 + } + return 0 +} + func shorten(s string) string { if len(s) > 40 { s = s[:17] + " ... " + s[len(s)-17:] @@ -209,11 +231,34 @@ func (e LambdaValue) MarshalYAML() (tag string, value interface{}, err error) { return "", "(( " + e.lambda.String() + " ))", nil } -func (e LambdaValue) Evaluate(inline bool, curry, autocurry bool, args []interface{}, binding Binding, locally bool) (bool, interface{}, EvaluationInfo, bool) { +func (e LambdaValue) Evaluate(inline bool, curry, autocurry bool, nargs map[string]yaml.Node, args []interface{}, binding Binding, locally bool) (bool, interface{}, EvaluationInfo, bool) { info := DefaultInfo() - required := len(e.lambda.Parameters) + nparams := len(e.Parameters) + required := nparams - if e.lambda.VarArgs { + named := map[string]yaml.Node{} + for n, v := range nargs { + i, err := strconv.ParseInt(n, 10, 32) + if err == nil { + i-- + if i < 0 { + info.Issue = yaml.NewIssue("invalid argument index %d", i+1) + return false, nil, info, false + } + if int(i) >= nparams { + info.Issue = yaml.NewIssue("argument index %d too large for %d parameters", i+1, nparams) + return false, nil, info, false + } + n = e.Parameters[i].Name + } + if _, ok := named[n]; ok { + info.Issue = yaml.NewIssue("named argument %s given by name and index", n) + return false, nil, info, false + } + named[n] = v + } + + if e.lambda.VarArgs { // reduce variable args to list if required > 0 { required-- } @@ -223,14 +268,11 @@ func (e LambdaValue) Evaluate(inline bool, curry, autocurry bool, args []interfa varargs = append(varargs, yaml.NewNode(a, binding.SourceName())) } args = append(args[:required], varargs) - } else { - if len(args) == required { - args = append(args, []yaml.Node{}) - } } } - if len(args) > len(e.lambda.Parameters) { - info.Issue = yaml.NewIssue("found %d argument(s), but expects %d", len(args), len(e.lambda.Parameters)) + + if len(args) > nparams { + info.Issue = yaml.NewIssue("found %d argument(s), but expects %d", len(args), nparams) return false, nil, info, false } inp := map[string]yaml.Node{} @@ -238,33 +280,77 @@ func (e LambdaValue) Evaluate(inline bool, curry, autocurry bool, args []interfa //fmt.Printf(" static %s: %s\n", n, ExpressionType(v.Value())) inp[n] = v } + + for n, v := range named { + if i := e.ParameterIndex(n); i >= 0 { + if i < len(args) { + info.Issue = yaml.NewIssue("both, positional (%d) and named argument found for lambda parameter %s", i+1, n) + return false, nil, info, false + } + if e.lambda.VarArgs && i == nparams-1 { + if _, ok := v.Value().([]yaml.Node); !ok { + info.SetError("named varargs argument %d (%s) must be a list", i+1, n) + return false, nil, info, false + } + } + } else { + info.Issue = yaml.NewIssue("no lambda parameter found for named argument %s", n) + return false, nil, info, false + } + inp[n] = v + } + debug.Debug("LAMBDA CALL: inherit local %+v\n", inp) for i, v := range args { - //fmt.Printf(" dyn %s: %s\n", e.lambda.Names[i], ExpressionType(v)) inp[e.lambda.Parameters[i].Name] = NewNode(v, binding) } - if curry || (autocurry && len(args) < len(e.lambda.Parameters) && e.lambda.Parameters[len(e.lambda.Parameters)-1].Default == nil) { + if curry || (autocurry && len(named) == 0 && len(args) < nparams && !e.lambda.VarArgs && e.lambda.Parameters[nparams-1].Default == nil) { debug.Debug("LAMBDA CALL: currying %+v\n", inp) rest := []Parameter{} - if len(args) < len(e.lambda.Parameters) { - rest = e.lambda.Parameters[len(args):] + varargs := false + if len(args) < nparams { + for i, p := range e.lambda.Parameters[len(args):] { + if _, ok := named[p.Name]; !ok { + rest = append(rest, p) + if i == nparams-len(args)-1 { + varargs = e.lambda.VarArgs + } + } + } } return true, LambdaValue{ rest, - LambdaExpr{rest, e.lambda.VarArgs && len(rest) > 0, e.lambda.E}, + LambdaExpr{rest, varargs, e.lambda.E}, inp, e.resolver, }, DefaultInfo(), true } - if len(args) < len(e.lambda.Parameters) { - if e.lambda.Parameters[len(args)].Default != nil { - for i := len(args); i < len(e.lambda.Parameters); i++ { - inp[e.lambda.Parameters[i].Name] = NewNode(e.lambda.Parameters[i].Default.(ValueExpr).Value, binding) + if len(args) < nparams { + for i := len(args); i < nparams; i++ { + p := e.lambda.Parameters[i] + if v, ok := named[p.Name]; ok { + inp[p.Name] = v + } else { + if p.Default != nil { + inp[p.Name] = NewNode(p.Default.(ValueExpr).Value, binding) + } else { + if e.lambda.VarArgs && i == nparams-1 { + inp[p.Name] = NewNode([]yaml.Node{}, binding) + } else { + if len(named) > 0 { + info.SetError("missing named argument for %s", p.Name) + } else { + if o := e.NumOptional(); o > 0 { + info.SetError("expected at least %d arguments (%d optional), but found %d", nparams-o, o, len(args)) + } else { + info.SetError("expected %d arguments, but found %d", nparams, len(args)) + } + } + return false, nil, info, false + } + } } - } else { - info.SetError("expected %d arguments, but found %d", len(e.lambda.Parameters), len(args)) - return false, nil, info, false } } if !inline { diff --git a/dynaml/listexpansion.go b/dynaml/listexpansion.go new file mode 100644 index 0000000..677a51f --- /dev/null +++ b/dynaml/listexpansion.go @@ -0,0 +1,41 @@ +package dynaml + +import "fmt" + +type ListExpansion interface { + Expression + IsListExpansion() bool +} + +type ListExpansionExpr struct { + Expression +} + +func (e ListExpansionExpr) String() string { + return fmt.Sprintf("%s...", e.Expression) +} + +func (e ListExpansionExpr) Evaluate(binding Binding, locally bool) (interface{}, EvaluationInfo, bool) { + return e.Expression.Evaluate(binding, locally) +} + +func (e ListExpansionExpr) IsListExpansion() bool { + return true +} + +func IsListExpansion(e Expression) bool { + va, ok := e.(ListExpansion) + return ok && va.IsListExpansion() +} + +func KeepArgWrapper(e Expression, orig Expression) Expression { + if va, ok := orig.(ListExpansion); ok && va.IsListExpansion() { + if _, ok := e.(ListExpansion); !ok { + return ListExpansionExpr{e} + } + } + if na, ok := orig.(NameArgument); ok { + return NameArgument{na.Name, e} + } + return e +} diff --git a/dynaml/mapping.go b/dynaml/mapping.go index a39f7c0..e71bc83 100644 --- a/dynaml/mapping.go +++ b/dynaml/mapping.go @@ -196,7 +196,7 @@ func mapList(inline bool, source []yaml.Node, e LambdaValue, binding Binding, ag debug.Debug("map: mapping for %d: %+v\n", i, n) inp[0] = i inp[len(inp)-1] = n.Value() - resolved, mapped, info, ok := e.Evaluate(inline, false, false, inp, binding, false) + resolved, mapped, info, ok := e.Evaluate(inline, false, false, nil, inp, binding, false) if !ok { debug.Debug("map: %d %+v: failed\n", i, n) return nil, info, false @@ -225,7 +225,7 @@ func mapMap(inline bool, source map[string]yaml.Node, e LambdaValue, binding Bin debug.Debug("map: mapping for %s: %+v\n", k, n) inp[0] = k inp[len(inp)-1] = n.Value() - resolved, mapped, info, ok := e.Evaluate(inline, false, false, inp, binding, false) + resolved, mapped, info, ok := e.Evaluate(inline, false, false, nil, inp, binding, false) if !ok { debug.Debug("map: %s %+v: failed\n", k, n) return nil, info, false diff --git a/dynaml/parser.go b/dynaml/parser.go index b08541b..6d26b0e 100644 --- a/dynaml/parser.go +++ b/dynaml/parser.go @@ -218,13 +218,21 @@ func buildExpression(grammar *DynamlGrammar, path []string, stubPath []string) ( call := tokens.Pop().(CallExpr) call.Curry = true tokens.Push(call) + case ruleChainedCall: args := tokens.PopExpressionList() f := tokens.Pop() - tokens.Push(CallExpr{ - Function: f, - Arguments: args, - }) + + var named []Expression + var pos []Expression + for _, a := range args { + if _, ok := a.(NameArgument); ok { + named = append(named, a) + } else { + pos = append(pos, a) + } + } + tokens.Push(CallExpr{Function: f, Arguments: append(named, pos...)}) case ruleAction0: case ruleAction1: @@ -462,15 +470,22 @@ func buildExpression(grammar *DynamlGrammar, path []string, stubPath []string) ( seq := tokens.PopExpressionList() tokens.Push(ListExpr{seq}) + case ruleNextNameArgument: + rhs := tokens.Pop() + name := tokens.Pop().(nameHelper).name + list := tokens.Pop().(expressionListHelper) + list.list = append(list.list, NameArgument{name, rhs}) + tokens.Push(list) + case ruleNextExpression: rhs := tokens.Pop() list := tokens.Pop().(expressionListHelper) list.list = append(list.list, rhs) - tokens.Push(list) - case ruleVarArgs: + + case ruleListExpansion: rhs := tokens.Pop() - tokens.Push(VarArgsExpr{rhs}) + tokens.Push(ListExpansionExpr{rhs}) case ruleStartList, ruleStartArguments: tokens.Push(expressionListHelper{}) @@ -479,6 +494,7 @@ func buildExpression(grammar *DynamlGrammar, path []string, stubPath []string) ( case ruleLevel0, ruleLevel1, ruleLevel2, ruleLevel3, ruleLevel4, ruleLevel5, ruleLevel6, ruleLevel7: case ruleExpression: case ruleExpressionList: + case ruleNameArgumentList: case ruleMap: case ruleScope: case ruleAssignments: diff --git a/dynaml/parser_test.go b/dynaml/parser_test.go index 8830133..7252631 100644 --- a/dynaml/parser_test.go +++ b/dynaml/parser_test.go @@ -251,7 +251,7 @@ var _ = Describe("parsing", func() { ListExpr{ []Expression{ IntegerExpr{1}, - VarArgsExpr{ReferenceExpr{[]string{"foo"}}}, + ListExpansionExpr{ReferenceExpr{[]string{"foo"}}}, IntegerExpr{2}, }, }, @@ -309,7 +309,7 @@ var _ = Describe("parsing", func() { ReferenceExpr{[]string{"foo"}}, []Expression{ IntegerExpr{1}, - VarArgsExpr{ReferenceExpr{[]string{"foo"}}}, + ListExpansionExpr{ReferenceExpr{[]string{"foo"}}}, IntegerExpr{2}, }, false, @@ -330,6 +330,63 @@ var _ = Describe("parsing", func() { ) }) + It("parses call for reference and named argument", func() { + parsesAs( + `foo.bar(a=1)`, + CallExpr{ + ReferenceExpr{[]string{"foo", "bar"}}, + []Expression{ + NameArgument{"a", IntegerExpr{1}}, + }, + false, + }, + ) + }) + + It("parses call for reference and named arguments", func() { + parsesAs( + `foo.bar(a=1, b=2)`, + CallExpr{ + ReferenceExpr{[]string{"foo", "bar"}}, + []Expression{ + NameArgument{"a", IntegerExpr{1}}, + NameArgument{"b", IntegerExpr{2}}, + }, + false, + }, + ) + }) + + It("parses call for reference and named and positional argument", func() { + parsesAs( + `foo.bar(a=1, 2)`, + CallExpr{ + ReferenceExpr{[]string{"foo", "bar"}}, + []Expression{ + NameArgument{"a", IntegerExpr{1}}, + IntegerExpr{2}, + }, + false, + }, + ) + }) + + It("parses call for reference and named and positional arguments", func() { + parsesAs( + `foo.bar(a=1, b=2, 3, 4)`, + CallExpr{ + ReferenceExpr{[]string{"foo", "bar"}}, + []Expression{ + NameArgument{"a", IntegerExpr{1}}, + NameArgument{"b", IntegerExpr{2}}, + IntegerExpr{3}, + IntegerExpr{4}, + }, + false, + }, + ) + }) + It("parses call for expression", func() { parsesAs( `(foo)(1)`, diff --git a/dynaml/replace.go b/dynaml/replace.go index 6f98d23..a491c16 100644 --- a/dynaml/replace.go +++ b/dynaml/replace.go @@ -91,7 +91,7 @@ func LambdaExpander(lambda LambdaValue, binding Binding) Expander { matches = append(matches, NewNode(string(src[match[i]:match[i+1]]), binding)) } inp := []interface{}{matches} - resolved, v, info, ok := lambda.Evaluate(false, false, false, inp, binding, false) + resolved, v, info, ok := lambda.Evaluate(false, false, false, nil, inp, binding, false) if !ok { return resolved, nil, fmt.Errorf("replace: %s", info.Issue.Issue) } diff --git a/dynaml/sort.go b/dynaml/sort.go index 2a69b0a..472e62e 100644 --- a/dynaml/sort.go +++ b/dynaml/sort.go @@ -59,7 +59,7 @@ func ValueLess(list []yaml.Node) Less { func LambdaLess(lambda LambdaValue, list []yaml.Node, binding Binding) Less { return func(i, j int) bool { inp := []interface{}{list[i].Value(), list[j].Value()} - resolved, v, info, ok := lambda.Evaluate(false, false, false, inp, binding, false) + resolved, v, info, ok := lambda.Evaluate(false, false, false, nil, inp, binding, false) if !ok || !resolved { RaiseEvaluationError(resolved, info, ok) } diff --git a/dynaml/sum.go b/dynaml/sum.go index b44822b..5f4d857 100644 --- a/dynaml/sum.go +++ b/dynaml/sum.go @@ -88,7 +88,7 @@ func sumList(inline bool, source []yaml.Node, e LambdaValue, initial interface{} inp[0] = result inp[1] = i inp[len(inp)-1] = n.Value() - resolved, mapped, info, ok := e.Evaluate(inline, false, false, inp, binding, false) + resolved, mapped, info, ok := e.Evaluate(inline, false, false, nil, inp, binding, false) if !ok { debug.Debug("map: %d %+v: failed\n", i, n) return nil, info, false @@ -119,7 +119,7 @@ func sumMap(inline bool, source map[string]yaml.Node, e LambdaValue, initial int inp[0] = result inp[1] = k inp[len(inp)-1] = n.Value() - resolved, mapped, info, ok := e.Evaluate(inline, false, false, inp, binding, false) + resolved, mapped, info, ok := e.Evaluate(inline, false, false, nil, inp, binding, false) if !ok { debug.Debug("map: %s %+v: failed\n", k, n) return nil, info, false diff --git a/dynaml/sync.go b/dynaml/sync.go index 8b2cd54..1bda338 100644 --- a/dynaml/sync.go +++ b/dynaml/sync.go @@ -88,7 +88,7 @@ func (e SyncExpr) Evaluate(binding Binding, locally bool) (interface{}, Evaluati default: return info.Error("lambda expression for sync condition must take one or two arguments, found %d", len(lambda.lambda.Parameters)) } - resolved, result, sub, ok := lambda.Evaluate(inline, false, false, args, binding, locally) + resolved, result, sub, ok := lambda.Evaluate(inline, false, false, nil, args, binding, locally) if !resolved { return e, sub, ok } @@ -154,7 +154,7 @@ func (e SyncExpr) Evaluate(binding Binding, locally bool) (interface{}, Evaluati default: return info.Error("lambda expression for sync value must take one or two arguments, found %d", len(lambda.lambda.Parameters)) } - resolved, result, sub, ok := lambda.Evaluate(inline, false, false, args, binding, locally) + resolved, result, sub, ok := lambda.Evaluate(inline, false, false, nil, args, binding, locally) if !resolved { return e, sub, ok } diff --git a/dynaml/validate.go b/dynaml/validate.go index 7256f04..3c854a3 100644 --- a/dynaml/validate.go +++ b/dynaml/validate.go @@ -72,7 +72,7 @@ func _validate(value interface{}, cond interface{}, binding Binding, args ...yam for _, a := range args { vargs = append(vargs, a.Value()) } - valid, r, info, ok := v.Evaluate(false, false, false, vargs, binding, false) + valid, r, info, ok := v.Evaluate(false, false, false, nil, vargs, binding, false) if !valid { if !ok { diff --git a/dynaml/varargs.go b/dynaml/varargs.go deleted file mode 100644 index 917ae92..0000000 --- a/dynaml/varargs.go +++ /dev/null @@ -1,38 +0,0 @@ -package dynaml - -import "fmt" - -type VarArgsExpression interface { - Expression - IsVarArg() bool -} - -type VarArgsExpr struct { - Expression -} - -func (e VarArgsExpr) String() string { - return fmt.Sprintf("%s...", e.Expression) -} - -func (e VarArgsExpr) Evaluate(binding Binding, locally bool) (interface{}, EvaluationInfo, bool) { - return e.Expression.Evaluate(binding, locally) -} - -func (e VarArgsExpr) IsVarArg() bool { - return true -} - -func IsVarArg(e Expression) bool { - va, ok := e.(VarArgsExpression) - return ok && va.IsVarArg() -} - -func KeepVarArg(e Expression, orig Expression) Expression { - if va, ok := orig.(VarArgsExpression); ok && va.IsVarArg() { - if _, ok := e.(VarArgsExpression); !ok { - return VarArgsExpr{e} - } - } - return e -} diff --git a/flow/cascade_test.go b/flow/cascade_test.go index 2fea609..b8f8c69 100644 --- a/flow/cascade_test.go +++ b/flow/cascade_test.go @@ -568,7 +568,24 @@ values: Expect(template).To(CascadeAs(resolved, source)) }) - It("supports currying with varargs", func() { + It("supports currying with unused varargs", func() { + source := parseYAML(` +--- +func: (( |a,b...|->join(a,b) )) +func1: (( .func*(","))) +values: + value: (( .func1("a","b") )) +`) + + resolved := parseYAML(` +--- +values: + value: a,b +`) + Expect(template).To(CascadeAs(resolved, source)) + }) + + It("supports currying with used varargs", func() { source := parseYAML(` --- func: (( |a,b...|->join(a,b) )) diff --git a/flow/flow_namedarg_test.go b/flow/flow_namedarg_test.go new file mode 100644 index 0000000..7a4191f --- /dev/null +++ b/flow/flow_namedarg_test.go @@ -0,0 +1,264 @@ +package flow + +import ( + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("NamedArgs", func() { + + Context("named args in functions", func() { + It("handles positional substitution", func() { + source := parseYAML(` +--- +data: + <<: (( &temporary )) + func: (( |a,b=1,c=2|->{$a=a, $b=b, $c=c } )) + +result: (( .data.func(a=1) )) +`) + resolved := parseYAML(` +--- +result: + a: 1 + b: 1 + c: 2 +`) + Expect(source).To(FlowAs(resolved)) + }) + + It("handles positional and leading optional", func() { + source := parseYAML(` +--- +data: + <<: (( &temporary )) + func: (( |a,b=1,c=2|->{$a=a, $b=b, $c=c } )) + +result: (( .data.func(a=1, b=2) )) +`) + resolved := parseYAML(` +--- +result: + a: 1 + b: 2 + c: 2 +`) + Expect(source).To(FlowAs(resolved)) + }) + + It("handles trailing optional argument", func() { + source := parseYAML(` +--- +data: + <<: (( &temporary )) + func: (( |a,b=1,c=2|->{$a=a, $b=b, $c=c } )) + +result: (( .data.func(c=3, 2) )) +`) + resolved := parseYAML(` +--- +result: + a: 2 + b: 1 + c: 3 +`) + Expect(source).To(FlowAs(resolved)) + }) + + It("handles indexed argiment", func() { + source := parseYAML(` +--- +data: + <<: (( &temporary )) + func: (( |a,b=1,c=2|->{$a=a, $b=b, $c=c } )) + +result: (( .data.func(3=3, 2) )) +`) + resolved := parseYAML(` +--- +result: + a: 2 + b: 1 + c: 3 +`) + Expect(source).To(FlowAs(resolved)) + }) + }) + + Context("named args in currying", func() { + It("handles currying last optional", func() { + source := parseYAML(` +--- +data: + <<: (( &temporary )) + func: (( |a,b=1,c=2|->{$a=a, $b=b, $c=c } )) + curry: (( data.func*(c=5) )) + +result: (( .data.curry(1,2) )) +`) + resolved := parseYAML(` +--- +result: + a: 1 + b: 2 + c: 5 +`) + Expect(source).To(FlowAs(resolved)) + }) + + It("handles currying non-optional by name", func() { + source := parseYAML(` +--- +data: + <<: (( &temporary )) + func: (( |a,b=1,c=2|->{$a=a, $b=b, $c=c } )) + curry: (( data.func*(a=5) )) + +result: (( .data.curry(2,3) )) +`) + resolved := parseYAML(` +--- +result: + a: 5 + b: 2 + c: 3 +`) + Expect(source).To(FlowAs(resolved)) + }) + + It("handles mixed currying", func() { + source := parseYAML(` +--- +data: + <<: (( &temporary )) + func: (( |a,b=1,c=2|->{$a=a, $b=b, $c=c } )) + curry: (( data.func*(b=5, 4) )) + +result: (( .data.curry(3) )) +`) + resolved := parseYAML(` +--- +result: + a: 4 + b: 5 + c: 3 +`) + Expect(source).To(FlowAs(resolved)) + }) + + It("handles named vararg currying", func() { + source := parseYAML(` +--- +data: + <<: (( &temporary )) + func: (( |a,b...|->{$a=a, $b=b } )) + curry: (( data.func*(b=[5], 4) )) + +result: (( .data.curry() )) +`) + resolved := parseYAML(` +--- +result: + a: 4 + b: + - 5 +`) + Expect(source).To(FlowAs(resolved)) + }) + + It("handles named non-vararg currying", func() { + source := parseYAML(` +--- +data: + <<: (( &temporary )) + func: (( |a,b...|->{$a=a, $b=b } )) + curry: (( data.func*(a=4) )) + +result: (( .data.curry(5,6) )) +`) + resolved := parseYAML(` +--- +result: + a: 4 + b: + - 5 + - 6 +`) + Expect(source).To(FlowAs(resolved)) + }) + }) + + Context("named args with errors", func() { + It("handles invalid name", func() { + source := parseYAML(` +--- +data: + <<: (( &temporary )) + func: (( |a,b=1,c=2|->{$a=a, $b=b, $c=c } )) + +result: (( catch(.data.func(d=5)) )) +`) + resolved := parseYAML(` +--- +result: + valid: false + error: no lambda parameter found for named argument d +`) + Expect(source).To(FlowAs(resolved)) + }) + + It("handles invalid index", func() { + source := parseYAML(` +--- +data: + <<: (( &temporary )) + func: (( |a,b=1,c=2|->{$a=a, $b=b, $c=c } )) + +result: (( catch(.data.func(4=5)) )) +`) + resolved := parseYAML(` +--- +result: + valid: false + error: argument index 4 too large for 3 parameters +`) + Expect(source).To(FlowAs(resolved)) + }) + + It("too many arguments", func() { + source := parseYAML(` +--- +data: + <<: (( &temporary )) + func: (( |a,b=1,c=2|->{$a=a, $b=b, $c=c } )) + +result: (( catch(.data.func(1,2,3,4)) )) +`) + resolved := parseYAML(` +--- +result: + valid: false + error: found 4 argument(s), but expects 3 +`) + Expect(source).To(FlowAs(resolved)) + }) + + It("too less arguments", func() { + source := parseYAML(` +--- +data: + <<: (( &temporary )) + func: (( |a,b=1,c=2|->{$a=a, $b=b, $c=c } )) + +result: (( catch(.data.func()) )) +`) + resolved := parseYAML(` +--- +result: + valid: false + error: expected at least 1 arguments (2 optional), but found 0 +`) + Expect(source).To(FlowAs(resolved)) + }) + }) +})