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)); }
public TypeAnnotatedDefFunctionClause(string name, List <Pattern> arguments, Expression body, TypeClause type) : base(name, arguments, body) { AnnotatedType = type; }
public TypeAnnotatedPattern(Pattern body, TypeClause type) { Type = type; Body = body; }
public FunctionTypeClause(TypeClause argument, TypeClause result) { Argument = argument; Result = result; }
public TypeAnnotatedExpression(Expression expression, TypeClause type) { Type = type; Expression = expression; }