| 171 | |
| 172 | @dataclass |
| 173 | class MacroIfStmt(Stmt): |
| 174 | condition: lx.Token |
| 175 | body: list[Stmt] |
| 176 | else_: lx.Token | None |
| 177 | else_body: list[Stmt] | None |
| 178 | endif: lx.Token |
| 179 | |
| 180 | def print(self, out:CWriter) -> None: |
| 181 | out.emit(self.condition) |
| 182 | for stmt in self.body: |
| 183 | stmt.print(out) |
| 184 | if self.else_body is not None: |
| 185 | out.emit("#else\n") |
| 186 | for stmt in self.else_body: |
| 187 | stmt.print(out) |
| 188 | |
| 189 | def accept(self, visitor: Visitor) -> None: |
| 190 | visitor(self) |
| 191 | for stmt in self.body: |
| 192 | stmt.accept(visitor) |
| 193 | if self.else_body is not None: |
| 194 | for stmt in self.else_body: |
| 195 | stmt.accept(visitor) |
| 196 | |
| 197 | def tokens(self) -> Iterator[lx.Token]: |
| 198 | yield self.condition |
| 199 | for stmt in self.body: |
| 200 | yield from stmt.tokens() |
| 201 | if self.else_body is not None: |
| 202 | for stmt in self.else_body: |
| 203 | yield from stmt.tokens() |
| 204 | |
| 205 | |
| 206 | @dataclass |
no outgoing calls
no test coverage detected
searching dependent graphs…