A polynomial-time parsing algorithm for a class of nondeterministic two-stack automata