def p_ioports(self, p):
        'ioports : ioports COMMA ioport'
        if isinstance(p[3], str):
            t = None
            for r in reversed(p[1]):
                if isinstance(r.first, Input):
                    t = Ioport(Input(name=p[3], width=r.first.width, lineno=p.lineno(3)),
                               lineno=p.lineno(3))
                    break
                if isinstance(r.first, Output) and r.second is None:
                    t = Ioport(Output(name=p[3], width=r.first.width, lineno=p.lineno(3)),
                               lineno=p.lineno(3))
                    break
                if isinstance(r.first, Output) and isinstance(r.second, Reg):
                    t = Ioport(Output(name=p[3], width=r.first.width, lineno=p.lineno(3)),
                               Reg(name=p[3], width=r.first.width,
                                   lineno=p.lineno(3)),
                               lineno=p.lineno(3))
                    break
                if isinstance(r.first, Inout):
                    t = Ioport(Inout(name=p[3], width=r.first.width, lineno=p.lineno(3)),
                               lineno=p.lineno(3))
                    break
            p[0] = p[1] + (t,)
        else:
            p[0] = p[1] + (p[3],)
        p.set_lineno(0, p.lineno(1))