cl-ast: Re-order items for aesthetic reasons
This commit is contained in:
parent
17a522b633
commit
e4f270da17
@ -33,6 +33,20 @@ pub enum Visibility {
|
|||||||
Public,
|
Public,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Capture token?
|
||||||
|
/// A name
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
|
pub struct Identifier(pub String);
|
||||||
|
|
||||||
|
/// A [Literal]: 0x42, 1e123, 2.4, "Hello"
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
|
pub enum Literal {
|
||||||
|
Bool(bool),
|
||||||
|
Char(char),
|
||||||
|
Int(u128),
|
||||||
|
String(String),
|
||||||
|
}
|
||||||
|
|
||||||
/// A list of [Item]s
|
/// A list of [Item]s
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
|
||||||
pub struct File {
|
pub struct File {
|
||||||
@ -271,11 +285,6 @@ pub enum PathPart {
|
|||||||
Ident(Identifier),
|
Ident(Identifier),
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Capture token?
|
|
||||||
/// A name
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
|
||||||
pub struct Identifier(pub String);
|
|
||||||
|
|
||||||
/// An abstract statement, and associated metadata
|
/// An abstract statement, and associated metadata
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
pub struct Stmt {
|
pub struct Stmt {
|
||||||
@ -284,13 +293,6 @@ pub struct Stmt {
|
|||||||
pub semi: Semi,
|
pub semi: Semi,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether or not a [Stmt] is followed by a semicolon
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
|
||||||
pub enum Semi {
|
|
||||||
Terminated,
|
|
||||||
Unterminated,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Whether the [Stmt] is a [Let], [Item], or [Expr] statement
|
/// Whether the [Stmt] is a [Let], [Item], or [Expr] statement
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
pub enum StmtKind {
|
pub enum StmtKind {
|
||||||
@ -300,6 +302,13 @@ pub enum StmtKind {
|
|||||||
Expr(Box<Expr>),
|
Expr(Box<Expr>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Whether or not a [Stmt] is followed by a semicolon
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
|
pub enum Semi {
|
||||||
|
Terminated,
|
||||||
|
Unterminated,
|
||||||
|
}
|
||||||
|
|
||||||
/// A local variable declaration [Stmt]
|
/// A local variable declaration [Stmt]
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
pub struct Let {
|
pub struct Let {
|
||||||
@ -317,8 +326,11 @@ pub struct Expr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Any of the different [Expr]essions
|
/// Any of the different [Expr]essions
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Default, Debug, PartialEq, Eq, Hash)]
|
||||||
pub enum ExprKind {
|
pub enum ExprKind {
|
||||||
|
/// An empty expression: `(` `)`
|
||||||
|
#[default]
|
||||||
|
Empty,
|
||||||
/// An [Assign]ment expression: [`Expr`] ([`AssignKind`] [`Expr`])\+
|
/// An [Assign]ment expression: [`Expr`] ([`AssignKind`] [`Expr`])\+
|
||||||
Assign(Assign),
|
Assign(Assign),
|
||||||
/// A [Binary] expression: [`Expr`] ([`BinaryKind`] [`Expr`])\+
|
/// A [Binary] expression: [`Expr`] ([`BinaryKind`] [`Expr`])\+
|
||||||
@ -340,8 +352,6 @@ pub enum ExprKind {
|
|||||||
AddrOf(AddrOf),
|
AddrOf(AddrOf),
|
||||||
/// A [Block] expression: `{` [`Stmt`]\* [`Expr`]? `}`
|
/// A [Block] expression: `{` [`Stmt`]\* [`Expr`]? `}`
|
||||||
Block(Block),
|
Block(Block),
|
||||||
/// An empty expression: `(` `)`
|
|
||||||
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`])+ `)`
|
||||||
@ -445,15 +455,6 @@ pub struct Index {
|
|||||||
pub indices: Vec<Expr>,
|
pub indices: Vec<Expr>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A [Literal]: 0x42, 1e123, 2.4, "Hello"
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
|
||||||
pub enum Literal {
|
|
||||||
Bool(bool),
|
|
||||||
Char(char),
|
|
||||||
Int(u128),
|
|
||||||
String(String),
|
|
||||||
}
|
|
||||||
|
|
||||||
/// An [Array] literal: `[` [`Expr`] (`,` [`Expr`])\* `]`
|
/// An [Array] literal: `[` [`Expr`] (`,` [`Expr`])\* `]`
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
pub struct Array {
|
pub struct Array {
|
||||||
|
Loading…
Reference in New Issue
Block a user