Skip to content

Commit

Permalink
feat(rust-parse): Add remaining expression grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
chorman0773 committed Aug 26, 2023
1 parent 0af970d commit 3ad3ffc
Show file tree
Hide file tree
Showing 3 changed files with 903 additions and 160 deletions.
25 changes: 21 additions & 4 deletions rust/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,26 +427,41 @@ pub enum Expr {
BlockExpr(Spanned<CompoundBlock>),
Literal(Spanned<Literal>),
Break(Option<Spanned<Label>>, Option<Box<Spanned<Expr>>>),
Continue(Option<Spanned<Label>>, Option<Box<Spanned<Expr>>>),
Continue(Option<Spanned<Label>>),
Yield(Option<Box<Spanned<Expr>>>),
ConstBlock(Spanned<Block>),
AsyncBlock(Spanned<Block>),
AsyncBlock(Spanned<AsyncBlock>),
Closure(Spanned<Closure>),
Yeet(Option<Box<Expr>>),
Yeet(Option<Box<Spanned<Expr>>>),
Constructor(Spanned<ConstructorExpr>),
Await(Box<Spanned<Expr>>),
Try(Box<Spanned<Expr>>),
Group(Box<Spanned<Expr>>),
Tuple(Vec<Spanned<Expr>>),
Return(Option<Box<Spanned<Expr>>>),
Array(Vec<Spanned<Expr>>),
ArrayRepeat {
base: Box<Spanned<Expr>>,
len: Box<Spanned<Expr>>,
},
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Label {
pub name: Spanned<Symbol>,
}

#[allow(dead_code)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct AsyncBlock {
pub capture_rule: Option<Spanned<CaptureSpec>>,
pub block: Spanned<Block>,
}

#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct Closure {
pub capture_rule: Option<Spanned<CaptureSpec>>,
pub params: Vec<Spanned<ClosureParam>>,
pub params: Spanned<Vec<Spanned<ClosureParam>>>,
pub retty: Option<Spanned<Type>>,
pub body: Box<Spanned<Expr>>,
}
Expand Down Expand Up @@ -558,6 +573,7 @@ pub enum BinaryOp {
Less,
Greater,
Equal,
NotEqual,
LessEqual,
GreaterEqual,
Assign,
Expand Down Expand Up @@ -595,6 +611,7 @@ impl core::fmt::Display for BinaryOp {
BinaryOp::Less => f.write_str("<"),
BinaryOp::Greater => f.write_str(">"),
BinaryOp::Equal => f.write_str("=="),
BinaryOp::NotEqual => f.write_str("!="),
BinaryOp::LessEqual => f.write_str("<="),
BinaryOp::GreaterEqual => f.write_str(">="),
BinaryOp::Assign => f.write_str("="),
Expand Down
Loading

0 comments on commit 3ad3ffc

Please sign in to comment.