(
&mut self,
start: Node,
lhs: Expression,
)
| 1178 | } |
| 1179 | |
| 1180 | fn parse_assignment_statement( |
| 1181 | &mut self, |
| 1182 | start: Node, |
| 1183 | lhs: Expression, |
| 1184 | ) -> Result<Statement, ParsingError> { |
| 1185 | let mut targets = vec![lhs]; |
| 1186 | self.bump(Kind::Assign); |
| 1187 | let value = loop { |
| 1188 | let rhs = self.parse_expressions()?; |
| 1189 | // if there's an assign after the expression we have multiple targets |
| 1190 | // like a = b = 1 |
| 1191 | // so we add the rhs to the targets and continue parsing |
| 1192 | // otherwise we break and return the rhs as the value |
| 1193 | if self.eat(Kind::Assign) { |
| 1194 | targets.push(rhs); |
| 1195 | } else { |
| 1196 | break rhs; |
| 1197 | } |
| 1198 | }; |
| 1199 | Ok(Statement::AssignStatement(Box::new(Assign { |
| 1200 | node: self.finish_node(start), |
| 1201 | targets, |
| 1202 | value, |
| 1203 | }))) |
| 1204 | } |
| 1205 | |
| 1206 | fn parse_aug_assignment_statement( |
| 1207 | &mut self, |
no test coverage detected