ast: Improve ExprKind descriptions

This commit is contained in:
John 2024-02-26 15:25:49 -06:00
parent 2095bfec80
commit cdf283064e

View File

@ -32,7 +32,7 @@ pub struct File {
} }
// Items // Items
/// Holds an abstract Item and associated metadata /// Stores an [ItemKind] and associated metadata
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct Item { pub struct Item {
pub extents: Span, pub extents: Span,
@ -253,45 +253,46 @@ pub struct Expr {
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum ExprKind { pub enum ExprKind {
/// An [Assign]ment expression: [`Expr`] ([`AssignKind`] [`Expr`])\+
Assign(Box<Assign>), Assign(Box<Assign>),
/// A [Binary] expression, with a leading and trailing side /// A [Binary] expression: [`Expr`] ([`BinaryKind`] [`Expr`])\+
Binary(Binary), Binary(Binary),
/// A [Unary] expression, with a trailing side /// A [Unary] expression: [`UnaryKind`]\* [`Expr`]
Unary(Unary), Unary(Unary),
/// A [Member] access expression /// A [Member] access expression: [`Expr`] (`.` [`Expr`])+
Member(Member), Member(Member),
/// A [Call] expression, with arguments /// A [Call] expression, with arguments: a(foo, bar)
Call(Call), Call(Call),
/// An Array [Index] expression /// An Array [Index] expression: a[10, 20, 30]
Index(Index), Index(Index),
/// A [path expression](Path): `::`? [PathPart] (`::` [PathPart])* /// A [path expression](Path): `::`? [PathPart] (`::` [PathPart])*
Path(Path), Path(Path),
/// A [Literal]: 0x42, 1e123, 2.4, "Hello" /// A [Literal]: 0x42, 1e123, 2.4, "Hello"
Literal(Literal), Literal(Literal),
/// An [Array] literal: `[` Expr (`,` Expr)* `]` /// An [Array] literal: `[` [`Expr`] (`,` [`Expr`])\* `]`
Array(Array), Array(Array),
/// An Array literal constructed with [repeat syntax](ArrayRep) /// An Array literal constructed with [repeat syntax](ArrayRep)
/// `[` [Expr] `;` [Literal] `]` /// `[` [Expr] `;` [Literal] `]`
ArrayRep(ArrayRep), ArrayRep(ArrayRep),
/// An address-of expression: `&`foo /// An address-of expression: `&` `mut`? [`Expr`]
AddrOf(AddrOf), AddrOf(AddrOf),
/// A [Block] expression: `{` Stmt* Expr? `}` /// A [Block] expression: `{` [`Stmt`]\* [`Expr`]? `}`
Block(Block), Block(Block),
/// An empty expression: `(` `)` /// An empty expression: `(` `)`
Empty, Empty,
/// A [Grouping](Group) expression `(` Expr `)` /// A [Grouping](Group) expression `(` [`Expr`] `)`
Group(Group), Group(Group),
/// A [Tuple] expression: `(` Expr (`,` Expr)+ `)` /// A [Tuple] expression: `(` [`Expr`] (`,` [`Expr`])+ `)`
Tuple(Tuple), Tuple(Tuple),
/// A [While] expression: `while` Expr Block Else? /// A [While] expression: `while` [`Expr`] [`Block`] [`Else`]?
While(While), While(While),
/// An [If] expression: `if` Expr Block Else? /// An [If] expression: `if` [`Expr`] [`Block`] [`Else`]?
If(If), If(If),
/// A [For] expression: `for` Pattern in Expr Block Else? /// A [For] expression: `for` Pattern `in` [`Expr`] [`Block`] [`Else`]?
For(For), For(For),
/// A [Break] expression: `break` Expr? /// A [Break] expression: `break` [`Expr`]?
Break(Break), Break(Break),
/// A [Return] expression `return` Expr? /// A [Return] expression `return` [`Expr`]?
Return(Return), Return(Return),
/// A continue expression: `continue` /// A continue expression: `continue`
Continue(Continue), Continue(Continue),