-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
walk
package to traverse an AST (#265)
* Add `walk` package to traverse an AST - Add `ast-gen-walk` - Remove `ColumnDefOptions` and `VectorIndexOption` because they are unused. * Move `Walk` functions to `ast` package * Fix format * Fix BinaryExpr.end * Do make gen * Add pos-end test into parser_test.go * Fix Join.end * Fix Selector.end * Fix AlterDatabase.end * Fix CreateTable.end * Fix AlterIndex.end * Fix end of ChangeStream * Fix TableConstraint.ConstraintPos * Make gen * go test --update * Fix interval notation * Update pos/end test * Add `Field` and `Index` to `Visitor` * Add `WalkMany` and other `Many` variants * Check and fix the field order * Update conventions * Update ast/ast.go Co-authored-by: apstndb <[email protected]> * Update Go version on CI * Update walk_internal.go * Fix PropertyGraphEdgeElementKeys pos * Insert an empty line --------- Co-authored-by: apstndb <[email protected]>
- Loading branch information
1 parent
d00c4b7
commit 6ab0f40
Showing
98 changed files
with
1,754 additions
and
412 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package ast | ||
|
||
type comparableNode = interface { | ||
comparable | ||
Node | ||
} | ||
|
||
func wrapNode[T comparableNode](node T) Node { | ||
var zero T | ||
if node == zero { | ||
return nil | ||
} | ||
return node | ||
} | ||
|
||
func wrapNodes[T Node](nodes []T) []Node { | ||
result := make([]Node, 0, len(nodes)) | ||
for _, node := range nodes { | ||
result = append(result, node) | ||
} | ||
return result | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.