GithubHelp home page GithubHelp logo

jimidle / tsqlparser Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 27.49 MB

An implementation of an ANTLR4 TSQL grammar at the 2008R2 spec

License: MIT License

ANTLR 31.16% Java 3.75% TSQL 63.94% PLpgSQL 1.15%

tsqlparser's Introduction

TSQL as of 2008R2

Introduction

This grammar was originally an ANTLR v3 grammar, with at most LL(3) token lookahead, and is now converted to ANTLR v4.

The original grammar used the ANTLR3 AST building techniques and as such, some of the grammar rules are a little more verbose and expanded out than they strictly need to be. However, as any serious use of this grammar will likely involve some form of AST construction, it makes sense to leave it as is.

The expression rule, which is the basis of much of the otherwise overly verbose SQL language, has been adapted to use the ANTLR4 left-recursive expression rule pattern, which is easier to deal with than the expanded precedence orient rules that v3 required. The predicate pattern has also been adapted to v4.

Why?

There a number of SQL grammars published in the ANTLR contributed grammars repository, but they all suffer from being cut-down copies of the normative specs, without regard to the actual language and parsing efficiency.

This was a commercial implementation of TSQL and as such, I consider it high quality. It does not suffer from the problems of massive specification ambiguity and in many cases can parse TSQL in SLL mode. The SQL mistake of making ';' generally optional, makes otherwise trivially parsed statements such as GO more ambiguous than they need to be, but that is a relatively minor issue.

Compatibility

This grammar is entirely complete with TSQL 2008R2, but since that time, TSQL has been expanded with many constructs that would need to be added to catch up with the latest spec. Contributions are welcome, however, they will need to be written in the same style as the existing grammar, avoiding ambiguity and not just copying the normative spec/BMF.

LICENSE

The MIT license pretty much allows you to do anything with this grammar other than claim it as your own. If you use it, please let me know, I would be interested to know how it is being used. The only requirement is attribution.

tsqlparser's People

Contributors

jimidle avatar

Watchers

 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.