Get a registered method for a dispatch token and type name, or return a default method if no registered methods with this dispatch token and type name. Parameters ---------- token : str The token for IR, e.g., T for TIR and R for Relax. type_name : str The type
(
token: str,
type_name: str,
default: ParseMethod | None = None,
)
| 64 | |
| 65 | |
| 66 | def get( |
| 67 | token: str, |
| 68 | type_name: str, |
| 69 | default: ParseMethod | None = None, |
| 70 | ) -> ParseMethod | None: |
| 71 | """Get a registered method for a dispatch token and type name, |
| 72 | or return a default method if no registered methods with this dispatch token and type name. |
| 73 | |
| 74 | Parameters |
| 75 | ---------- |
| 76 | token : str |
| 77 | The token for IR, e.g., T for TIR and R for Relax. |
| 78 | |
| 79 | type_name : str |
| 80 | The type name of AST node, e.g., FunctionDef, With, For. |
| 81 | |
| 82 | default : Optional[ParseMethod] |
| 83 | The default method when no registered methods with this dispatch token and type name. |
| 84 | |
| 85 | Returns |
| 86 | ------- |
| 87 | func : Optional[ParseMethod] |
| 88 | The dispatched method of parsing corresponding token and AST node type. |
| 89 | """ |
| 90 | return ParseVTable.get((token, type_name), default) |
| 91 | |
| 92 | |
| 93 | def register_op(operand_type: type, op_node_type: AST, operand_index: int): |