-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b709630
commit 0833a51
Showing
14 changed files
with
10,155 additions
and
10,077 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
module ydb-go-sdk/parser | ||
module github.com/ydb-platform/ydb-go-sdk/v3/parser | ||
|
||
go 1.23.4 | ||
go 1.22 | ||
|
||
toolchain go1.23.0 | ||
|
||
require ( | ||
github.com/antlr4-go/antlr/v4 v4.13.1 | ||
github.com/stretchr/testify v1.10.0 | ||
) | ||
|
||
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-20240506185415-9bf2ced13842 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ= | ||
github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw= | ||
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/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.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= | ||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= | ||
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM= | ||
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= | ||
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= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package parser | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/antlr4-go/antlr/v4" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/ydb-platform/ydb-go-sdk/v3/parser/yql" | ||
) | ||
|
||
type treeShapeListener struct { | ||
*yql.BaseYQLListener | ||
|
||
data []string | ||
} | ||
|
||
func (l *treeShapeListener) EnterEveryRule(ctx antlr.ParserRuleContext) { | ||
l.data = append(l.data, ctx.GetText()) | ||
} | ||
|
||
func TestParserYQL(t *testing.T) { | ||
input := antlr.NewInputStream(`SELECT 1`) | ||
lexer := yql.NewYQLLexer(input) | ||
stream := antlr.NewCommonTokenStream(lexer, 0) | ||
parser := yql.NewYQLParser(stream) | ||
parser.AddErrorListener(antlr.NewDiagnosticErrorListener(true)) | ||
stmt := parser.Select_stmt() | ||
listener := &treeShapeListener{} | ||
antlr.NewParseTreeWalker().Walk(listener, stmt) | ||
require.Equal(t, | ||
[]string{ | ||
"SELECT1", | ||
"SELECT1", | ||
"SELECT1", | ||
"SELECT1", | ||
"SELECT1", | ||
"", | ||
"1", | ||
"1", | ||
"1", | ||
"1", | ||
"1", | ||
"1", | ||
"1", | ||
"1", | ||
"1", | ||
"1", | ||
"1", | ||
"1", | ||
"1", | ||
"1", | ||
"1", | ||
"1", | ||
"", | ||
}, | ||
listener.data, | ||
) | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.