Finite State Machine Implementation
Added grammar