diff --git a/AST.cs b/AST.cs index a333cb3..41bd7fe 100644 --- a/AST.cs +++ b/AST.cs @@ -54,7 +54,7 @@ public partial record SimplePattern public abstract record Binding(Expr Value); public record VarBinding(Pattern Pattern, Expr Value) : Binding(Value); -public record FuncBinding(Name Name, SimplePattern[] Params, Expr Value) : Binding(Value) +public record FuncBinding(Name Name, Pattern[] Params, Expr Value) : Binding(Value) { public override string ToString() { diff --git a/Parser.cs b/Parser.cs index adefd30..b3ae6af 100644 --- a/Parser.cs +++ b/Parser.cs @@ -264,22 +264,10 @@ class Parser switch (p) { case (SimplePattern(var funcName)) when funcName != null && match(TokenType.LParen): - List funcParams = new List(); + List funcParams = new List(); while (!check(TokenType.RParen)) { - Name? paramName; - if (match(TokenType.Blank)) - { - funcParams.Add(new(null)); - } - else if ((paramName = name()) != null) - { - funcParams.Add(new(paramName)); - } - else - { - throw error(peek(), "Expect identifier or '_' as function parameter."); - } + funcParams.Add(pattern()); if (!match(TokenType.Comma)) { break;