Implements the Stack parsing algorithms.