Skip to content

Commit 26578ec

Browse files
committed
Split ast.go into one file per AST node
Refactor the ast package to have each AST node type in its own file: - node.go: Node interface - script.go, batch.go: Root types - statement.go, select_statement.go: Statement types - query_expression.go, query_specification.go: Query types - select_element.go, select_scalar_expression.go, select_star_expression.go - scalar_expression.go, column_reference_expression.go - integer_literal.go, string_literal.go, function_call.go - identifier.go, multi_part_identifier.go, identifier_or_value_expression.go - from_clause.go, table_reference.go, named_table_reference.go, qualified_join.go - schema_object_name.go - where_clause.go, boolean_expression.go, boolean_comparison_expression.go - boolean_binary_expression.go - group_by_clause.go, grouping_specification.go, expression_grouping_specification.go - having_clause.go, order_by_clause.go, expression_with_sort_order.go - optimizer_hint.go Also update metadata.json to use empty object instead of skip: false.
1 parent cd21e22 commit 26578ec

36 files changed

+313
-280
lines changed

ast/ast.go

Lines changed: 0 additions & 279 deletions
This file was deleted.

ast/batch.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package ast
2+
3+
// Batch represents a T-SQL batch of statements.
4+
type Batch struct {
5+
Statements []Statement `json:"Statements,omitempty"`
6+
}
7+
8+
func (*Batch) node() {}

ast/boolean_binary_expression.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package ast
2+
3+
// BooleanBinaryExpression represents a binary boolean expression (AND, OR).
4+
type BooleanBinaryExpression struct {
5+
BinaryExpressionType string `json:"BinaryExpressionType,omitempty"`
6+
FirstExpression BooleanExpression `json:"FirstExpression,omitempty"`
7+
SecondExpression BooleanExpression `json:"SecondExpression,omitempty"`
8+
}
9+
10+
func (*BooleanBinaryExpression) node() {}
11+
func (*BooleanBinaryExpression) booleanExpression() {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package ast
2+
3+
// BooleanComparisonExpression represents a comparison expression.
4+
type BooleanComparisonExpression struct {
5+
ComparisonType string `json:"ComparisonType,omitempty"`
6+
FirstExpression ScalarExpression `json:"FirstExpression,omitempty"`
7+
SecondExpression ScalarExpression `json:"SecondExpression,omitempty"`
8+
}
9+
10+
func (*BooleanComparisonExpression) node() {}
11+
func (*BooleanComparisonExpression) booleanExpression() {}

ast/boolean_expression.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package ast
2+
3+
// BooleanExpression is the interface for boolean expressions.
4+
type BooleanExpression interface {
5+
Node
6+
booleanExpression()
7+
}

ast/column_reference_expression.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package ast
2+
3+
// ColumnReferenceExpression represents a column reference.
4+
type ColumnReferenceExpression struct {
5+
ColumnType string `json:"ColumnType,omitempty"`
6+
MultiPartIdentifier *MultiPartIdentifier `json:"MultiPartIdentifier,omitempty"`
7+
}
8+
9+
func (*ColumnReferenceExpression) node() {}
10+
func (*ColumnReferenceExpression) scalarExpression() {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package ast
2+
3+
// ExpressionGroupingSpecification represents a grouping by expression.
4+
type ExpressionGroupingSpecification struct {
5+
Expression ScalarExpression `json:"Expression,omitempty"`
6+
DistributedAggregation bool `json:"DistributedAggregation,omitempty"`
7+
}
8+
9+
func (*ExpressionGroupingSpecification) node() {}
10+
func (*ExpressionGroupingSpecification) groupingSpecification() {}

ast/expression_with_sort_order.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package ast
2+
3+
// ExpressionWithSortOrder represents an expression with sort order.
4+
type ExpressionWithSortOrder struct {
5+
SortOrder string `json:"SortOrder,omitempty"`
6+
Expression ScalarExpression `json:"Expression,omitempty"`
7+
}
8+
9+
func (*ExpressionWithSortOrder) node() {}

ast/from_clause.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package ast
2+
3+
// FromClause represents a FROM clause.
4+
type FromClause struct {
5+
TableReferences []TableReference `json:"TableReferences,omitempty"`
6+
}
7+
8+
func (*FromClause) node() {}

ast/function_call.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package ast
2+
3+
// FunctionCall represents a function call.
4+
type FunctionCall struct {
5+
FunctionName *Identifier `json:"FunctionName,omitempty"`
6+
Parameters []ScalarExpression `json:"Parameters,omitempty"`
7+
UniqueRowFilter string `json:"UniqueRowFilter,omitempty"`
8+
WithArrayWrapper bool `json:"WithArrayWrapper,omitempty"`
9+
}
10+
11+
func (*FunctionCall) node() {}
12+
func (*FunctionCall) scalarExpression() {}

0 commit comments

Comments
 (0)