fix: statement branch
This commit is contained in:
@@ -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();
|
||||
}
|
||||
@@ -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 = {
|
||||
|
||||
@@ -20,11 +20,13 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for StatementBranch {
|
||||
type Error = AstError<'a, Self>;
|
||||
|
||||
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_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<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 {
|
||||
init: inner.next().unwrap().try_into().map(Box::new),
|
||||
|
||||
Reference in New Issue
Block a user