Read SQL text, and it will be tokenlized by lexer into list of tokens. This list of source tokens will be used as the input of the yacc parser.
Yacc parser reads source token in SourceTokenList, based on the syntax of different databases SQL dialect, the parser will create a query parse tree if no syntax error was found. Otherwise, syntax error will be detected.
Translate the raw query parse tree into a formal parse tree, top level node of the formal parse tree is type of sql statements: such as TSelectSqlStatement, TInsertSqlStatement, TDeleteSqlStatement, TUpdateSqlStatement, TCreateTableSqlStatement and etc. which in turn includes other sub parse tree nodes.