implemented regex to fsm parser