@@ -2859,6 +2859,132 @@ End Type
28592859 AssertTree ( parseResult . Item1 , parseResult . Item2 , "//commentOrAnnotation" , matches => matches . Count == 1 ) ;
28602860 }
28612861
2862+ [ Category ( "Parser" ) ]
2863+ [ Test ]
2864+ public void MidStatement ( )
2865+ {
2866+ const string code = @"
2867+ Public Sub Test()
2868+ Dim TestString As String
2869+ TestString = ""The dog jumps""
2870+ Mid(TestString, 5, 3) = ""fox""
2871+ End Sub
2872+ " ;
2873+ var parseResult = Parse ( code ) ;
2874+ AssertTree ( parseResult . Item1 , parseResult . Item2 , "//midStatement" , matches => matches . Count == 1 ) ;
2875+ }
2876+
2877+ [ Category ( "Parser" ) ]
2878+ [ Test ]
2879+ public void MidDollarStatement ( )
2880+ {
2881+ const string code = @"
2882+ Public Sub Test()
2883+ Dim TestString As String
2884+ TestString = ""The dog jumps""
2885+ Mid$(TestString, 5, 3) = ""fox""
2886+ End Sub
2887+ " ;
2888+ var parseResult = Parse ( code ) ;
2889+ AssertTree ( parseResult . Item1 , parseResult . Item2 , "//midStatement" , matches => matches . Count == 1 ) ;
2890+ }
2891+
2892+ public void MidBStatement ( )
2893+ {
2894+ const string code = @"
2895+ Public Sub Test()
2896+ Dim TestString As String
2897+ TestString = ""The dog jumps""
2898+ MidB(TestString, 5, 3) = ""fox""
2899+ End Sub
2900+ " ;
2901+ var parseResult = Parse ( code ) ;
2902+ AssertTree ( parseResult . Item1 , parseResult . Item2 , "//midStatement" , matches => matches . Count == 1 ) ;
2903+ }
2904+
2905+ [ Category ( "Parser" ) ]
2906+ [ Test ]
2907+ public void MidBDollarStatement ( )
2908+ {
2909+ const string code = @"
2910+ Public Sub Test()
2911+ Dim TestString As String
2912+ TestString = ""The dog jumps""
2913+ MidB$(TestString, 5, 3) = ""fox""
2914+ End Sub
2915+ " ;
2916+ var parseResult = Parse ( code ) ;
2917+ AssertTree ( parseResult . Item1 , parseResult . Item2 , "//midStatement" , matches => matches . Count == 1 ) ;
2918+ }
2919+
2920+ [ Category ( "Parser" ) ]
2921+ [ Test ]
2922+ public void MidFunction ( )
2923+ {
2924+ const string code = @"
2925+ Public Sub Test()
2926+ Dim TestString As String
2927+ TestString = ""The dog jumps""
2928+ If Mid(TestString, 5, 3) = ""fox"" Then
2929+ MsgBox ""Found""
2930+ End If
2931+ End Sub
2932+ " ;
2933+ var parseResult = Parse ( code ) ;
2934+ AssertTree ( parseResult . Item1 , parseResult . Item2 , "//midStatement" , matches => matches . Count == 0 ) ;
2935+ }
2936+
2937+ [ Category ( "Parser" ) ]
2938+ [ Test ]
2939+ public void MidDollarFunction ( )
2940+ {
2941+ const string code = @"
2942+ Public Sub Test()
2943+ Dim TestString As String
2944+ TestString = ""The dog jumps""
2945+ If Mid$(TestString, 5, 3) = ""fox"" Then
2946+ MsgBox ""Found""
2947+ End If
2948+ End Sub
2949+ " ;
2950+ var parseResult = Parse ( code ) ;
2951+ AssertTree ( parseResult . Item1 , parseResult . Item2 , "//midStatement" , matches => matches . Count == 0 ) ;
2952+ }
2953+
2954+ [ Category ( "Parser" ) ]
2955+ [ Test ]
2956+ public void MidBFunction ( )
2957+ {
2958+ const string code = @"
2959+ Public Sub Test()
2960+ Dim TestString As String
2961+ TestString = ""The dog jumps""
2962+ If MidB(TestString, 5, 3) = ""fox"" Then
2963+ MsgBox ""Found""
2964+ End If
2965+ End Sub
2966+ " ;
2967+ var parseResult = Parse ( code ) ;
2968+ AssertTree ( parseResult . Item1 , parseResult . Item2 , "//midStatement" , matches => matches . Count == 0 ) ;
2969+ }
2970+
2971+ [ Category ( "Parser" ) ]
2972+ [ Test ]
2973+ public void MidBDollarFunction ( )
2974+ {
2975+ const string code = @"
2976+ Public Sub Test()
2977+ Dim TestString As String
2978+ TestString = ""The dog jumps""
2979+ If MidB$(TestString, 5, 3) = ""fox"" Then
2980+ MsgBox ""Found""
2981+ End If
2982+ End Sub
2983+ " ;
2984+ var parseResult = Parse ( code ) ;
2985+ AssertTree ( parseResult . Item1 , parseResult . Item2 , "//midStatement" , matches => matches . Count == 0 ) ;
2986+ }
2987+
28622988 private Tuple < VBAParser , ParserRuleContext > Parse ( string code , PredictionMode predictionMode = null )
28632989 {
28642990 var stream = new AntlrInputStream ( code ) ;
0 commit comments