Sunday, February 7, 2016

Writing a SQL Parser using JavaCC

A parser can read the text, put into parts, and help you interpret the meaning. It is a tool for writing a programming language.

JavaCC is a tool I used earlier for application integration.  At that time, there is no XML and EAI vendors started emerging.  Oracle participated in the Open Application Group and helped define the standard business object document (BOD) format that can be used in exchanging data between different application vendors.


I wrote a BOD parser to take the data from the text file.  This experience later helped me in understanding XML and JSON.

SQL is a popular and it does have standards.  However, the syntax in each database is proprietary.
  • Writing SQL parser is important for accepting SQL as a query language.
  • Writing SQL parser also help converting the old reports.
The key is that we need to define the grammar file for the SQL.

Here are some starting points:

PlSql.jj
ANTLR3.3 grammar for Oracle's PL/SQL

 JSqlParser





No comments: