Recover the linear token stream.
(self: _NodeType)
| 88 | return self.children[item] |
| 89 | |
| 90 | def to_tokens(self: _NodeType) -> list[Token]: |
| 91 | """Recover the linear token stream.""" |
| 92 | |
| 93 | def recursive_collect_tokens(node: _NodeType, token_list: list[Token]) -> None: |
| 94 | if node.type == "root": |
| 95 | for child in node.children: |
| 96 | recursive_collect_tokens(child, token_list) |
| 97 | elif node.token: |
| 98 | token_list.append(node.token) |
| 99 | else: |
| 100 | assert node.nester_tokens |
| 101 | token_list.append(node.nester_tokens.opening) |
| 102 | for child in node.children: |
| 103 | recursive_collect_tokens(child, token_list) |
| 104 | token_list.append(node.nester_tokens.closing) |
| 105 | |
| 106 | tokens: list[Token] = [] |
| 107 | recursive_collect_tokens(self, tokens) |
| 108 | return tokens |
| 109 | |
| 110 | @property |
| 111 | def children(self: _NodeType) -> list[_NodeType]: |
no outgoing calls