Giter Site home page Giter Site logo

gridl / pg_sql_parser Goto Github PK

View Code? Open in Web Editor NEW

This project forked from valgog/pg_sql_parser

0.0 1.0 0.0 5.17 MB

PostgreSQL SQL and PL/pgSQL parser

Java 0.92% PLpgSQL 51.92% Makefile 0.11% ANTLR 8.25% C++ 1.19% C 1.06% Yacc 28.21% Lex 2.30% Python 1.05% SQLPL 4.63% PLSQL 0.36%

pg_sql_parser's Introduction

pg_sql_parser

The aim of this project is to provide a PostgreSQL SQL and PL/pgSQL grammars (ANTLR4) to enable code analysis of Postgres stored procedures in Java and Python.

This is work in progress or even an experiment for now.

METHOD

We create grammar files for a lexer and a parser. ANTLR4 can turn these into java classes for us. We can then use these classes to parse the source code. Having a basic grasp of parsing and ANTLR4 is very valuable in getting started.

GOALS

For this project we have a few different goals, they are here listed in order of ease of expected implementation:

  • Identify relations that are being mentioned (and therefore probably used) in the stored procedures.
  • Reformat source code

REFERENCES

We are not the only one having this idea. There are multiple projects dead and alive which are attempting the same thing. We will list a few as reference, to learn from other's mistakes and ideas.

An ANTLR 4 lexer for PostgreSQL
https://github.com/tunnelvisionlabs/antlr4-grammar-postgresql
Last activity: 4 days ago (September 2014)

pg-parser
https://github.com/claesjac/pg-parser
Last activity: 3 years ago (2011)

Discussion: exporting raw parser
http://postgresql.1045698.n5.nabble.com/exporting-raw-parser-td2018442.html
Last activity: 4 years ago (2010)

pgFormatter
https://github.com/darold/pgFormatter
Last activity: 14 days ago (September 2014)

BUGS

Issue 670

  • ANTLR 4.2.2 Can parse our .g4 files, but cannot generate Python code.
  • ANTLR 4.4 Cannot parse our .g4 files, but can generate Pyton code.
    antlr/antlr4#670

pg_sql_parser's People

Contributors

codechimp avatar valgog avatar feikesteenbergen avatar

Watchers

Dimitri Grinkevich avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.