Fix to parsing with arguments

This commit is contained in:
Pieter Vander Vennet 2020-06-05 13:37:12 +02:00
parent fb7bf63ed2
commit 8bf77cbc69
2 changed files with 18 additions and 4 deletions

View file

@ -330,7 +330,9 @@ namespace AspectedRouting.IO.jsonParser
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?");

View file

@ -7,6 +7,7 @@ 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.";
@ -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)
}
)
{