step table (S tt@(Atom x:ts) st@(s:ss) oo _)
  | applicator' table s =
  case findBoth table x st of
    BBegin pt1
      | not (leftOpen pt1) && rightHole pt1 == Just SExpression ->
      S ts (Part pt1:st) ([]:oo) StackL
      | not (leftOpen pt1) ->
      S ts (Part pt1:st) oo StackL
    _ ->
      S tt ss (apply s oo) Application

-- An operator part is on the input stack and on the stack.
step table (S tt@(Atom x:ts) st@(s:ss) oo _)
  | applicator' table s =
  case findBoth table x st of
    BBegin pt1
      | not (leftOpen pt1) && rightHole pt1 == Just SExpression ->
      S ts (Part pt1:st) ([]:oo) StackL
      | not (leftOpen pt1) ->
      S ts (Part pt1:st) oo StackL
    _ ->
      S tt ss (apply s oo) Application

-- An operator part is on the input stack and on the stack.
step table (S tt@(Atom x:ts) st@(s:ss) oo _)
  | applicator' table s =
  case findBoth table x st of
    BBegin pt1
      | not (leftOpen pt1) && rightHole pt1 == Just SExpression ->
      S ts (Part pt1:st) ([]:oo) StackL
      | not (leftOpen pt1) ->
      S ts (Part pt1:st) oo StackL
    _ ->
      S tt ss (apply s oo) Application

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