-- An applicator is on the input stack.
step table (S (t:ts) st@(s:_) oo@(os:oss) _)
  | applicator table t = case s of
  Part y
    | rightHole y == Just SExpression ->
      S ts st ((t:os):oss) SExpr
    | otherwise ->
      S ts (s2t t:st) ([]:oo) StackApp
  Leaf _                       -> S ts st ((t:os):oss) Argument
  Branch _                     -> S ts st ((t:os):oss) Argument

-- An operator part is on the input stack and an applicator is on
-- the stack.
step table (S (t:ts) st@(s:_) oo@(os:oss) _)
  | applicator table t = case s of
  Part y
    | rightHole y == Just SExpression ->
      S ts st ((t:os):oss) SExpr
    | otherwise ->
      S ts (s2t t:st) ([]:oo) StackApp
  Leaf _                       -> S ts st ((t:os):oss) Argument
  Branch _                     -> S ts st ((t:os):oss) Argument

-- An operator part is on the input stack and an applicator is on
-- the stack.
step table (S (t:ts) st@(s:_) oo@(os:oss) _)
  | applicator table t = case s of
  Part y
    | rightHole y == Just SExpression ->
      S ts st ((t:os):oss) SExpr
    | otherwise ->
      S ts (s2t t:st) ([]:oo) StackApp
  Leaf _                       -> S ts st ((t:os):oss) Argument
  Branch _                     -> S ts st ((t:os):oss) Argument

-- An operator part is on the input stack and an applicator is on
-- the stack.