public ExpressionParserDeclarationResult ParseDeclaration(TextRange Signature)
            {
                var m = rSignature.Match(SignatureText.GetTextInLine(Signature));

                if (!m.Success)
                {
                    throw new InvalidSyntaxException("SignatureInvalid: " + Signature, new FileTextRange {
                        Text = SignatureText, Range = Signature
                    });
                }
                var Name          = m.Result("${Name}");
                var ParameterList = m.Result("${ParameterList}");
                var ReturnType    = m.Result("${ReturnType}");
                var rt            = ParseType(ReturnType, new FileTextRange {
                    Text = SignatureText, Range = Signature
                });

                List <VariableDef> Parameters;

                if (rEmptyParameterList.Match(ParameterList).Success)
                {
                    Parameters = new List <VariableDef>();
                }
                else
                {
                    Parameters = ParameterList.Split(',').Select(p => ParseVariable(p, Signature)).ToList();
                }
                var dParameters = Parameters.ToDictionary(p => p.Name, p => p.Type);

                var fd = new FunctionDecl
                {
                    Name        = Name,
                    Parameters  = Parameters,
                    ReturnValue = rt
                };

                var epr = new ExpressionParserDeclarationResult
                {
                    Declaration = fd,
                    Positions   = Positions
                };

                return(epr);
            }
        public static ExpressionParserExprResult ParseBody(IVariableTypeProvider VariableTypeProvider, FunctionDecl Declaration, String Body)
        {
            var LinesBody = new List <TextLine>();

            LinesBody.Add(new TextLine {
                Text = Body, Range = new TextRange {
                    Start = new TextPosition {
                        CharIndex = 0, Row = 1, Column = 1
                    }, End = new TextPosition {
                        CharIndex = Body.Length, Row = 1, Column = Body.Length + 1
                    }
                }
            });
            var tBody = new Text {
                Path = "Body", Lines = LinesBody
            };
            var p = new Parser(null, tBody);

            return(p.ParseBody(VariableTypeProvider, Declaration, LinesBody.Single().Range));
        }
            public ExpressionParserResult ParseFunction(IVariableTypeProvider VariableTypeProvider, FunctionDecl Declaration, TextRange Body)
            {
                var d    = Declaration;
                var epbr = ParseBody(VariableTypeProvider, d, Body);

                var fd = new FunctionDef
                {
                    Name        = d.Name,
                    Parameters  = d.Parameters,
                    ReturnValue = d.ReturnValue,
                    Body        = epbr.Body
                };

                var epr = new ExpressionParserResult
                {
                    Definition = fd,
                    TypeDict   = epbr.TypeDict,
                    Positions  = Positions
                };

                return(epr);
            }
            public ExpressionParserExprResult ParseBody(IVariableTypeProvider VariableTypeProvider, FunctionDecl Declaration, TextRange Body)
            {
                var d           = Declaration;
                var dParameters = d.Parameters.ToDictionary(p => p.Name, p => p.Type);
                var vtp         = new VariableTypeProviderCombiner(new SimpleVariableTypeProvider(dParameters), VariableTypeProvider);
                var br          = BindExpr(vtp, d.ReturnValue, Body);

                var epr = new ExpressionParserExprResult
                {
                    Body      = br.Semantics,
                    TypeDict  = br.TypeDict,
                    Positions = Positions
                };

                return(epr);
            }
        public ExpressionParserResult ParseFunction(IVariableTypeProvider VariableTypeProvider, FunctionDecl Declaration, TextRange Body)
        {
            var p = new Parser(SignatureText, BodyText);

            return(p.ParseFunction(VariableTypeProvider, Declaration, Body));
        }