pyebnf/compiler.py
def _ast_to_code(self, node, **kwargs):
    """Convert an abstract syntax tree to python source code."""
    if isinstance(node, OptreeNode):
      return self._ast_optree_node_to_code(node, **kwargs)
    elif isinstance(node, Identifier):
      return self._ast_identifier_to_code(node, **kwargs)
    elif isinstance(node, Terminal):
      return self._ast_terminal_to_code(node, **kwargs)
    elif isinstance(node, OptionGroup):
      return self._ast_option_group_to_code(node, **kwargs)
    elif isinstance(node, RepetitionGroup):
      return self._ast_repetition_group_to_code(node, **kwargs)
    elif isinstance(node, SpecialHandling):
      return self._ast_special_handling_to_code(node, **kwargs)
    elif isinstance(node, Number):
      return self._ast_number_to_code(node, **kwargs)
    else:
      raise Exception("Unhandled ast node: {0}".format(node))
def _ast_to_code(self, node, **kwargs):
    """Convert an abstract syntax tree to python source code."""
    if isinstance(node, OptreeNode):
      return self._ast_optree_node_to_code(node, **kwargs)
    elif isinstance(node, Identifier):
      return self._ast_identifier_to_code(node, **kwargs)
    elif isinstance(node, Terminal):
      return self._ast_terminal_to_code(node, **kwargs)
    elif isinstance(node, OptionGroup):
      return self._ast_option_group_to_code(node, **kwargs)
    elif isinstance(node, RepetitionGroup):
      return self._ast_repetition_group_to_code(node, **kwargs)
    elif isinstance(node, SpecialHandling):
      return self._ast_special_handling_to_code(node, **kwargs)
    elif isinstance(node, Number):
      return self._ast_number_to_code(node, **kwargs)
    else:
      raise Exception("Unhandled ast node: {0}".format(node))
Convert an abstract syntax tree to python source code.