| 283 | |
| 284 | |
| 285 | class Rule(ASTNode): |
| 286 | def __init__(self, *args, **kwargs): |
| 287 | super(Rule, self).__init__(*args, **kwargs) |
| 288 | |
| 289 | assert self.value is None and self.label is None, 'Rule LHS cannot have values or labels' |
| 290 | |
| 291 | @property |
| 292 | def parent(self): |
| 293 | return self.as_type_node |
| 294 | |
| 295 | def __repr__(self): |
| 296 | parent = typename(self.type) |
| 297 | |
| 298 | if self.label is not None: |
| 299 | parent += '{%s}' % self.label |
| 300 | |
| 301 | if self.value is not None: |
| 302 | parent += '{val=%s}' % self.value |
| 303 | |
| 304 | return '%s -> %s' % (parent, ', '.join([repr(c) for c in self.children])) |
| 305 | |
| 306 | |
| 307 | if __name__ == '__main__': |
no outgoing calls
no test coverage detected