This is a C++ based SQL Parser and Compiler that takes SQL queries as input, tokenizes them, parses them using LL(1) parsing techniques, and outputs derivations and errors with rich formatted tables using the tabulate library. It also reads grammar from a JSON file and dynamically constructs the parsing table.
- Lexer: Tokenizes SQL queries
- Parser: LL(1) table-based parser
- Custom Grammar Support: Load grammar from
grammar.json - Verbose Debugging: With levels 1 and 2
- Formatted Output: Using
tabulateand syntax highlighting - Cross-platform: Buildable on both Linux and Windows using CMake
| Parsing Table in Action |
![]() |
git clone https://github.com/your-username/sql-compiler.git
cd sql-compilersudo apt update
sudo apt install cmake g++ libfmt-devMake sure you're using C++17 or newer.
mkdir build
cd build
cmake ..
cmake --build ../SQLParser -v 1- Visual Studio 2022
- Install "Desktop Development with C++"
- CMake for Windows
- Open CMakeLists.txt in Visual Studio
- Configure and generate with desired compiler (e.g., MSVC)
- Build the target
SQLParser
In VS:
- Right click the project → Properties
- Go to Debugging → Command Arguments:
--verbose 2
./SQLParser [options]
Options:
-v, --verbose [1|2] Set verbosity level (default: 1)
-h, --help Show this help message.
├── CMakeLists.txt
├── grammar.json
├── src/
│ ├── Lexer.cpp/h
│ ├── Token.cpp/h
│ ├── parser.cpp/h
│ ├── SQL_Interpreter.cpp/h
│ └── Interpreter_main.cpp
├── demo/
│ └── parsing.gif
| Name | GitHub |
|---|---|
| Siddhartha Mondal | @witty-31-06 |
| Soumyadeep Singh | @singhsoumya0109 |
| Sugata Laha | @sugatalaha |
| Subham Mondal | @Subham-Mondal-973 |
This project wouldn't have been possible without the help of these amazing open-source libraries:
- 🧩 nlohmann/json – for elegant and easy-to-use JSON parsing in C++.
- 📊 tabulate – for beautifully formatted and customizable tables in the terminal.
Huge shoutout to their contributors and maintainers! 💙
