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,
|
||||
}
|
||||
|
||||
// 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
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
|
||||
pub struct File {
|
||||
@ -271,11 +285,6 @@ pub enum PathPart {
|
||||
Ident(Identifier),
|
||||
}
|
||||
|
||||
// TODO: Capture token?
|
||||
/// A name
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct Identifier(pub String);
|
||||
|
||||
/// An abstract statement, and associated metadata
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct Stmt {
|
||||
@ -284,13 +293,6 @@ pub struct Stmt {
|
||||
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
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum StmtKind {
|
||||
@ -300,6 +302,13 @@ pub enum StmtKind {
|
||||
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]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct Let {
|
||||
@ -317,8 +326,11 @@ pub struct Expr {
|
||||
}
|
||||
|
||||
/// Any of the different [Expr]essions
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
#[derive(Clone, Default, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum ExprKind {
|
||||
/// An empty expression: `(` `)`
|
||||
#[default]
|
||||
Empty,
|
||||
/// An [Assign]ment expression: [`Expr`] ([`AssignKind`] [`Expr`])\+
|
||||
Assign(Assign),
|
||||
/// A [Binary] expression: [`Expr`] ([`BinaryKind`] [`Expr`])\+
|
||||
@ -340,8 +352,6 @@ pub enum ExprKind {
|
||||
AddrOf(AddrOf),
|
||||
/// A [Block] expression: `{` [`Stmt`]\* [`Expr`]? `}`
|
||||
Block(Block),
|
||||
/// An empty expression: `(` `)`
|
||||
Empty,
|
||||
/// A [Grouping](Group) expression `(` [`Expr`] `)`
|
||||
Group(Group),
|
||||
/// A [Tuple] expression: `(` [`Expr`] (`,` [`Expr`])+ `)`
|
||||
@ -445,15 +455,6 @@ pub struct Index {
|
||||
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`])\* `]`
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct Array {
|
||||
|
Loading…
Reference in New Issue
Block a user