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 object?Transform(ArgumentSetNode item) { throw new NotImplementedException(); }
public IEnumerable <bool> Transform(ArgumentSetNode item) { yield return(false); }