Skip to content

Latest commit

Β 

History

History
144 lines (97 loc) Β· 3.05 KB

File metadata and controls

144 lines (97 loc) Β· 3.05 KB

SQL Compiler & Parser

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.


🧰 Features

  • 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 tabulate and syntax highlighting
  • Cross-platform: Buildable on both Linux and Windows using CMake

πŸ“Έ Demo

Parsing Table in Action

πŸš€ Getting Started

🐧 Linux Instructions

1. Clone the Repository

git clone https://github.com/your-username/sql-compiler.git
cd sql-compiler

2. Install Dependencies

sudo apt update
sudo apt install cmake g++ libfmt-dev

Make sure you're using C++17 or newer.

3. Build the Project

mkdir build
cd build
cmake ..
cmake --build .

4. Run the Executable

./SQLParser -v 1

πŸͺŸ Windows Instructions (VS 2022)

1. Install Tools

2. Open Project

  • Open CMakeLists.txt in Visual Studio
  • Configure and generate with desired compiler (e.g., MSVC)
  • Build the target SQLParser

3. Run with Arguments

In VS:

  • Right click the project β†’ Properties
  • Go to Debugging β†’ Command Arguments:
    --verbose 2

βš™οΈ Command-Line Usage

./SQLParser [options]

Options:
  -v, --verbose [1|2]    Set verbosity level (default: 1)
  -h, --help             Show this help message

πŸ“ Project Structure

.
β”œβ”€β”€ CMakeLists.txt
β”œβ”€β”€ grammar.json
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ Lexer.cpp/h
β”‚   β”œβ”€β”€ Token.cpp/h
β”‚   β”œβ”€β”€ parser.cpp/h
β”‚   β”œβ”€β”€ SQL_Interpreter.cpp/h
β”‚   └── Interpreter_main.cpp
β”œβ”€β”€ demo/
β”‚   └── parsing.gif

πŸ‘¨β€πŸ’» Contributors

Name GitHub
Siddhartha Mondal @witty-31-06
Soumyadeep Singh @singhsoumya0109
Sugata Laha @sugatalaha
Subham Mondal @Subham-Mondal-973

πŸ“¦ Special Thanks

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! πŸ’™