private static bool TryParseFunctionDeclaration(IdentifierNode identifier, ArgumentSetNode argumentSet, [NotNullWhen(true)] out FunctionDeclaration?declaration) { declaration = default; var functionName = identifier.TextValue; var arguments = argumentSet.Arguments.Select(ParseParameterDeclaration).ToArray(); // Check for a required parameter that exists after an optional parameter var firstOptionalIndex = int.MaxValue; for (int argIndex = 0; argIndex < arguments.Length; ++argIndex) { var arg = arguments[argIndex] ?? throw new NotImplementedException(); if (arg.Optional) { firstOptionalIndex = Math.Min(firstOptionalIndex, argIndex); } else if (firstOptionalIndex != int.MaxValue) { // This is *NOT* optional, yet exists after an optional parameter. throw new NotImplementedException(); } } ParameterDeclaration[] nonNullArguments = arguments.Where(arg => arg != null).Select(arg => arg).ToArray() !; if (nonNullArguments.Length != arguments.Length) { return(false); } declaration = new FunctionDeclaration(returnType: typeof(object), functionName, nonNullArguments); return(true); }
public ScopedUserDefinedFunction(FunctionDeclaration declaration, ScopedUserDefinedFunctionDelegate body) { Body = body; Declaration = declaration; }
public UserDefinedTest(FunctionDeclaration <bool> declaration, UserDefinedTestDelegate body) { Declaration = declaration; Body = body; }
public UserDefinedFunction(FunctionDeclaration declaration, UserDefinedFunctionDelegate body) { Declaration = declaration; Body = body; }