15
15
using PT . PM . Common . Nodes . TypeMembers ;
16
16
using PT . PM . Common . Nodes . Tokens . Literals ;
17
17
using PT . PM . TSqlParseTreeUst ;
18
+ using Antlr4 . Runtime ;
18
19
19
20
namespace PT . PM . SqlParseTreeUst
20
21
{
@@ -67,7 +68,7 @@ public UstNode VisitDdl_clause([NotNull] TSqlParser.Ddl_clauseContext context)
67
68
/// <returns><see cref="Statement"/></returns>
68
69
public UstNode VisitCfl_statement ( [ NotNull ] TSqlParser . Cfl_statementContext context )
69
70
{
70
- return Visit ( context ) ;
71
+ return VisitChildren ( context ) ;
71
72
}
72
73
73
74
/// <returns><see cref="Statement"/></returns>
@@ -137,11 +138,11 @@ public UstNode VisitReturn_statement([NotNull] TSqlParser.Return_statementContex
137
138
public UstNode VisitThrow_statement ( [ NotNull ] TSqlParser . Throw_statementContext context )
138
139
{
139
140
var exprs = new List < Expression > ( ) ;
140
- if ( context . error_number != null )
141
+ if ( context . throw_error_number ( ) != null )
141
142
{
142
- exprs . Add ( ExtractLiteral ( context . error_number ) ) ;
143
- exprs . Add ( ExtractLiteral ( context . message ) ) ;
144
- exprs . Add ( ExtractLiteral ( context . state ) ) ;
143
+ exprs . Add ( ( Token ) VisitTerminal ( ( ITerminalNode ) context . throw_error_number ( ) . GetChild ( 0 ) ) ) ;
144
+ exprs . Add ( ( Token ) VisitTerminal ( ( ITerminalNode ) context . throw_message ( ) . GetChild ( 0 ) ) ) ;
145
+ exprs . Add ( ( Token ) VisitTerminal ( ( ITerminalNode ) context . throw_state ( ) . GetChild ( 0 ) ) ) ;
145
146
}
146
147
var result = new ThrowStatement (
147
148
new MultichildExpression ( exprs , FileNode ) ,
@@ -1165,7 +1166,26 @@ public UstNode VisitConstant_LOCAL_ID([NotNull] TSqlParser.Constant_LOCAL_IDCont
1165
1166
/// <returns><see cref="Expression"/></returns>
1166
1167
public UstNode VisitExpression ( [ NotNull ] TSqlParser . ExpressionContext context )
1167
1168
{
1168
- return Visit ( context ) ;
1169
+ if ( context . expression ( ) . Length == 2 )
1170
+ {
1171
+ var expr1 = ( Expression ) Visit ( context . expression ( 0 ) ) ;
1172
+ var expr2 = ( Expression ) Visit ( context . expression ( 1 ) ) ;
1173
+ var opText = RemoveSpaces ( context . GetChild ( 1 ) . GetText ( ) ) ;
1174
+ if ( opText == "=" )
1175
+ {
1176
+ opText = "==" ;
1177
+ }
1178
+ BinaryOperator op ;
1179
+ if ( ! BinaryOperatorLiteral . TextBinaryOperator . TryGetValue ( opText , out op ) )
1180
+ {
1181
+ op = BinaryOperator . Equal ;
1182
+ }
1183
+ var opLiteral = new BinaryOperatorLiteral ( op , context . GetTextSpan ( ) , FileNode ) ;
1184
+ var result = new BinaryOperatorExpression ( expr1 , opLiteral , expr2 , context . GetTextSpan ( ) , FileNode ) ;
1185
+ return result ;
1186
+ }
1187
+
1188
+ return VisitChildren ( context ) ;
1169
1189
}
1170
1190
1171
1191
/// <returns><see cref="IdToken"/></returns>
@@ -1191,21 +1211,6 @@ public UstNode VisitPrimitive_expression([NotNull] TSqlParser.Primitive_expressi
1191
1211
return result ;
1192
1212
}
1193
1213
1194
- /// <returns><see cref="InvocationExpression"/></returns>
1195
- public UstNode VisitFunction_call_expression ( [ NotNull ] TSqlParser . Function_call_expressionContext context )
1196
- {
1197
- if ( context . function_call ( ) != null )
1198
- {
1199
- return Visit ( context . function_call ( ) ) ;
1200
- }
1201
- else
1202
- {
1203
- return new InvocationExpression (
1204
- new IdToken ( "Collate" , context . COLLATE ( ) . GetTextSpan ( ) , FileNode ) ,
1205
- new ArgsNode ( ( IdToken ) Visit ( context . id ( ) ) ) , context . GetTextSpan ( ) , FileNode ) ;
1206
- }
1207
- }
1208
-
1209
1214
/// <returns><see cref="WrapperExpression"/></returns>
1210
1215
public UstNode VisitCase_expression ( [ NotNull ] TSqlParser . Case_expressionContext context )
1211
1216
{
@@ -1226,24 +1231,12 @@ public UstNode VisitCase_expression([NotNull] TSqlParser.Case_expressionContext
1226
1231
return new WrapperExpression ( result ) ;
1227
1232
}
1228
1233
1229
- /// <returns><see cref="Expression"/></returns>
1230
- public UstNode VisitColumn_ref_expression ( [ NotNull ] TSqlParser . Column_ref_expressionContext context )
1231
- {
1232
- return Visit ( context . full_column_name ( ) ) ;
1233
- }
1234
-
1235
1234
/// <returns><see cref="Expression"/></returns>
1236
1235
public UstNode VisitBracket_expression ( [ NotNull ] TSqlParser . Bracket_expressionContext context )
1237
1236
{
1238
1237
return Visit ( context . expression ( ) ) ;
1239
1238
}
1240
1239
1241
- /// <returns><see cref="Expression"/></returns>
1242
- public UstNode VisitSubquery_expression ( [ NotNull ] TSqlParser . Subquery_expressionContext context )
1243
- {
1244
- return Visit ( context . subquery ( ) ) ;
1245
- }
1246
-
1247
1240
/// <returns><see cref="UnaryOperatorExpression"/></returns>
1248
1241
public UstNode VisitUnary_operator_expression ( [ NotNull ] TSqlParser . Unary_operator_expressionContext context )
1249
1242
{
@@ -1254,28 +1247,6 @@ public UstNode VisitUnary_operator_expression([NotNull] TSqlParser.Unary_operato
1254
1247
return result ;
1255
1248
}
1256
1249
1257
- /// <returns><see cref="BinaryOperatorExpression"/></returns>
1258
- public UstNode VisitBinary_operator_expression ( [ NotNull ] TSqlParser . Binary_operator_expressionContext context )
1259
- {
1260
- var expr1 = ( Expression ) Visit ( context . expression ( 0 ) ) ;
1261
- var expr2 = ( Expression ) Visit ( context . expression ( 1 ) ) ;
1262
- var opText = RemoveSpaces ( context . GetChild ( 1 ) . GetText ( ) ) ;
1263
- if ( opText == "=" )
1264
- {
1265
- opText = "==" ;
1266
- }
1267
- BinaryOperator op = BinaryOperatorLiteral . TextBinaryOperator [ opText ] ;
1268
- var opLiteral = new BinaryOperatorLiteral ( op , context . GetTextSpan ( ) , FileNode ) ;
1269
- var result = new BinaryOperatorExpression ( expr1 , opLiteral , expr2 , context . GetTextSpan ( ) , FileNode ) ;
1270
- return result ;
1271
- }
1272
-
1273
- /// <returns><see cref="InvocationExpression"/></returns>
1274
- public UstNode VisitOver_clause_expression ( [ NotNull ] TSqlParser . Over_clause_expressionContext context )
1275
- {
1276
- return Visit ( context . over_clause ( ) ) ;
1277
- }
1278
-
1279
1250
/// <returns><see cref="Expression"/></returns>
1280
1251
public UstNode VisitConstant_expression ( [ NotNull ] TSqlParser . Constant_expressionContext context )
1281
1252
{
@@ -2446,11 +2417,6 @@ public UstNode VisitTop_count([NotNull] TSqlParser.Top_countContext context)
2446
2417
2447
2418
#endregion
2448
2419
2449
- public UstNode VisitAsssignment_operator_expression ( [ NotNull ] TSqlParser . Asssignment_operator_expressionContext context )
2450
- {
2451
- return VisitChildren ( context ) ;
2452
- }
2453
-
2454
2420
public UstNode VisitCreate_queue ( [ NotNull ] TSqlParser . Create_queueContext context )
2455
2421
{
2456
2422
return VisitChildren ( context ) ;
@@ -2806,5 +2772,30 @@ public UstNode VisitSend_conversation([NotNull] TSqlParser.Send_conversationCont
2806
2772
{
2807
2773
return VisitChildren ( context ) ;
2808
2774
}
2775
+
2776
+ public UstNode VisitThrow_error_number ( [ NotNull ] TSqlParser . Throw_error_numberContext context )
2777
+ {
2778
+ return VisitChildren ( context ) ;
2779
+ }
2780
+
2781
+ public UstNode VisitThrow_message ( [ NotNull ] TSqlParser . Throw_messageContext context )
2782
+ {
2783
+ return VisitChildren ( context ) ;
2784
+ }
2785
+
2786
+ public UstNode VisitThrow_state ( [ NotNull ] TSqlParser . Throw_stateContext context )
2787
+ {
2788
+ return VisitChildren ( context ) ;
2789
+ }
2790
+
2791
+ public UstNode VisitDrop_relational_or_xml_or_spatial_index ( [ NotNull ] TSqlParser . Drop_relational_or_xml_or_spatial_indexContext context )
2792
+ {
2793
+ return VisitChildren ( context ) ;
2794
+ }
2795
+
2796
+ public UstNode VisitDrop_backward_compatible_index ( [ NotNull ] TSqlParser . Drop_backward_compatible_indexContext context )
2797
+ {
2798
+ return VisitChildren ( context ) ;
2799
+ }
2809
2800
}
2810
2801
}
0 commit comments