pyebnf/compiler.py
def _ast_optree_node_to_code(self, node, **kwargs):
    """Convert an abstract syntax operator tree to python source code."""
    opnode = node.opnode
    if opnode is None:
      return self._ast_to_code(node.operands[0])
    else:
      operator = opnode.operator
      if operator is OP_ALTERNATE:
        return self._ast_op_alternate_to_code(node, **kwargs)
      elif operator is OP_WS_CONCAT:
        kwargs["ignore_whitespace"] = False
        return self._ast_op_concat_to_code(node, **kwargs)
      elif operator is OP_CONCAT:
        kwargs["ignore_whitespace"] = True
        return self._ast_op_concat_to_code(node, **kwargs)
      elif operator is OP_EXCLUDE:
        return self._ast_op_exclude_to_code(node, **kwargs)
      elif operator is OP_MULTIPLY:
        return self._ast_op_multiply_to_code(node, **kwargs)
      elif operator is OP_REPEAT:
        return self._ast_op_repeat_to_code(node, **kwargs)
      else:
        raise Exception("Unhandled optree node: {0}".format(node))
def _ast_optree_node_to_code(self, node, **kwargs):
    opnode = node.opnode
    if opnode is None:
      return self._ast_to_code(node.operands[0])
    else:
      operator = opnode.operator
      if operator is OP_ALTERNATE:
        return self._ast_op_alternate_to_code(node, **kwargs)
      elif operator is OP_WS_CONCAT:
        kwargs["ignore_whitespace"] = False
        return self._ast_op_concat_to_code(node, **kwargs)
      elif operator is OP_CONCAT:
        kwargs["ignore_whitespace"] = True
        return self._ast_op_concat_to_code(node, **kwargs)
      elif operator is OP_EXCLUDE:
        return self._ast_op_exclude_to_code(node, **kwargs)
      elif operator is OP_MULTIPLY:
        return self._ast_op_multiply_to_code(node, **kwargs)
      elif operator is OP_REPEAT:
        return self._ast_op_repeat_to_code(node, **kwargs)
      else:
        raise Exception("Unhandled optree node: {0}".format(node))
def _ast_optree_node_to_code ( self , node , * * kwargs ) : opnode = node . opnode if opnode is None : return self . _ast_to_code ( node . operands [ 0 ] ) else : operator = opnode . operator if operator is OP_ALTERNATE : return self . _ast_op_alternate_to_code ( node , * * kwargs ) elif operator is OP_WS_CONCAT : kwargs [ "ignore_whitespace" ] = False return self . _ast_op_concat_to_code ( node , * * kwargs ) elif operator is OP_CONCAT : kwargs [ "ignore_whitespace" ] = True return self . _ast_op_concat_to_code ( node , * * kwargs ) elif operator is OP_EXCLUDE : return self . _ast_op_exclude_to_code ( node , * * kwargs ) elif operator is OP_MULTIPLY : return self . _ast_op_multiply_to_code ( node , * * kwargs ) elif operator is OP_REPEAT : return self . _ast_op_repeat_to_code ( node , * * kwargs ) else : raise Exception ( "Unhandled optree node: {0}" . format ( node ) )
Convert an abstract syntax operator tree to python source code.
Convert an abstract syntax operator tree to python source code .