implements text tokenizer using PLY