(&mut self)
| 1161 | } |
| 1162 | |
| 1163 | fn if_statement(&mut self) -> Option<Stmt<'gc>> { |
| 1164 | // Set the flag before parsing condition |
| 1165 | self.stop_at_brace = true; |
| 1166 | let condition = self.expression()?; |
| 1167 | // Clear the flag after parsing condition |
| 1168 | self.stop_at_brace = false; |
| 1169 | |
| 1170 | self.consume(TokenType::OpenBrace, "Expect '{' before then branch."); |
| 1171 | let then_branch = Box::new(self.block_statement()?); |
| 1172 | |
| 1173 | let else_branch = if self.match_token(TokenType::Else) { |
| 1174 | if self.match_token(TokenType::If) { |
| 1175 | Some(Box::new(self.if_statement()?)) |
| 1176 | } else { |
| 1177 | self.consume(TokenType::OpenBrace, "Expect '{' before else branch."); |
| 1178 | Some(Box::new(self.block_statement()?)) |
| 1179 | } |
| 1180 | } else { |
| 1181 | None |
| 1182 | }; |
| 1183 | |
| 1184 | Some(Stmt::If { |
| 1185 | condition, |
| 1186 | then_branch, |
| 1187 | else_branch, |
| 1188 | line: self.previous.line, |
| 1189 | }) |
| 1190 | } |
| 1191 | |
| 1192 | fn block_statement(&mut self) -> Option<Stmt<'gc>> { |
| 1193 | let statements = self.block(); |
no test coverage detected