conlang: Patterns...2!

- Deny arbitrary paths in patterns (only one non-keyword identifier allowed!)
- Allow patterns in for-loop binders (literally useless atm, but it's a step toward making patterns the only way to bind names.)

Next: Functions, Tuple Struct Patterns... And solving the stupid syntactic ambiguity of structors.
This commit is contained in:
2025-02-22 01:00:29 -06:00
parent b115fea71b
commit 5d2c714bc1
8 changed files with 85 additions and 113 deletions

View File

@@ -1037,7 +1037,7 @@ impl Parse<'_> for For {
#[rustfmt::skip]
fn parse(p: &mut Parser) -> PResult<For> {
p.match_type(TokenKind::For, Parsing::For)?;
let bind = Sym::parse(p)?;
let bind = Pattern::parse(p)?;
p.match_type(TokenKind::In, Parsing::For)?;
Ok(For {
bind,