C style for loop grammar

This commit is contained in:
2026-05-05 16:34:55 +02:00
parent 0d00ebcd2c
commit 9eeaabbf19
2 changed files with 8 additions and 1 deletions
+5
View File
@@ -67,6 +67,7 @@ statement = _{
| assign_statement
| if_stmt
| while_stmt
| c_for_stmt
| return_stmt
| break_stmt
| continue_stmt
@@ -99,6 +100,10 @@ while_stmt = {
"while" ~ "(" ~ expr ~ ")" ~ statement
}
c_for_stmt = {
"for" ~ "(" ~ statement ~ expr ~ ";" ~ statement ~ ")" ~ statement
}
// ================= EXPRESSIONS =================
tuple_type = { "(" ~ (type_expr ~ ("," ~ type_expr)*)? ~ ")" }
path_type = { static_path ~ ("<" ~ (type_expr ~ ("," ~ type_expr)*)? ~ ">")? }
+3 -1
View File
@@ -1,3 +1,5 @@
void main() {
for (usize i; i < 10; i = i + 1;) {
println!("{i}");
}
}