Fix to parsing with arguments
This commit is contained in:
parent
fb7bf63ed2
commit
8bf77cbc69
2 changed files with 18 additions and 4 deletions
|
@ -323,14 +323,16 @@ namespace AspectedRouting.IO.jsonParser
|
|||
var allExprs = allArgs
|
||||
.Where(kv => !kv.NameEquals("#")) // Leave out comments
|
||||
.ToDictionary(kv => kv.Name, kv => kv.Value.ParseExpression(context));
|
||||
|
||||
|
||||
|
||||
if (allExprs.Count > 1)
|
||||
{
|
||||
if (func.ArgNames == null || func.ArgNames.Count < 2)
|
||||
throw new ArgumentException("{funcName} does not specify argument names");
|
||||
|
||||
foreach (var argName in func.ArgNames)
|
||||
|
||||
foreach (var argName in func.ArgNames.GetRange(1, func.ArgNames.Count - 2))
|
||||
// We skip the first argument, that one is already added
|
||||
{
|
||||
args.Add(allExprs[argName]);
|
||||
}
|
||||
|
@ -413,6 +415,11 @@ namespace AspectedRouting.IO.jsonParser
|
|||
return eithered;
|
||||
}
|
||||
|
||||
if (mapping != null)
|
||||
{
|
||||
return mapping;
|
||||
}
|
||||
|
||||
|
||||
throw new Exception(
|
||||
"No top level reducer found. Did you forget the '$' in the reducing function? Did your forget 'value' to add the mapping?");
|
||||
|
|
|
@ -7,7 +7,8 @@ namespace AspectedRouting.Language.Functions
|
|||
public class If : Function
|
||||
{
|
||||
private static Var a = new Var("a");
|
||||
|
||||
private static Var b = new Var("b");
|
||||
|
||||
public override string Description { get; } = "Selects either one of the branches, depending on the condition." +
|
||||
"If the `else` branch is not set, `null` is returned in the condition is false.";
|
||||
public override List<string> ArgNames { get; } = new List<string> {"condition", "then", "else"};
|
||||
|
@ -16,7 +17,13 @@ namespace AspectedRouting.Language.Functions
|
|||
new[]
|
||||
{
|
||||
Curry.ConstructFrom(a, Typs.Bool, a, a),
|
||||
Curry.ConstructFrom(a, Typs.Bool, a)
|
||||
Curry.ConstructFrom(a, Typs.Bool, a),
|
||||
|
||||
Curry.ConstructFrom(a,
|
||||
new Curry(b, Typs.Bool),
|
||||
new Curry(b, a),
|
||||
new Curry(b, a),
|
||||
b)
|
||||
}
|
||||
)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue