Input parsing using FSM.