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)
| 467 | /// |
| 468 | /// See: <https://docs.python.org/3/reference/expressions.html#atom-identifiers> |
| 469 | pub(super) fn parse_name(&mut self, context: ExpressionContext) -> ast::ExprName { |
| 470 | let identifier = self.parse_identifier_with_context(context); |
| 471 | |
| 472 | let ctx = if identifier.is_valid() { |
| 473 | ExprContext::Load |
| 474 | } else { |
| 475 | ExprContext::Invalid |
| 476 | }; |
| 477 | |
| 478 | ast::ExprName { |
| 479 | range: identifier.range, |
| 480 | id: identifier.id, |
| 481 | ctx, |
| 482 | node_index: AtomicNodeIndex::NONE, |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | pub(super) fn parse_missing_name(&mut self) -> ast::ExprName { |
| 487 | let identifier = self.parse_missing_identifier(); |
no test coverage detected