MCPcopy Create free account
hub / github.com/Glyphack/enderpy / parse_assignment_statement

Method parse_assignment_statement

parser/src/parser/parser.rs:1180–1204  ·  view source on GitHub ↗
(
        &mut self,
        start: Node,
        lhs: Expression,
    )

Source from the content-addressed store, hash-verified

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,

Calls 4

bumpMethod · 0.80
parse_expressionsMethod · 0.80
eatMethod · 0.80
finish_nodeMethod · 0.80

Tested by

no test coverage detected