Calculator based on FSM (final state machine).