Skip to content

Commit

Permalink
Merge pull request #123 from tursodatabase/inline_parser
Browse files Browse the repository at this point in the history
Copy code from github.com/libsql/sqlite-antlr4-parser and stop using the external package
  • Loading branch information
haaawk authored Jul 15, 2024
2 parents 6d998ac + 1f22c3e commit 518abad
Show file tree
Hide file tree
Showing 24 changed files with 38,201 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
run: go get ./...

- name: Vet
run: go vet -v ./...
run: go vet -v $(go list ./... | grep -v "github.com/tursodatabase/libsql-client-go/sqliteparser$")

- name: Install sqlclosecheck
run: go install github.com/ryanrolds/sqlclosecheck@latest
Expand All @@ -49,7 +49,7 @@ jobs:
run: go vet -vettool=${HOME}/go/bin/sqlclosecheck ./...

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6

- name: Build
run: go build -v ./...
Expand Down
9 changes: 1 addition & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,8 @@ go 1.20

require (
github.com/antlr4-go/antlr/v4 v4.13.0
github.com/libsql/sqlite-antlr4-parser v0.0.0-20240327125255-dbf53b6cbf06
github.com/stretchr/testify v1.9.0
golang.org/x/sync v0.3.0
nhooyr.io/websocket v1.8.10
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
require golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect
12 changes: 0 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI=
github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/libsql/sqlite-antlr4-parser v0.0.0-20240327125255-dbf53b6cbf06 h1:JLvn7D+wXjH9g4Jsjo+VqmzTUpl/LX7vfr6VOfSWTdM=
github.com/libsql/sqlite-antlr4-parser v0.0.0-20240327125255-dbf53b6cbf06/go.mod h1:FUkZ5OHjlGPjnM2UyGJz9TypXQFgYqw6AFNO1UiROTM=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 h1:aAcj0Da7eBAtrTp03QXWvm88pSyOt+UgdZw2BFZ+lEw=
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
nhooyr.io/websocket v1.8.10 h1:mv4p+MnGrLDcPlBoWsvPP7XCzTYMXP9F9eIGoKbgx7Q=
nhooyr.io/websocket v1.8.10/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
4 changes: 2 additions & 2 deletions libsql/internal/http/shared/statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"sort"

"github.com/antlr4-go/antlr/v4"
"github.com/libsql/sqlite-antlr4-parser/sqliteparser"
"github.com/libsql/sqlite-antlr4-parser/sqliteparserutils"
"github.com/tursodatabase/libsql-client-go/sqliteparser"
"github.com/tursodatabase/libsql-client-go/sqliteparserutils"
)

type ParamsInfo struct {
Expand Down
18 changes: 18 additions & 0 deletions sqliteparser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ANTLR SQLite Parser

This project is just a generation of a [ANTLR4](https://www.antlr.org/) go parser using [SQLite grammar](https://github.com/antlr/grammars-v4/tree/master/sql/sqlite) from [antlr/grammars-v4](https://github.com/antlr/grammars-v4/tree/master) project. Its only reason to exist is to avoid forcing everyone that want a simple parser to install JAVA.

You can find the grammar inside `./grammar` and the generated parser inside `./sqliteparser`

## Generate parser

### Requirements
- JAVA 11+ installed
- ANTLR4 compelte java binaries. Link [here](https://www.antlr.org/download.html)
- Put the binary inside `/usr/local/lib`

Important: The parser inside `./sqliteparser` was generated using OpenJDK 11 and ANTLR 4.12.0

### Steps
- Just run `./generate-parser.sh`

Loading

0 comments on commit 518abad

Please sign in to comment.