If you need something custom, you might consider reading [Federico Tomassetti’s] tutorial on using ANTLR to build a complete ... If you are using C, you might consider looking up lex and yacc ...