Use Flex & Bison to parse SQL. Implemented in much elegant way.