conlang: Add Tuple-Struct Patterns

- Patterns are no longer parsed with the highest precedence
- Function calls with just a path and a tuple of args can now be transformed into a Pattern
This commit is contained in:
2025-02-22 01:37:08 -06:00
parent 5d2c714bc1
commit 697d139cfd
9 changed files with 46 additions and 5 deletions

View File

@@ -1080,7 +1080,7 @@ impl Parse<'_> for Return {
impl Parse<'_> for Pattern {
fn parse(p: &mut Parser<'_>) -> PResult<Self> {
let value = prec::exprkind(p, prec::Precedence::Highest.level())?;
let value = prec::exprkind(p, prec::Precedence::Pattern.level())?;
Pattern::try_from(value)
.map_err(|_| p.error(ExpectedParsing { want: Parsing::Pattern }, Parsing::Pattern))
}

View File

@@ -255,8 +255,8 @@ pub enum Precedence {
Index,
Cast,
Member, // left-associative
Pattern,
Call,
Highest,
}
impl Precedence {