Skip to content

Commit f6c50d4

Browse files
h3n4lclaude
andauthored
refactor: replace ANTLR parser with omni recursive descent parser (#26)
* refactor: replace ANTLR parser with omni recursive descent parser Replace the ANTLR-based parser (bytebase/parser/mongodb) with the hand-written recursive descent parser (bytebase/omni/mongo). This eliminates the ANTLR runtime dependency and simplifies the translator from ~3400 lines to ~1600 lines by replacing the visitor pattern with direct AST type switches. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ci: bump Go to 1.25 and golangci-lint to v2.11.4 The omni dependency requires Go 1.25.5, which is incompatible with golangci-lint v1.64.8 (built with Go 1.24). Upgrade both the Go version and linter in CI workflows. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: address PR review comments - Use errors.As for robust ParseError unwrapping in translator.go - Validate that Timestamp document contains both 't' and 'i' fields with integer values in bson_helpers.go - Copy bool value before taking address in extractRenameCollectionArgs to avoid retaining AST node Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: bump omni to v0.0.0-20260402100940-de2123e1bfb3 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: go mod tidy Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 02084c9 commit f6c50d4

File tree

11 files changed

+1231
-2644
lines changed

11 files changed

+1231
-2644
lines changed

.github/workflows/lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ jobs:
2020
- uses: actions/checkout@v4
2121
- uses: actions/setup-go@v5
2222
with:
23-
go-version: '1.24'
23+
go-version: '1.25'
2424
- name: golangci-lint
25-
uses: golangci/golangci-lint-action@v6
25+
uses: golangci/golangci-lint-action@v7
2626
with:
27-
version: v1.64.8
27+
version: v2.11.4
2828
args: --verbose --timeout 5m --allow-parallel-runners

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- uses: actions/checkout@v4
2121
- uses: actions/setup-go@v5
2222
with:
23-
go-version: '1.24'
23+
go-version: '1.25'
2424
- name: Verify go.mod is tidy
2525
run: |
2626
go mod tidy

go.mod

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,74 @@
11
module github.com/bytebase/gomongo
22

3-
go 1.24.5
3+
go 1.25.5
44

55
require (
6-
github.com/antlr4-go/antlr/v4 v4.13.1
7-
github.com/bytebase/parser v0.0.0-20260324035613-3b4d6e704551
6+
github.com/bytebase/omni v0.0.0-20260402100940-de2123e1bfb3
87
github.com/google/uuid v1.6.0
98
github.com/stretchr/testify v1.11.1
10-
github.com/testcontainers/testcontainers-go v0.40.0
9+
github.com/testcontainers/testcontainers-go v0.41.0
1110
github.com/testcontainers/testcontainers-go/modules/mongodb v0.40.0
1211
go.mongodb.org/mongo-driver/v2 v2.4.1
1312
)
1413

1514
require (
1615
dario.cat/mergo v1.0.2 // indirect
17-
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
16+
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
1817
github.com/Microsoft/go-winio v0.6.2 // indirect
1918
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
19+
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
20+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
2021
github.com/containerd/errdefs v1.0.0 // indirect
2122
github.com/containerd/errdefs/pkg v0.3.0 // indirect
2223
github.com/containerd/log v0.1.0 // indirect
2324
github.com/containerd/platforms v0.2.1 // indirect
2425
github.com/cpuguy83/dockercfg v0.3.2 // indirect
2526
github.com/davecgh/go-spew v1.1.1 // indirect
2627
github.com/distribution/reference v0.6.0 // indirect
27-
github.com/docker/docker v28.5.1+incompatible // indirect
28+
github.com/docker/docker v28.5.2+incompatible // indirect
2829
github.com/docker/go-connections v0.6.0 // indirect
2930
github.com/docker/go-units v0.5.0 // indirect
30-
github.com/ebitengine/purego v0.8.4 // indirect
31+
github.com/ebitengine/purego v0.10.0 // indirect
3132
github.com/felixge/httpsnoop v1.0.4 // indirect
3233
github.com/go-logr/logr v1.4.3 // indirect
3334
github.com/go-logr/stdr v1.2.2 // indirect
3435
github.com/go-ole/go-ole v1.2.6 // indirect
3536
github.com/golang/snappy v1.0.0 // indirect
36-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.4 // indirect
37-
github.com/klauspost/compress v1.18.0 // indirect
37+
github.com/klauspost/compress v1.18.2 // indirect
3838
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
3939
github.com/magiconair/properties v1.8.10 // indirect
4040
github.com/moby/docker-image-spec v1.3.1 // indirect
41-
github.com/moby/go-archive v0.1.0 // indirect
41+
github.com/moby/go-archive v0.2.0 // indirect
4242
github.com/moby/patternmatcher v0.6.0 // indirect
4343
github.com/moby/sys/sequential v0.6.0 // indirect
4444
github.com/moby/sys/user v0.4.0 // indirect
4545
github.com/moby/sys/userns v0.1.0 // indirect
46-
github.com/moby/term v0.5.0 // indirect
46+
github.com/moby/term v0.5.2 // indirect
4747
github.com/morikuni/aec v1.0.0 // indirect
4848
github.com/opencontainers/go-digest v1.0.0 // indirect
4949
github.com/opencontainers/image-spec v1.1.1 // indirect
5050
github.com/pkg/errors v0.9.1 // indirect
5151
github.com/pmezard/go-difflib v1.0.0 // indirect
52-
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
53-
github.com/shirou/gopsutil/v4 v4.25.6 // indirect
52+
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
53+
github.com/shirou/gopsutil/v4 v4.26.2 // indirect
5454
github.com/sirupsen/logrus v1.9.3 // indirect
55-
github.com/tklauser/go-sysconf v0.3.12 // indirect
56-
github.com/tklauser/numcpus v0.6.1 // indirect
55+
github.com/tklauser/go-sysconf v0.3.16 // indirect
56+
github.com/tklauser/numcpus v0.11.0 // indirect
5757
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
5858
github.com/xdg-go/scram v1.1.2 // indirect
5959
github.com/xdg-go/stringprep v1.0.4 // indirect
6060
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
6161
github.com/yusufpapurcu/wmi v1.2.4 // indirect
6262
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
6363
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
64-
go.opentelemetry.io/otel v1.38.0 // indirect
65-
go.opentelemetry.io/otel/metric v1.38.0 // indirect
66-
go.opentelemetry.io/otel/sdk v1.38.0 // indirect
67-
go.opentelemetry.io/otel/trace v1.38.0 // indirect
68-
golang.org/x/crypto v0.43.0 // indirect
69-
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
64+
go.opentelemetry.io/otel v1.41.0 // indirect
65+
go.opentelemetry.io/otel/metric v1.41.0 // indirect
66+
go.opentelemetry.io/otel/trace v1.41.0 // indirect
67+
golang.org/x/crypto v0.48.0 // indirect
7068
golang.org/x/sync v0.19.0 // indirect
71-
golang.org/x/sys v0.38.0 // indirect
72-
golang.org/x/text v0.32.0 // indirect
73-
google.golang.org/grpc v1.78.0 // indirect
74-
google.golang.org/protobuf v1.36.11 // indirect
69+
golang.org/x/sys v0.41.0 // indirect
70+
golang.org/x/text v0.34.0 // indirect
71+
google.golang.org/genproto/googleapis/api v0.0.0-20260209200024-4cfbd4190f57 // indirect
72+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260209200024-4cfbd4190f57 // indirect
7573
gopkg.in/yaml.v3 v3.0.1 // indirect
7674
)
77-
78-
replace github.com/antlr4-go/antlr/v4 => github.com/bytebase/antlr/v4 v4.0.0-20240827034948-8c385f108920

0 commit comments

Comments
 (0)