@@ -36,24 +36,24 @@ public class ExpressionEvaluator
3636 private const string numberRegexOrigPattern = @"^(?<sign>[+-])?([0-9][0-9_{1}]*[0-9]|\d)(?<hasdecimal>{0}?([0-9][0-9_]*[0-9]|\d)(e[+-]?([0-9][0-9_]*[0-9]|\d))?)?(?<type>ul|[fdulm])?" ;
3737 private string numberRegexPattern = null ;
3838
39- private static readonly Regex otherBasesNumberRegex = new Regex ( @"^(?<sign>[+-])?(?<value>0(?<type>x)([0-9a-f][0-9a-f_]*[0-9a-f]|[0-9a-f])|0(?<type>b)([01][01_]*[01]|[01]))" , RegexOptions . IgnoreCase ) ;
40- private static readonly Regex stringBeginningRegex = new Regex ( "^(?<interpolated>[$])?(?<escaped>[@])?[\" ]" ) ;
41- private static readonly Regex internalCharRegex = new Regex ( @"^['](\\[']|[^'])*[']" ) ;
42- private static readonly Regex indexingBeginningRegex = new Regex ( @"^[?]?\[" ) ;
39+ private static readonly Regex otherBasesNumberRegex = new Regex ( @"^(?<sign>[+-])?(?<value>0(?<type>x)([0-9a-f][0-9a-f_]*[0-9a-f]|[0-9a-f])|0(?<type>b)([01][01_]*[01]|[01]))" , RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
40+ private static readonly Regex stringBeginningRegex = new Regex ( "^(?<interpolated>[$])?(?<escaped>[@])?[\" ]" , RegexOptions . Compiled ) ;
41+ private static readonly Regex internalCharRegex = new Regex ( @"^['](\\[']|[^'])*[']" , RegexOptions . Compiled ) ;
42+ private static readonly Regex indexingBeginningRegex = new Regex ( @"^[?]?\[" , RegexOptions . Compiled ) ;
4343 private static readonly Regex assignationOrPostFixOperatorRegex = new Regex ( @"^\s*((?<assignmentPrefix>[+\-*/%&|^]|<<|>>)?=(?![=>])|(?<postfixOperator>([+][+]|--)(?![" + diactiticsKeywordsRegexPattern + @"0-9])))" ) ;
4444 private static readonly Regex genericsDecodeRegex = new Regex ( "(?<name>[^,<>]+)(?<isgeneric>[<](?>[^<>]+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?" , RegexOptions . Compiled ) ;
45- private static readonly Regex genericsEndOnlyOneTrim = new Regex ( @"\s+[>]\s+$" ) ;
46-
47- private static readonly Regex endOfStringWithDollar = new Regex ( "^([^\" {\\ \\ ]|\\ \\ [\\ \\ \" 0abfnrtv])*[\" {]" ) ;
48- private static readonly Regex endOfStringWithoutDollar = new Regex ( "^([^\" \\ \\ ]|\\ \\ [\\ \\ \" 0abfnrtv])*[\" ]" ) ;
49- private static readonly Regex endOfStringWithDollarWithAt = new Regex ( "^[^\" {]*[\" {]" ) ;
50- private static readonly Regex endOfStringWithoutDollarWithAt = new Regex ( "^[^\" ]*[\" ]" ) ;
51- private static readonly Regex endOfStringInterpolationRegex = new Regex ( "^('\" '|[^}\" ])*[}\" ]" ) ;
52- private static readonly Regex stringBeginningForEndBlockRegex = new Regex ( "[$]?[@]?[\" ]$" ) ;
53- private static readonly Regex lambdaExpressionRegex = new Regex ( $@ "^\s*(?<args>(\s*[(]\s*([{ diactiticsKeywordsRegexPattern } ][{ diactiticsKeywordsRegexPattern } 0-9]*\s*([,]\s*[{ diactiticsKeywordsRegexPattern } ][{ diactiticsKeywordsRegexPattern } 0-9]*\s*)*)?[)])|[{ diactiticsKeywordsRegexPattern } ][{ diactiticsKeywordsRegexPattern } 0-9]*)\s*=>(?<expression>.*)$", RegexOptions . Singleline ) ;
54- private static readonly Regex lambdaArgRegex = new Regex ( $@ "[{ diactiticsKeywordsRegexPattern } ][{ diactiticsKeywordsRegexPattern } 0-9]*") ;
55- private static readonly Regex initInNewBeginningRegex = new Regex ( @"^\s*{" ) ;
56- private static readonly Regex OtherDimentionArrayInNewBeginningRegex = new Regex ( @"^\s*\[" ) ;
45+ private static readonly Regex genericsEndOnlyOneTrim = new Regex ( @"\s+[>]\s+$" , RegexOptions . Compiled ) ;
46+
47+ private static readonly Regex endOfStringWithDollar = new Regex ( "^([^\" {\\ \\ ]|\\ \\ [\\ \\ \" 0abfnrtv])*[\" {]" , RegexOptions . Compiled ) ;
48+ private static readonly Regex endOfStringWithoutDollar = new Regex ( "^([^\" \\ \\ ]|\\ \\ [\\ \\ \" 0abfnrtv])*[\" ]" , RegexOptions . Compiled ) ;
49+ private static readonly Regex endOfStringWithDollarWithAt = new Regex ( "^[^\" {]*[\" {]" , RegexOptions . Compiled ) ;
50+ private static readonly Regex endOfStringWithoutDollarWithAt = new Regex ( "^[^\" ]*[\" ]" , RegexOptions . Compiled ) ;
51+ private static readonly Regex endOfStringInterpolationRegex = new Regex ( "^('\" '|[^}\" ])*[}\" ]" , RegexOptions . Compiled ) ;
52+ private static readonly Regex stringBeginningForEndBlockRegex = new Regex ( "[$]?[@]?[\" ]$" , RegexOptions . Compiled ) ;
53+ private static readonly Regex lambdaExpressionRegex = new Regex ( $@ "^\s*(?<args>(\s*[(]\s*([{ diactiticsKeywordsRegexPattern } ][{ diactiticsKeywordsRegexPattern } 0-9]*\s*([,]\s*[{ diactiticsKeywordsRegexPattern } ][{ diactiticsKeywordsRegexPattern } 0-9]*\s*)*)?[)])|[{ diactiticsKeywordsRegexPattern } ][{ diactiticsKeywordsRegexPattern } 0-9]*)\s*=>(?<expression>.*)$", RegexOptions . Singleline | RegexOptions . Compiled ) ;
54+ private static readonly Regex lambdaArgRegex = new Regex ( $@ "[{ diactiticsKeywordsRegexPattern } ][{ diactiticsKeywordsRegexPattern } 0-9]*", RegexOptions . Compiled ) ;
55+ private static readonly Regex initInNewBeginningRegex = new Regex ( @"^\s*{" , RegexOptions . Compiled ) ;
56+ private static readonly Regex OtherDimentionArrayInNewBeginningRegex = new Regex ( @"^\s*\[" , RegexOptions . Compiled ) ;
5757
5858 // Depending on OptionInlineNamespacesEvaluationActive. Initialized in constructor
5959 private string InstanceCreationWithNewKeywordRegexPattern { get { return $@ "^new\s+(?<name>[{ diactiticsKeywordsRegexPattern } ][{ diactiticsKeywordsRegexPattern } 0-9{ ( OptionInlineNamespacesEvaluationActive ? @"\." : string . Empty ) } ]*)\s*(?<isgeneric>[<](?>[^<>]+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?\s*((?<isfunction>[(])|(?<isArray>\[)|(?<isInit>[{{]))?"; } }
@@ -66,16 +66,16 @@ public class ExpressionEvaluator
6666 private const string lineComments = @"//[^\r\n]*" ;
6767 private const string stringsIgnore = @"""((\\[^\n]|[^""\n])*)""" ;
6868 private const string verbatimStringsIgnore = @"@(""[^""]*"")+" ;
69- private static readonly Regex removeCommentsRegex = new Regex ( $ "{ blockComments } |{ lineComments } |{ stringsIgnore } |{ verbatimStringsIgnore } ", RegexOptions . Singleline ) ;
70- private static readonly Regex newLineCharsRegex = new Regex ( @"\r\n|\r|\n" ) ;
69+ private static readonly Regex removeCommentsRegex = new Regex ( $ "{ blockComments } |{ lineComments } |{ stringsIgnore } |{ verbatimStringsIgnore } ", RegexOptions . Singleline | RegexOptions . Compiled ) ;
70+ private static readonly Regex newLineCharsRegex = new Regex ( @"\r\n|\r|\n" , RegexOptions . Compiled ) ;
7171
7272 // For script only
73- private static readonly Regex blockKeywordsBeginningRegex = new Regex ( @"^\s*(?<keyword>while|for|foreach|if|else\s+if|catch)\s*[(]" , RegexOptions . IgnoreCase ) ;
74- private static readonly Regex foreachParenthisEvaluationRegex = new Regex ( @"^\s*(?<variableName>[" + diactiticsKeywordsRegexPattern + @"][" + diactiticsKeywordsRegexPattern + @"0-9]*)\s+(?<in>in)\s+(?<collection>.*)" , RegexOptions . IgnoreCase ) ;
75- private static readonly Regex blockKeywordsWithoutParenthesesBeginningRegex = new Regex ( @"^\s*(?<keyword>else|do|try|finally)(?![" + diactiticsKeywordsRegexPattern + @"0-9])" , RegexOptions . IgnoreCase ) ;
76- private static readonly Regex blockBeginningRegex = new Regex ( @"^\s*[{]" ) ;
77- private static readonly Regex returnKeywordRegex = new Regex ( @"^return(\s+|\()" , RegexOptions . IgnoreCase | RegexOptions . Singleline ) ;
78- private static readonly Regex nextIsEndOfExpressionRegex = new Regex ( @"^\s*[;]" ) ;
73+ private static readonly Regex blockKeywordsBeginningRegex = new Regex ( @"^\s*(?<keyword>while|for|foreach|if|else\s+if|catch)\s*[(]" , RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
74+ private static readonly Regex foreachParenthisEvaluationRegex = new Regex ( @"^\s*(?<variableName>[" + diactiticsKeywordsRegexPattern + @"][" + diactiticsKeywordsRegexPattern + @"0-9]*)\s+(?<in>in)\s+(?<collection>.*)" , RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
75+ private static readonly Regex blockKeywordsWithoutParenthesesBeginningRegex = new Regex ( @"^\s*(?<keyword>else|do|try|finally)(?![" + diactiticsKeywordsRegexPattern + @"0-9])" , RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
76+ private static readonly Regex blockBeginningRegex = new Regex ( @"^\s*[{]" , RegexOptions . Compiled ) ;
77+ private static readonly Regex returnKeywordRegex = new Regex ( @"^return(\s+|\()" , RegexOptions . IgnoreCase | RegexOptions . Singleline | RegexOptions . Compiled ) ;
78+ private static readonly Regex nextIsEndOfExpressionRegex = new Regex ( @"^\s*[;]" , RegexOptions . Compiled ) ;
7979
8080 #endregion
8181
0 commit comments