Iterator grammar
This commit is contained in:
@@ -68,6 +68,7 @@ statement = _{
|
|||||||
| if_stmt
|
| if_stmt
|
||||||
| while_stmt
|
| while_stmt
|
||||||
| c_for_stmt
|
| c_for_stmt
|
||||||
|
| for_stmt
|
||||||
| return_stmt
|
| return_stmt
|
||||||
| break_stmt
|
| break_stmt
|
||||||
| continue_stmt
|
| continue_stmt
|
||||||
@@ -104,6 +105,10 @@ c_for_stmt = {
|
|||||||
"for" ~ "(" ~ statement ~ expr ~ semicolon ~ statement ~ ")" ~ statement
|
"for" ~ "(" ~ statement ~ expr ~ semicolon ~ statement ~ ")" ~ statement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for_stmt = {
|
||||||
|
"for" ~ "(" ~ identifier ~ "in" ~ expr ~ ")" ~ statement
|
||||||
|
}
|
||||||
|
|
||||||
// ================= EXPRESSIONS =================
|
// ================= EXPRESSIONS =================
|
||||||
tuple_type = { "(" ~ (type_expr ~ ("," ~ type_expr)*)? ~ ")" }
|
tuple_type = { "(" ~ (type_expr ~ ("," ~ type_expr)*)? ~ ")" }
|
||||||
path_type = { static_path ~ ("<" ~ (type_expr ~ ("," ~ type_expr)*)? ~ ">")? }
|
path_type = { static_path ~ ("<" ~ (type_expr ~ ("," ~ type_expr)*)? ~ ">")? }
|
||||||
|
|||||||
+3
-1
@@ -1,5 +1,7 @@
|
|||||||
void main() {
|
void main() {
|
||||||
for (usize mut i = 0; i < 10; i = i + 1;) {
|
let iter = vec!(1, 2, 3, 4, 5);
|
||||||
|
|
||||||
|
for (i in iter) {
|
||||||
println!("{i}");
|
println!("{i}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user