Fixed block propaganda

This commit is contained in:
2026-05-24 12:43:35 +02:00
parent 1c2cc94cb9
commit 6551aee03b
4 changed files with 13 additions and 14 deletions
+7 -3
View File
@@ -14,7 +14,7 @@ pub enum Statement {
If { If {
initial: StatementBranch, initial: StatementBranch,
else_if: Vec<StatementBranch>, else_if: Vec<StatementBranch>,
else_branch: Option<Box<Expression>>, else_branch: Option<Expression>,
}, },
Loop(Expression), Loop(Expression),
While(StatementBranch), While(StatementBranch),
@@ -28,7 +28,7 @@ pub enum Statement {
mutable: bool, mutable: bool,
pattern: Pattern, pattern: Pattern,
iterator: Expression, iterator: Expression,
body: Box<Expression>, body: Expression,
}, },
Match(Expression, Vec<(Vec<Pattern>, Expression)>), Match(Expression, Vec<(Vec<Pattern>, Expression)>),
@@ -60,7 +60,11 @@ pub struct StatementBranch {
impl Statement { impl Statement {
pub fn is_block(&self) -> bool { pub fn is_block(&self) -> bool {
match self { match self {
Self::Block(_) => true, Self::Block(_) | Self::Match(_, _) => true,
Self::While(branch) => branch.body.is_block(),
Self::For { body, .. } | Self::Loop(body) | Self::CStyleFor { body, .. } => {
body.is_block()
}
Self::If { Self::If {
initial, initial,
else_if, else_if,
+1 -1
View File
@@ -91,7 +91,7 @@ generics = { "<" ~ (generic ~ ("," ~ generic)*)? ~ ">" }
// ====================================================== // ======================================================
tuple_type = { tuple_type = {
"(" ~ (type_expr ~ ("," ~ type_expr)*)? ~ ")" "[" ~ (type_expr ~ ("," ~ type_expr)*)? ~ "]"
} }
path_type = { path_type = {
+2 -7
View File
@@ -63,12 +63,7 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Statement {
ast_expr!(Statement::If { ast_expr!(Statement::If {
initial: inner.next().unwrap().try_into(), initial: inner.next().unwrap().try_into(),
else_if: collect_recovered(inner.next().unwrap().into_inner()), else_if: collect_recovered(inner.next().unwrap().into_inner()),
else_branch: inner else_branch: inner.next().map(Expression::try_from).transpose(),
.next()
.map(Expression::try_from)
.transpose()
.map(|v| v.map(Box::new))
.get_map(|v| { Some(Box::new(v)) }),
}) })
} }
@@ -87,7 +82,7 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Statement {
mutable: Ok(listen_rule(&mut inner, Rule::mutable)) as AstResult<'_, bool>, mutable: Ok(listen_rule(&mut inner, Rule::mutable)) as AstResult<'_, bool>,
pattern: inner.next().unwrap().try_into(), pattern: inner.next().unwrap().try_into(),
iterator: inner.next().unwrap().try_into(), iterator: inner.next().unwrap().try_into(),
body: inner.next().unwrap().try_into().map(Box::new), body: inner.next().unwrap().try_into(),
}), }),
Rule::match_stmt => ast_expr!(Statement::Match( Rule::match_stmt => ast_expr!(Statement::Match(
+3 -3
View File
@@ -1,7 +1,7 @@
pub enum Event { pub enum Event {
Startup, Startup,
Shutdown, Shutdown,
TaskExecuted(String), TaskExecuted[String],
PluginLoaded(String), PluginLoaded[String],
Error(String), Error[String],
} }