fix: statement branch

This commit is contained in:
2026-05-16 07:22:43 +02:00
parent 5174cc34ee
commit 47b179b782
3 changed files with 23 additions and 8 deletions
+11
View File
@@ -1,4 +1,15 @@
pub mod app;
pub mod task;
pub mod plugin;
pub mod logger;
pub mod event;
void main() { void main() {
var mut app_instance = new app::Application("mist-app");
// greeting::register(&mut app_instance);
// statistics::register(&mut app_instance);
app_instance.boot(); app_instance.boot();
app_instance.run(); app_instance.run();
} }
+5 -3
View File
@@ -357,8 +357,10 @@ assign_statement = {
// CONDITIONALS // CONDITIONALS
// ------------------------------------------------------ // ------------------------------------------------------
statement_branch = { "(" ~ expr ~ ")" ~ statement }
else_if = { else_if = {
"else" ~ "if" ~ "(" ~ expr ~ ")" ~ statement "else" ~ "if" ~ statement_branch
} }
else_if_list = { else_if_list = {
@@ -366,7 +368,7 @@ else_if_list = {
} }
if_stmt = { if_stmt = {
"if" ~ "(" ~ expr ~ ")" ~ statement ~ else_if_list ~ ("else" ~ statement)? "if" ~ "(" ~ statement_branch ~ else_if_list ~ ("else" ~ statement)?
} }
// ------------------------------------------------------ // ------------------------------------------------------
@@ -374,7 +376,7 @@ if_stmt = {
// ------------------------------------------------------ // ------------------------------------------------------
while_stmt = { while_stmt = {
"while" ~ "(" ~ expr ~ ")" ~ statement "while" ~ statement_branch
} }
c_for_stmt = { c_for_stmt = {
+4 -2
View File
@@ -20,12 +20,14 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for StatementBranch {
type Error = AstError<'a, Self>; type Error = AstError<'a, Self>;
fn try_from(pair: pest::iterators::Pair<'a, Rule>) -> Result<Self, Self::Error> { fn try_from(pair: pest::iterators::Pair<'a, Rule>) -> Result<Self, Self::Error> {
let mut inner = pair.into_inner(); let mut inner = pair.clone().into_inner();
ast_ensure!(pair, Rule::statement_branch => {
ast_expr!(StatementBranch { ast_expr!(StatementBranch {
condition: inner.next().unwrap().try_into(), condition: inner.next().unwrap().try_into(),
body: inner.next().unwrap().try_into().map(Box::new), body: inner.next().unwrap().try_into().map(Box::new),
}) })
})
} }
} }
@@ -74,7 +76,7 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Statement {
}) })
} }
Rule::while_stmt => ast_expr!(Statement::While(pair.try_into())), Rule::while_stmt => ast_expr!(Statement::While(inner.next().unwrap().try_into())),
Rule::c_for_stmt => ast_expr!(Statement::CStyleFor { Rule::c_for_stmt => ast_expr!(Statement::CStyleFor {
init: inner.next().unwrap().try_into().map(Box::new), init: inner.next().unwrap().try_into().map(Box::new),