Git Product home page Git Product logo

go-antlrv4-postgresql-parser's Introduction

Antlr v4 Postgresql Golang

简体中文

Steps for usage:

Step 1.

Update the lexical file and grammar file to the latest version, the latest version can be obtained from this place:
https://github.com/antlr/grammars-v4/tree/master/sql/postgresql

Step 2.

First run main.go in the project root directory, convert PostgreSQLLexer.g4 and PostgreSQLParser.g4 into a form suitable for Golang, the converted directory is stored in other directories, and the default is stored in the project root directory Golang directory under .

Why do this step of conversion?

The original g4 file is compatible with Java and C#, but some features of Java and C# cannot be adapted in Golang. For example, in the member method of a class in Java, this can be omitted to call the same class or parent class. method, but not in Golang, you must manually specify the receiver, and other problems such as package paths in golang are different from other languages, but you don't want to change the original g4 file, because once Changing g4 cannot guarantee the correctness of Java and C#. It is very stressful to ensure support for so many languages ine the single g4 file, so I chose to perform it based on the characteristics of golang based on the original file. Tweaked the generated new file so that it could adapt to Golang's syntax

Step 3.

Then use antlr-4.10.1-complete.jar to generate the corresponding code from the converted lexical file and grammar file. The name of the jar package may be different in different versions, please replace it with your own version.

Generate lexical parsing code:

java -jar ./tools/antlr-4.10.1-complete.jar -Dlanguage=Go ./Golang/PostgreSQLLexer.g4 -o parser -visitor

Generate parsing code:

java -jar ./tools/antlr-4.10.1-complete.jar -Dlanguage=Go ./Golang/PostgreSQLParser.g4 -o parser -visitor

Step 4.

Run test/main.go to see if Kangkang can output normally.

go-antlrv4-postgresql-parser's People

Contributors

cc11001100 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

krisdiano

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.