diff --git a/mist-test/src/main.mist b/mist-test/src/main.mist index ad4d9d1..853e686 100644 --- a/mist-test/src/main.mist +++ b/mist-test/src/main.mist @@ -1,4 +1,15 @@ +pub mod app; +pub mod task; +pub mod plugin; +pub mod logger; +pub mod event; + 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.run(); } \ No newline at end of file diff --git a/parser/src/grammar.pest b/parser/src/grammar.pest index 13b699f..13b9787 100644 --- a/parser/src/grammar.pest +++ b/parser/src/grammar.pest @@ -357,8 +357,10 @@ assign_statement = { // CONDITIONALS // ------------------------------------------------------ +statement_branch = { "(" ~ expr ~ ")" ~ statement } + else_if = { - "else" ~ "if" ~ "(" ~ expr ~ ")" ~ statement + "else" ~ "if" ~ statement_branch } else_if_list = { @@ -366,7 +368,7 @@ else_if_list = { } 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" ~ "(" ~ expr ~ ")" ~ statement + "while" ~ statement_branch } c_for_stmt = { diff --git a/parser/src/parser/common/statement.rs b/parser/src/parser/common/statement.rs index 9de2546..18edb8e 100644 --- a/parser/src/parser/common/statement.rs +++ b/parser/src/parser/common/statement.rs @@ -20,11 +20,13 @@ impl<'a> TryFrom> for StatementBranch { type Error = AstError<'a, Self>; fn try_from(pair: pest::iterators::Pair<'a, Rule>) -> Result { - let mut inner = pair.into_inner(); + let mut inner = pair.clone().into_inner(); - ast_expr!(StatementBranch { - condition: inner.next().unwrap().try_into(), - body: inner.next().unwrap().try_into().map(Box::new), + ast_ensure!(pair, Rule::statement_branch => { + ast_expr!(StatementBranch { + condition: inner.next().unwrap().try_into(), + body: inner.next().unwrap().try_into().map(Box::new), + }) }) } } @@ -74,7 +76,7 @@ impl<'a> TryFrom> 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 { init: inner.next().unwrap().try_into().map(Box::new),