Improved for loops
This commit is contained in:
@@ -19,10 +19,10 @@ pub enum Statement {
|
||||
},
|
||||
While(StatementBranch),
|
||||
CStyleFor {
|
||||
init: Box<Statement>,
|
||||
init: Expression,
|
||||
condition: Expression,
|
||||
update: Box<Statement>,
|
||||
body: Box<Statement>,
|
||||
update: Expression,
|
||||
body: Expression,
|
||||
},
|
||||
For {
|
||||
mutable: bool,
|
||||
|
||||
@@ -405,11 +405,11 @@ while_stmt = {
|
||||
}
|
||||
|
||||
c_for_stmt = {
|
||||
"for" ~ "(" ~ statement ~ expr ~ semicolon ~ statement ~ ")" ~ statement
|
||||
"for" ~ "(" ~ statement ~ statement ~ expr ~ ")" ~ statement
|
||||
}
|
||||
|
||||
for_stmt = {
|
||||
"for" ~ "(" ~ mutable? ~ pattern ~ "in" ~ expr ~ ")" ~ statement
|
||||
"for" ~ "(" ~ mutable? ~ pattern ~ ":" ~ expr ~ ")" ~ statement
|
||||
}
|
||||
|
||||
// ------------------------------------------------------
|
||||
|
||||
@@ -75,10 +75,10 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Statement {
|
||||
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),
|
||||
init: inner.next().unwrap().try_into(),
|
||||
condition: inner.next().unwrap().try_into(),
|
||||
update: inner.next().unwrap().try_into().map(Box::new),
|
||||
body: inner.next().unwrap().try_into().map(Box::new),
|
||||
update: inner.next().unwrap().try_into(),
|
||||
body: inner.next().unwrap().try_into(),
|
||||
}),
|
||||
|
||||
Rule::for_stmt => ast_expr!(Statement::For {
|
||||
|
||||
Reference in New Issue
Block a user