How can a Sql parser be written? Is there a tool or else manually we have to program and get the tokens. Please help.

Thanks