ast: Break compatibility

- Turned `static` and `const` into scoped modifiers (like `pub`
- Added anonymous record patterns
This commit is contained in:
2025-12-20 05:22:14 -05:00
parent 64ce18d576
commit f551e3aef3
8 changed files with 43 additions and 36 deletions

View File

@@ -81,8 +81,10 @@ pub enum Op {
Call, // Expr ( Expr,* )
Pub, // pub Expr
Const, // const Expr
Static, // static Expr
Loop, // loop Expr
Match, // match Expr { <Let(Match, ..)>,* }
Match, // match Expr { <Bind(Match, ..)>,* }
If, // if Expr Expr (else Expr)?
While, // while Expr Expr (else Expr)?
Break, // break Expr
@@ -176,8 +178,6 @@ pub enum Use {
/// A pattern binding
/// ```ignore
/// let Pat (= Expr (else Expr)?)?
/// const Pat (= Expr (else Expr)?)?
/// static Pat (= Expr (else Expr)?)?
/// type Pat (= Expr)?
/// struct Pat
/// enum Pat
@@ -199,10 +199,6 @@ pub struct Bind<A: Annotation = Span>(
pub enum BindOp {
/// A `let Pat (= Expr (else Expr)?)?` binding
Let,
/// A `const Pat = Expr` binding
Const,
/// A `static Pat = Expr` binding
Static,
/// A type-alias binding
Type,
/// A `fn Pat Expr` binding
@@ -251,7 +247,7 @@ pub enum Pat {
/// Matches against a named const value
Path(Path),
/// Matches a Struct Expression `Ident { Pat }`
NamedStruct(Path, Box<Pat>),
NamedRecord(Path, Box<Pat>),
/// Matches a Tuple Struct Expression `Ident ( Pat )`
NamedTuple(Path, Box<Pat>),
/// Matches a literal value by equality comparison
@@ -277,15 +273,17 @@ pub enum PatOp {
RangeEx,
/// Matches an inclusive bounded range (`0..=100`)
RangeIn,
/// Matches the elements of a tuple
/// Matches the elements of a record or struct { a, b, c }
Record,
/// Matches the elements of a tuple ( a, b, c )
Tuple,
/// Matches the elements of a slice or array
/// Matches the elements of a slice or array [ a, b, c ]
Slice,
/// Matches a constant-size slice with repeating elements
ArRep,
/// Matches a type annotation or struct member
Typed,
/// Matches a function signature
/// Changes the binding mode to "function-body"
Fn,
/// Matches one of a list of alternatives
Alt,