cl-ast: Remove Param, replace with flat Pattern

This commit is contained in:
2025-02-23 02:01:38 -06:00
parent e3d94d8949
commit cc6168b55e
10 changed files with 16 additions and 49 deletions

View File

@@ -469,7 +469,7 @@ impl Parse<'_> for Function {
}
}
type FnSig = (Vec<Param>, Vec<TyKind>);
type FnSig = (Vec<Pattern>, Vec<TyKind>);
impl Parse<'_> for FnSig {
/// Parses the [parameters](Param) associated with a Function
@@ -488,16 +488,17 @@ impl Parse<'_> for FnSig {
}
}
type TypedParam = (Param, TyKind);
type TypedParam = (Pattern, TyKind);
impl Parse<'_> for TypedParam {
/// Parses a single function [parameter](Param)
fn parse(p: &mut Parser) -> PResult<(Param, TyKind)> {
fn parse(p: &mut Parser) -> PResult<(Pattern, TyKind)> {
Ok((
Param { mutability: Mutability::parse(p)?, bind: Pattern::parse(p)? },
{
p.match_type(TokenKind::Colon, Parsing::Param)?;
Pattern::parse(p)?,
if p.match_type(TokenKind::Colon, Parsing::Param).is_ok() {
TyKind::parse(p)?
} else {
TyKind::Path(Path::from(Sym::from("_")))
},
))
}