Added forever loop

This commit is contained in:
2026-05-22 03:05:08 +02:00
parent d33763be2e
commit a26c1c31fb
5 changed files with 21 additions and 1 deletions
+1
View File
@@ -16,6 +16,7 @@ pub enum Statement {
else_if: Vec<StatementBranch>,
else_branch: Option<Box<Statement>>,
},
Loop(Expression),
While(StatementBranch),
CStyleFor {
init: Expression,
+6
View File
@@ -29,6 +29,7 @@ keyword = {
| "true"
| "false"
| "dyn"
| "loop"
}
identifier = @{
@@ -379,6 +380,7 @@ control_flow = {
| c_for_stmt
| for_stmt
| match_stmt
| loop_stmt
| block
}
@@ -412,6 +414,10 @@ for_stmt = {
"for" ~ "(" ~ mutable? ~ pattern ~ ":" ~ expr ~ ")" ~ statement
}
loop_stmt = {
"loop" ~ statement
}
// ------------------------------------------------------
// MATCH
// ------------------------------------------------------
+2
View File
@@ -74,6 +74,8 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Statement {
Rule::while_stmt => ast_expr!(Statement::While(inner.next().unwrap().try_into())),
Rule::loop_stmt => ast_expr!(Statement::Loop(inner.next().unwrap().try_into())),
Rule::c_for_stmt => ast_expr!(Statement::CStyleFor {
init: inner.next().unwrap().try_into(),
condition: inner.next().unwrap().try_into(),