Expression assignment evaluation when parsing. Parameters ---------- target : doc.expr The root node of AST tree node of assigned expression to evaluate. source : Any The source to be assigned with evaluated expression. bind_value :
(
self,
target: doc.expr,
source: Any,
bind_value: Callable[["Parser", doc.expr, str, Any], Any],
allow_shadowing: bool = False,
)
| 562 | raise NotImplementedError |
| 563 | |
| 564 | def eval_assign( |
| 565 | self, |
| 566 | target: doc.expr, |
| 567 | source: Any, |
| 568 | bind_value: Callable[["Parser", doc.expr, str, Any], Any], |
| 569 | allow_shadowing: bool = False, |
| 570 | ) -> dict[str, Any]: |
| 571 | """Expression assignment evaluation when parsing. |
| 572 | |
| 573 | Parameters |
| 574 | ---------- |
| 575 | target : doc.expr |
| 576 | The root node of AST tree node of assigned expression to evaluate. |
| 577 | |
| 578 | source : Any |
| 579 | The source to be assigned with evaluated expression. |
| 580 | |
| 581 | bind_value : Callable[["Parser", doc.expr, str, Any], Any] |
| 582 | The value binding method when assigning the values to variables. |
| 583 | |
| 584 | allow_shadowing : bool |
| 585 | The options of whether variable shadowing allowed for assignment. |
| 586 | |
| 587 | Returns |
| 588 | ------- |
| 589 | res : Dict[str, Any] |
| 590 | The dictionary of assignment result. |
| 591 | """ |
| 592 | if self._duplicate_lhs_check(target) is True: |
| 593 | self.report_error(target, "Duplicate vars assigned.") |
| 594 | var_values = eval_assign(self, target, source) |
| 595 | for k, v in var_values.items(): |
| 596 | var = bind_value(self, target, k, v) |
| 597 | self.var_table.add(k, var, allow_shadowing) |
| 598 | return var_values |
| 599 | |
| 600 | def report_error(self, node: doc.AST, err: Exception | str) -> None: # pylint: disable=no-self-use |
| 601 | """The error reporting when parsing. |
no test coverage detected