statement body parsing

This commit is contained in:
2026-05-24 12:55:33 +02:00
parent 6551aee03b
commit f4fe38140a
3 changed files with 48 additions and 11 deletions
+9 -5
View File
@@ -343,6 +343,10 @@ statement = _{
| (expr ~ semicolon)
}
statement_wrapper = { statement }
statement_body = { statement_wrapper | expr }
// ------------------------------------------------------
// BASIC STATEMENTS
// ------------------------------------------------------
@@ -384,7 +388,7 @@ control_flow = {
| block
}
statement_branch = { "(" ~ expr ~ ")" ~ statement }
statement_branch = { "(" ~ expr ~ ")" ~ statement_body }
else_if = {
"else" ~ "if" ~ statement_branch
@@ -395,7 +399,7 @@ else_if_list = {
}
if_stmt = {
"if" ~ statement_branch ~ else_if_list ~ ("else" ~ statement)?
"if" ~ statement_branch ~ else_if_list ~ ("else" ~ statement_body)?
}
// ------------------------------------------------------
@@ -407,15 +411,15 @@ while_stmt = {
}
c_for_stmt = {
"for" ~ "(" ~ statement ~ statement ~ expr ~ ")" ~ statement
"for" ~ "(" ~ statement ~ statement ~ expr ~ ")" ~ statement_body
}
for_stmt = {
"for" ~ "(" ~ mutable? ~ pattern ~ ":" ~ expr ~ ")" ~ statement
"for" ~ "(" ~ mutable? ~ pattern ~ ":" ~ expr ~ ")" ~ statement_body
}
loop_stmt = {
"loop" ~ statement
"loop" ~ statement_body
}
// ------------------------------------------------------