示例#1
0
        private DefClause ParseDefClause()
        {
            string name;

            if (_tokenizer.Token == "operator")
            {
                name = ParseOperatorName();
            }
            else
            {
                name = ParseName();
                Assert(!Char.IsUpper(name[0]), "Binding name should not start with an uppercase letter");
            }

            var arguments = new List <Pattern>();

            while (_tokenizer.Token != null && _tokenizer.Token != "as" && _tokenizer.Token != ":" && _tokenizer.Token != ")")
            {
                arguments.Add(ParsePattern());
            }

            TypeClause type = null;

            if (_tokenizer.Token == ":")
            {
                _tokenizer.Advance();
                type = ParseTypeClause();
            }

            RequireToken("as");

            var body = ParseExpression();

            return(type != null ? new TypeAnnotatedDefFunctionClause(name, arguments, body, type) : new DefFunctionClause(name, arguments, body));
        }
示例#2
0
 public TypeAnnotatedDefFunctionClause(string name, List <Pattern> arguments, Expression body, TypeClause type) : base(name, arguments, body)
 {
     AnnotatedType = type;
 }
示例#3
0
 public TypeAnnotatedPattern(Pattern body, TypeClause type)
 {
     Type = type;
     Body = body;
 }
示例#4
0
 public FunctionTypeClause(TypeClause argument, TypeClause result)
 {
     Argument = argument;
     Result   = result;
 }
示例#5
0
 public TypeAnnotatedExpression(Expression expression, TypeClause type)
 {
     Type       = type;
     Expression = expression;
 }