FSM based tokenizer