Skip to content

Commit 136ea2b

Browse files
authored
Add semicolon skipping in trigger/try-catch statement bodies (#52)
1 parent 9c21ac5 commit 136ea2b

90 files changed

Lines changed: 4754 additions & 400 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ast/alter_database_set_statement.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ func (l *LiteralDatabaseOption) createDatabaseOption() {}
8787

8888
// AlterDatabaseAddFileStatement represents ALTER DATABASE ... ADD FILE statement
8989
type AlterDatabaseAddFileStatement struct {
90-
DatabaseName *Identifier
90+
DatabaseName *Identifier
91+
FileDeclarations []*FileDeclaration
92+
FileGroup *Identifier
93+
IsLog bool
94+
UseCurrent bool
9195
}
9296

9397
func (a *AlterDatabaseAddFileStatement) node() {}

ast/alter_function_statement.go

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ type AlterFunctionStatement struct {
55
Name *SchemaObjectName
66
Parameters []*ProcedureParameter
77
ReturnType FunctionReturnType
8-
Options []*FunctionOption
8+
Options []FunctionOptionBase
99
StatementList *StatementList
1010
}
1111

@@ -17,7 +17,7 @@ type CreateFunctionStatement struct {
1717
Name *SchemaObjectName
1818
Parameters []*ProcedureParameter
1919
ReturnType FunctionReturnType
20-
Options []*FunctionOption
20+
Options []FunctionOptionBase
2121
StatementList *StatementList
2222
}
2323

@@ -50,8 +50,37 @@ type SelectFunctionReturnType struct {
5050

5151
func (r *SelectFunctionReturnType) functionReturnTypeNode() {}
5252

53-
// FunctionOption represents a function option
53+
// FunctionOptionBase is an interface for function options
54+
type FunctionOptionBase interface {
55+
Node
56+
functionOption()
57+
}
58+
59+
// FunctionOption represents a function option (like ENCRYPTION, SCHEMABINDING)
5460
type FunctionOption struct {
55-
OptionKind string
56-
OptionState string
61+
OptionKind string
5762
}
63+
64+
func (o *FunctionOption) node() {}
65+
func (o *FunctionOption) functionOption() {}
66+
67+
// InlineFunctionOption represents an INLINE function option
68+
type InlineFunctionOption struct {
69+
OptionKind string // "Inline"
70+
OptionState string // "On", "Off"
71+
}
72+
73+
func (o *InlineFunctionOption) node() {}
74+
func (o *InlineFunctionOption) functionOption() {}
75+
76+
// CreateOrAlterFunctionStatement represents a CREATE OR ALTER FUNCTION statement
77+
type CreateOrAlterFunctionStatement struct {
78+
Name *SchemaObjectName
79+
Parameters []*ProcedureParameter
80+
ReturnType FunctionReturnType
81+
Options []FunctionOptionBase
82+
StatementList *StatementList
83+
}
84+
85+
func (s *CreateOrAlterFunctionStatement) statement() {}
86+
func (s *CreateOrAlterFunctionStatement) node() {}

ast/alter_simple_statements.go

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ package ast
22

33
// AlterRouteStatement represents an ALTER ROUTE statement.
44
type AlterRouteStatement struct {
5-
Name *Identifier `json:"Name,omitempty"`
5+
Name *Identifier `json:"Name,omitempty"`
6+
RouteOptions []*RouteOption `json:"RouteOptions,omitempty"`
67
}
78

89
func (s *AlterRouteStatement) node() {}
@@ -18,15 +19,65 @@ func (s *AlterAssemblyStatement) statement() {}
1819

1920
// AlterEndpointStatement represents an ALTER ENDPOINT statement.
2021
type AlterEndpointStatement struct {
21-
Name *Identifier `json:"Name,omitempty"`
22+
Name *Identifier `json:"Name,omitempty"`
23+
State string `json:"State,omitempty"` // Started, Disabled, NotSpecified
24+
Affinity *EndpointAffinity `json:"Affinity,omitempty"`
25+
Protocol string `json:"Protocol,omitempty"` // None, Tcp, Http
26+
ProtocolOptions []EndpointProtocolOption `json:"ProtocolOptions,omitempty"`
27+
EndpointType string `json:"EndpointType,omitempty"` // NotSpecified, Soap, ServiceBroker, etc.
28+
PayloadOptions []PayloadOption `json:"PayloadOptions,omitempty"`
2229
}
2330

2431
func (s *AlterEndpointStatement) node() {}
2532
func (s *AlterEndpointStatement) statement() {}
2633

34+
// EndpointAffinity represents the affinity setting for an endpoint.
35+
type EndpointAffinity struct {
36+
Kind string `json:"Kind,omitempty"` // None, Admin, Integer
37+
Value *IntegerLiteral `json:"Value,omitempty"`
38+
}
39+
40+
func (e *EndpointAffinity) node() {}
41+
42+
// EndpointProtocolOption is an interface for endpoint protocol options.
43+
type EndpointProtocolOption interface {
44+
Node
45+
endpointProtocolOption()
46+
}
47+
48+
// LiteralEndpointProtocolOption represents a literal endpoint protocol option.
49+
type LiteralEndpointProtocolOption struct {
50+
Value ScalarExpression `json:"Value,omitempty"`
51+
Kind string `json:"Kind,omitempty"` // TcpListenerPort, HttpListenerPort, etc.
52+
}
53+
54+
func (l *LiteralEndpointProtocolOption) node() {}
55+
func (l *LiteralEndpointProtocolOption) endpointProtocolOption() {}
56+
57+
// PayloadOption is an interface for endpoint payload options.
58+
type PayloadOption interface {
59+
Node
60+
payloadOption()
61+
}
62+
63+
// SoapMethod represents a SOAP web method option.
64+
type SoapMethod struct {
65+
Alias *StringLiteral `json:"Alias,omitempty"`
66+
Action string `json:"Action,omitempty"` // Add, Alter, Drop
67+
Name *StringLiteral `json:"Name,omitempty"`
68+
Format string `json:"Format,omitempty"` // NotSpecified, AllResults, RowsetsOnly, None
69+
Schema string `json:"Schema,omitempty"` // NotSpecified, Default, None, Standard
70+
Kind string `json:"Kind,omitempty"` // None, WebMethod
71+
}
72+
73+
func (s *SoapMethod) node() {}
74+
func (s *SoapMethod) payloadOption() {}
75+
2776
// AlterServiceStatement represents an ALTER SERVICE statement.
2877
type AlterServiceStatement struct {
29-
Name *Identifier `json:"Name,omitempty"`
78+
Name *Identifier `json:"Name,omitempty"`
79+
QueueName *SchemaObjectName `json:"QueueName,omitempty"`
80+
ServiceContracts []*ServiceContract `json:"ServiceContracts,omitempty"`
3081
}
3182

3283
func (s *AlterServiceStatement) node() {}

ast/alter_trigger_statement.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ func (o *TriggerOption) triggerOption() {}
4343

4444
// ExecuteAsClause represents an EXECUTE AS clause
4545
type ExecuteAsClause struct {
46-
ExecuteAsOption string // Caller, Self, Owner, or specific user
47-
Principal ScalarExpression
46+
ExecuteAsOption string // Caller, Self, Owner, String
47+
Literal *StringLiteral // Used when ExecuteAsOption is "String"
4848
}
4949

50+
func (e *ExecuteAsClause) node() {}
51+
5052
// ExecuteAsTriggerOption represents an EXECUTE AS trigger option
5153
type ExecuteAsTriggerOption struct {
5254
OptionKind string // "ExecuteAsClause"

ast/alter_user_statement.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package ast
22

33
// AlterUserStatement represents an ALTER USER statement.
44
type AlterUserStatement struct {
5-
Name *Identifier `json:"Name,omitempty"`
6-
Options []UserOption `json:"Options,omitempty"`
5+
Name *Identifier `json:"Name,omitempty"`
6+
UserOptions []UserOption `json:"UserOptions,omitempty"`
77
}
88

99
func (s *AlterUserStatement) node() {}

ast/column_master_key_statement.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package ast
2+
3+
// CreateColumnMasterKeyStatement represents a CREATE COLUMN MASTER KEY statement.
4+
type CreateColumnMasterKeyStatement struct {
5+
Name *Identifier
6+
Parameters []ColumnMasterKeyParameter
7+
}
8+
9+
func (c *CreateColumnMasterKeyStatement) node() {}
10+
func (c *CreateColumnMasterKeyStatement) statement() {}
11+
12+
// ColumnMasterKeyParameter is an interface for column master key parameters.
13+
type ColumnMasterKeyParameter interface {
14+
Node
15+
columnMasterKeyParameter()
16+
}
17+
18+
// ColumnMasterKeyStoreProviderNameParameter represents KEY_STORE_PROVIDER_NAME parameter.
19+
type ColumnMasterKeyStoreProviderNameParameter struct {
20+
Name ScalarExpression
21+
ParameterKind string
22+
}
23+
24+
func (c *ColumnMasterKeyStoreProviderNameParameter) node() {}
25+
func (c *ColumnMasterKeyStoreProviderNameParameter) columnMasterKeyParameter() {}
26+
27+
// ColumnMasterKeyPathParameter represents KEY_PATH parameter.
28+
type ColumnMasterKeyPathParameter struct {
29+
Path ScalarExpression
30+
ParameterKind string
31+
}
32+
33+
func (c *ColumnMasterKeyPathParameter) node() {}
34+
func (c *ColumnMasterKeyPathParameter) columnMasterKeyParameter() {}
35+
36+
// ColumnMasterKeyEnclaveComputationsParameter represents ENCLAVE_COMPUTATIONS parameter.
37+
type ColumnMasterKeyEnclaveComputationsParameter struct {
38+
Signature ScalarExpression
39+
ParameterKind string
40+
}
41+
42+
func (c *ColumnMasterKeyEnclaveComputationsParameter) node() {}
43+
func (c *ColumnMasterKeyEnclaveComputationsParameter) columnMasterKeyParameter() {}
44+
45+
// DropColumnMasterKeyStatement represents a DROP COLUMN MASTER KEY statement.
46+
type DropColumnMasterKeyStatement struct {
47+
Name *Identifier
48+
}
49+
50+
func (d *DropColumnMasterKeyStatement) node() {}
51+
func (d *DropColumnMasterKeyStatement) statement() {}

ast/create_procedure_statement.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ type CreateProcedureStatement struct {
66
Parameters []*ProcedureParameter
77
StatementList *StatementList
88
IsForReplication bool
9+
Options []ProcedureOptionBase
10+
MethodSpecifier *MethodSpecifier
911
}
1012

1113
func (c *CreateProcedureStatement) node() {}
@@ -22,3 +24,26 @@ type ProcedureParameter struct {
2224
}
2325

2426
func (p *ProcedureParameter) node() {}
27+
28+
// ProcedureOptionBase is the interface for procedure options.
29+
type ProcedureOptionBase interface {
30+
Node
31+
procedureOption()
32+
}
33+
34+
// ProcedureOption represents a simple procedure option like RECOMPILE or ENCRYPTION.
35+
type ProcedureOption struct {
36+
OptionKind string // Recompile, Encryption
37+
}
38+
39+
func (p *ProcedureOption) node() {}
40+
func (p *ProcedureOption) procedureOption() {}
41+
42+
// ExecuteAsProcedureOption represents an EXECUTE AS option for a procedure.
43+
type ExecuteAsProcedureOption struct {
44+
ExecuteAs *ExecuteAsClause
45+
OptionKind string // ExecuteAs
46+
}
47+
48+
func (e *ExecuteAsProcedureOption) node() {}
49+
func (e *ExecuteAsProcedureOption) procedureOption() {}

ast/create_simple_statements.go

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,25 @@ package ast
22

33
// CreateDatabaseStatement represents a CREATE DATABASE statement.
44
type CreateDatabaseStatement struct {
5-
DatabaseName *Identifier `json:"DatabaseName,omitempty"`
6-
Options []CreateDatabaseOption `json:"Options,omitempty"`
7-
AttachMode string `json:"AttachMode,omitempty"` // "None", "Attach", "AttachRebuildLog"
8-
CopyOf *MultiPartIdentifier `json:"CopyOf,omitempty"` // For AS COPY OF syntax
5+
DatabaseName *Identifier `json:"DatabaseName,omitempty"`
6+
Options []CreateDatabaseOption `json:"Options,omitempty"`
7+
AttachMode string `json:"AttachMode,omitempty"` // "None", "Attach", "AttachRebuildLog"
8+
CopyOf *MultiPartIdentifier `json:"CopyOf,omitempty"` // For AS COPY OF syntax
9+
FileGroups []*FileGroupDefinition `json:"FileGroups,omitempty"`
10+
LogOn []*FileDeclaration `json:"LogOn,omitempty"`
11+
Collation *Identifier `json:"Collation,omitempty"`
12+
Containment *ContainmentDatabaseOption `json:"Containment,omitempty"`
913
}
1014

15+
// ContainmentDatabaseOption represents CONTAINMENT = NONE/PARTIAL
16+
type ContainmentDatabaseOption struct {
17+
Value string // "None" or "Partial"
18+
OptionKind string // Always "Containment"
19+
}
20+
21+
func (c *ContainmentDatabaseOption) node() {}
22+
func (c *ContainmentDatabaseOption) createDatabaseOption() {}
23+
1124
func (s *CreateDatabaseStatement) node() {}
1225
func (s *CreateDatabaseStatement) statement() {}
1326

@@ -19,9 +32,20 @@ type CreateLoginStatement struct {
1932
func (s *CreateLoginStatement) node() {}
2033
func (s *CreateLoginStatement) statement() {}
2134

35+
// ServiceContract represents a contract in CREATE/ALTER SERVICE.
36+
type ServiceContract struct {
37+
Name *Identifier `json:"Name,omitempty"`
38+
Action string `json:"Action,omitempty"` // "Add", "Drop", "None"
39+
}
40+
41+
func (s *ServiceContract) node() {}
42+
2243
// CreateServiceStatement represents a CREATE SERVICE statement.
2344
type CreateServiceStatement struct {
24-
Name *Identifier `json:"Name,omitempty"`
45+
Owner *Identifier `json:"Owner,omitempty"`
46+
Name *Identifier `json:"Name,omitempty"`
47+
QueueName *SchemaObjectName `json:"QueueName,omitempty"`
48+
ServiceContracts []*ServiceContract `json:"ServiceContracts,omitempty"`
2549
}
2650

2751
func (s *CreateServiceStatement) node() {}
@@ -61,12 +85,22 @@ func (s *CreateQueueStatement) statement() {}
6185

6286
// CreateRouteStatement represents a CREATE ROUTE statement.
6387
type CreateRouteStatement struct {
64-
Name *Identifier `json:"Name,omitempty"`
88+
Name *Identifier `json:"Name,omitempty"`
89+
Owner *Identifier `json:"Owner,omitempty"`
90+
RouteOptions []*RouteOption `json:"RouteOptions,omitempty"`
6591
}
6692

6793
func (s *CreateRouteStatement) node() {}
6894
func (s *CreateRouteStatement) statement() {}
6995

96+
// RouteOption represents an option in CREATE/ALTER ROUTE statement.
97+
type RouteOption struct {
98+
OptionKind string `json:"OptionKind,omitempty"`
99+
Literal ScalarExpression `json:"Literal,omitempty"`
100+
}
101+
102+
func (r *RouteOption) node() {}
103+
70104
// CreateEndpointStatement represents a CREATE ENDPOINT statement.
71105
type CreateEndpointStatement struct {
72106
Name *Identifier `json:"Name,omitempty"`
@@ -150,14 +184,36 @@ type CreationDispositionKeyOption struct {
150184
func (c *CreationDispositionKeyOption) node() {}
151185
func (c *CreationDispositionKeyOption) keyOption() {}
152186

187+
// CryptoMechanism represents an encryption mechanism (CERTIFICATE, KEY, PASSWORD, etc.)
188+
type CryptoMechanism struct {
189+
CryptoMechanismType string `json:"CryptoMechanismType,omitempty"` // "Certificate", "SymmetricKey", "AsymmetricKey", "Password"
190+
Identifier *Identifier `json:"Identifier,omitempty"`
191+
PasswordOrSignature ScalarExpression `json:"PasswordOrSignature,omitempty"`
192+
}
193+
194+
func (c *CryptoMechanism) node() {}
195+
153196
// CreateSymmetricKeyStatement represents a CREATE SYMMETRIC KEY statement.
154197
type CreateSymmetricKeyStatement struct {
155-
Name *Identifier `json:"Name,omitempty"`
198+
KeyOptions []KeyOption `json:"KeyOptions,omitempty"`
199+
Provider *Identifier `json:"Provider,omitempty"`
200+
Name *Identifier `json:"Name,omitempty"`
201+
EncryptingMechanisms []*CryptoMechanism `json:"EncryptingMechanisms,omitempty"`
156202
}
157203

158204
func (s *CreateSymmetricKeyStatement) node() {}
159205
func (s *CreateSymmetricKeyStatement) statement() {}
160206

207+
// DropSymmetricKeyStatement represents a DROP SYMMETRIC KEY statement.
208+
type DropSymmetricKeyStatement struct {
209+
RemoveProviderKey bool `json:"RemoveProviderKey,omitempty"`
210+
Name *Identifier `json:"Name,omitempty"`
211+
IsIfExists bool `json:"IsIfExists"`
212+
}
213+
214+
func (s *DropSymmetricKeyStatement) node() {}
215+
func (s *DropSymmetricKeyStatement) statement() {}
216+
161217
// CreateMessageTypeStatement represents a CREATE MESSAGE TYPE statement.
162218
type CreateMessageTypeStatement struct {
163219
Name *Identifier `json:"Name,omitempty"`
@@ -171,7 +227,9 @@ func (s *CreateMessageTypeStatement) statement() {}
171227

172228
// CreateRemoteServiceBindingStatement represents a CREATE REMOTE SERVICE BINDING statement.
173229
type CreateRemoteServiceBindingStatement struct {
174-
Name *Identifier `json:"Name,omitempty"`
230+
Name *Identifier `json:"Name,omitempty"`
231+
Service ScalarExpression `json:"Service,omitempty"`
232+
Options []RemoteServiceBindingOption `json:"Options,omitempty"`
175233
}
176234

177235
func (s *CreateRemoteServiceBindingStatement) node() {}

0 commit comments

Comments
 (0)