(script: Union[str, bytes, SupportsRead[str], Path])
| 19 | reconstructor = Reconstructor(lang) |
| 20 | |
| 21 | def parse(script: Union[str, bytes, SupportsRead[str], Path]) -> Tree: |
| 22 | if isinstance(script, Path): |
| 23 | script = script.read_text() |
| 24 | if isinstance(script, SupportsRead): |
| 25 | read_data = script.read() |
| 26 | assert isinstance(read_data, str) |
| 27 | script = read_data |
| 28 | if isinstance(script, bytes): |
| 29 | script = script.decode("utf-8") |
| 30 | return lang.parse(script) |
| 31 | |
| 32 | def unparse(tree: Tree) -> str: |
| 33 | return reconstructor.reconstruct(tree) |