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 {
initial: StatementBranch,
else_if: Vec<StatementBranch>,
else_branch: Option<Box<Expression>>,
else_branch: Option<Expression>,
},
Loop(Expression),
While(StatementBranch),
@@ -28,7 +28,7 @@ pub enum Statement {
mutable: bool,
pattern: Pattern,
iterator: Expression,
body: Box<Expression>,
body: Expression,
},
Match(Expression, Vec<(Vec<Pattern>, Expression)>),
@@ -60,7 +60,11 @@ pub struct StatementBranch {
impl Statement {
pub fn is_block(&self) -> bool {
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 {
initial,
else_if,
+1 -1
View File
@@ -91,7 +91,7 @@ generics = { "<" ~ (generic ~ ("," ~ generic)*)? ~ ">" }
// ======================================================
tuple_type = {
"(" ~ (type_expr ~ ("," ~ type_expr)*)? ~ ")"
"[" ~ (type_expr ~ ("," ~ type_expr)*)? ~ "]"
}
path_type = {
+2 -7
View File
@@ -63,12 +63,7 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Statement {
ast_expr!(Statement::If {
initial: inner.next().unwrap().try_into(),
else_if: collect_recovered(inner.next().unwrap().into_inner()),
else_branch: inner
.next()
.map(Expression::try_from)
.transpose()
.map(|v| v.map(Box::new))
.get_map(|v| { Some(Box::new(v)) }),
else_branch: inner.next().map(Expression::try_from).transpose(),
})
}
@@ -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>,
pattern: 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(
+3 -3
View File
@@ -1,7 +1,7 @@
pub enum Event {
Startup,
Shutdown,
TaskExecuted(String),
PluginLoaded(String),
Error(String),
TaskExecuted[String],
PluginLoaded[String],
Error[String],
}