diff --git a/parser/src/grammar.pest b/parser/src/grammar.pest index c5c2e20..e19f0e9 100644 --- a/parser/src/grammar.pest +++ b/parser/src/grammar.pest @@ -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)*)? ~ ">")? } diff --git a/test/src/main.mist b/test/src/main.mist index bd51952..1ecf710 100644 --- a/test/src/main.mist +++ b/test/src/main.mist @@ -1,3 +1,5 @@ void main() { - + for (usize i; i < 10; i = i + 1;) { + println!("{i}"); + } }