def _trans_inout(self, ast):
     ret = Ast("pin")
     name = ast.get_children()[0]
     ret.set_attr("name", name.value)
     size = ast.find_children_by_id('size')
     if size:
         size = size[0]
         ret.set_attr("bus-size", size.value)
     return ret
    def _trans_chip(self, ast):

        ret = Ast("chip")
        ret.set_attr("name", ast.find_children_by_id('name')[0].value)

        ret.add_children_by_name(ast, "inputs")
        ret.add_children_by_name(ast, "outputs")
        ret.add_children_by_name(ast, "parts")
        ret.add_children_by_name(ast, "builtin")

        return ret
 def _trans_connection(self, ast):
     ret = Ast('connection')
     lhs = Ast('pin')
     ret.add_child(lhs)
     lhs.set_attr("name", ast.find_children_by_id('param')[0].value)
     from_ = ast.find_children_by_id('from')
     if from_:
         from_ = from_[0].value
         to = ast.find_children_by_id('to')[0].value
         lhs.set_attr("from", from_)
         lhs.set_attr("to", to)
     value = ast.get_children()[-1]
     ret.add_child(value)
     return ret
 def _trans_value(self, ast):
     children = ast.get_children()
     if len(children) == 1:
         child = children[0]
         if child.name == "TRUE" or child.name == "FALSE":
             return Ast(child.name.lower())
     ret = Ast("pin")
     ret.set_attr("name", ast.find_children_by_id('pin')[0].value)
     from_ = ast.find_children_by_id('from')
     if from_:
         from_ = from_[0].value
         to = ast.find_children_by_id('to')[0].value
         ret.set_attr("from", from_)
         ret.set_attr("to", to)
     return ret
 def _trans_part(self, ast):
     ret = Ast('part')
     chip = ast.find_children_by_id("chip")[0].value
     ret.set_attr("chip-name", chip)
     ret.add_children_by_id(ast, "conn")
     return ret
 def _trans_builtin(self, ast):
     ret = Ast("builtin")
     ret.set_attr("chip-name", ast.find_children_by_id("chip")[0].value)
     return ret