https://github.com/bytebase/tsql-parser
The parser for SQL Server. It is based on the ANTLR4
https://github.com/bytebase/tsql-parser
antlr antlr4 antlr4-parser database parser sql sql-parser sql-server sqlserver
Last synced: 3 months ago
JSON representation
The parser for SQL Server. It is based on the ANTLR4
- Host: GitHub
- URL: https://github.com/bytebase/tsql-parser
- Owner: bytebase
- Created: 2023-07-13T15:48:22.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-11T08:56:25.000Z (7 months ago)
- Last Synced: 2025-04-03T01:53:25.642Z (6 months ago)
- Topics: antlr, antlr4, antlr4-parser, database, parser, sql, sql-parser, sql-server, sqlserver
- Language: C++
- Homepage: https://www.bytebase.com
- Size: 12.7 MB
- Stars: 3
- Watchers: 1
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
The tsql-parser is a parser for T-SQL. It is based on the [ANTLR4](https://github.com/antlr/antlr4) and use the grammar from [antlr4-grammars-plsql](https://github.com/antlr/grammars-v4/tree/master/sql/tsql).
## Build
Before build, you need to install the ANTLR4.
requirements:
- https://github.com/antlr/antlr4/blob/master/doc/getting-started.md
- https://github.com/antlr/antlr4/blob/master/doc/go-target.md```bash
./build.sh
```## Update grammar
### Manually change the grammar file in this project
1. run `./build.sh` to generate the parser code.
### From antlr4-grammars-tsql
1. Clone the `TSqlLexer.g4` and `TSqlParser.g4` grammar files from https://github.com/antlr/grammars-v4/tree/master/sql/snowflake.
2. Clone the examples[https://github.com/antlr/grammars-v4/tree/master/sql/tsql/examples], and use it for test.
3. run `./build.sh` to generate the parser code.## Test the parser
Run `TestTSQLParser` in `parser_test.go` to test the parser.
```bash
go test -v
```## References
- ANTLR4 Getting Started https://github.com/antlr/antlr4/blob/master/doc/getting-started.md
- ANTLR4 Go Garget https://github.com/antlr/antlr4/blob/master/doc/go-target.md## Port
Port folder contains the ported code in another language.