예제 #1
0
        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);
        }
예제 #2
0
 public object?Transform(ArgumentSetNode item)
 {
     throw new NotImplementedException();
 }
예제 #3
0
 public IEnumerable <bool> Transform(ArgumentSetNode item)
 {
     yield return(false);
 }