Parses a name. For an invalid name, the `id` field will be an empty string and the `ctx` field will be [`ExprContext::Invalid`]. See:
(&mut self, context: ExpressionContext)
| 534 | /// |
| 535 | /// See: <https://docs.python.org/3/reference/expressions.html#atom-identifiers> |
| 536 | pub(super) fn parse_name(&mut self, context: ExpressionContext) -> ast::ExprName { |
| 537 | let identifier = self.parse_identifier_with_context(context); |
| 538 | |
| 539 | let ctx = if identifier.is_valid() { |
| 540 | ExprContext::Load |
| 541 | } else { |
| 542 | ExprContext::Invalid |
| 543 | }; |
| 544 | |
| 545 | ast::ExprName { |
| 546 | range: identifier.range, |
| 547 | id: identifier.id, |
| 548 | ctx, |
| 549 | node_index: AtomicNodeIndex::NONE, |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | pub(super) fn parse_missing_name(&mut self) -> ast::ExprName { |
| 554 | let identifier = self.parse_missing_identifier(); |
no test coverage detected