The entire parsing engine is organized in 3 layers:
The generated C parsers wrapped by small classes to provide a C++ interface (including a tree walker, the mention syntax checker and a scanner). You can find all related files in the “library/mysql.parser” subfolder. The generated and wrapper files are:
MySQL.tokens (a list of token names and their values)
MySQLLexer.h/c (the generated lexer)
mysql-scanner.h/cpp (the C++ wrapper around the generated lexer)
MySQLParserc.h/c (the generated (full) parser)
mysql-parser.h/cpp (the C++ wrapper around the generated (full) parser)
MySQLSimpleParser.h/c (the generated parser without AST creation) + its token file
mysql-syntax-check.h/cpp (the C++ wrapper for that, it shares the lexer with the main parser)
Some support files (mysql-parser-common.h/cpp, mysql-recognition-types.h)
The “library/mysql.parser/grammar” folder contains the 2 grammar files (full + simplified parser), build scripts for each platform and the test application (currently for OSX only).
A module providing our socalled parsing services, including parsing of individual create statements (e.g. for our table or view editors). The parsing services mostly deal with conversion of sql text into our grt tree structure, which is the base for all object editors etc. Currently this is separated into a dynamically loadable module, containing the actual implementation and an abstract class for direct use of the module within Workbench. The related files are:
modules/db.mysql.parser/src/mysql_parser_module.h/cpp (the module with most of the actual code)
backend/wbpublic/grtsqlparser/mysql_parser_services.h/cpp (the abstract interface for the module + some support code)
The editor backend driving the UI, connecting the parsing services and implementing error checking + markup as well as code completion. This layer is spread over a couple of files, all dealing with a specific aspect of handling sql code, which includes query determination and data type parsing as well as our object editors and the sql editor backend. This backend is a good example of the integration of GUI, Workbench backend and parser services including syntax checks and code completion (backend/wbpublic/sqlide/sql_editor_be.h/cpp).