def prefix_suffix_table(text):

    """
    build prefix—suffix-table
    >>> prefix_suffix_table('ananasy')
    [-1, 0, 0, 1, 2, 3, 0, 0]
    """

    t = -1
    p = [t]

    for x in text:
        while t >= 0 and x != text[t]:
            t = p[t]
        t += 1
        p.append(t)

    return p