how to create tokens from CFG
The problem of creating a parse tree given a grammar and a word generated by it is known as parsing. The CYK algorithm parses all context-free grammars, but is slow. In practice, only restricted types of context-free grammars are used, and these can be parsed in linear time. The common example is LALR parsing. Perhaps you will learn more about this topic in due time.