@@ -31,7 +31,7 @@ public class ExpressionEvaluator
31
31
private const string diactitics = "áàâãåǎăāąæéèêëěēĕėęěìíîïīĭįijóôõöōŏőøðœùúûüǔũūŭůűųýþÿŷıćĉċčçďđĝğġģĥħĵķĺļľŀłńņňŋñŕŗřśŝşšţťŧŵźżžÁÀÂÃÅǍĂĀĄÆÉÈÊËĚĒĔĖĘĚÌÍÎÏĪĬĮIJÓÔÕÖŌŎŐØÐŒÙÚÛÜǓŨŪŬŮŰŲÝÞŸŶIĆĈĊČÇĎĐĜĞĠĢĤĦĴĶĹĻĽĿŁŃŅŇŊÑŔŖŘŚŜŞŠŢŤŦŴŹŻŽß" ;
32
32
private const string diactiticsKeywordsRegexPattern = "a-zA-Z_" + diactitics ;
33
33
34
- private static readonly Regex varOrFunctionRegEx = new Regex ( $@ "^((?<sign>[+-])|(?<prefixOperator>[+][+]|--)|(?<inObject>(?<nullConditional>[?])?\.)?)(?<name>[{ diactiticsKeywordsRegexPattern } ][{ diactiticsKeywordsRegexPattern } 0-9]*)\s*((?<assignationOperator>(?<assignmentPrefix>[+\-*/%&|^]|<<|>>)?=(?![=>]))|(?<postfixOperator>([+][+]|--)(?![{ diactiticsKeywordsRegexPattern } 0-9]))|((?<isgeneric>[<](?>[^<>]+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?(?<isfunction>[(])?))", RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
34
+ private static readonly Regex varOrFunctionRegEx = new Regex ( $@ "^((?<sign>[+-])|(?<prefixOperator>[+][+]|--)|(?<inObject>(?<nullConditional>[?])?\.)?)(?<name>[{ diactiticsKeywordsRegexPattern } ](?> [{ diactiticsKeywordsRegexPattern } 0-9]*))(?> \s*) ((?<assignationOperator>(?<assignmentPrefix>[+\-*/%&|^]|<<|>>)?=(?![=>]))|(?<postfixOperator>([+][+]|--)(?![{ diactiticsKeywordsRegexPattern } 0-9]))|((?<isgeneric>[<](?>[^<>]+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?(?<isfunction>[(])?))", RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
35
35
36
36
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])?" ;
37
37
private string numberRegexPattern = null ;
@@ -40,24 +40,24 @@ public class ExpressionEvaluator
40
40
private static readonly Regex stringBeginningRegex = new Regex ( "^(?<interpolated>[$])?(?<escaped>[@])?[\" ]" , RegexOptions . Compiled ) ;
41
41
private static readonly Regex internalCharRegex = new Regex ( @"^['](\\[\\'0abfnrtv]|[^'])[']" , RegexOptions . Compiled ) ;
42
42
private static readonly Regex indexingBeginningRegex = new Regex ( @"^[?]?\[" , RegexOptions . Compiled ) ;
43
- private static readonly Regex assignationOrPostFixOperatorRegex = new Regex ( @"^\s*((?<assignmentPrefix>[+\-*/%&|^]|<<|>>)?=(?![=>])|(?<postfixOperator>([+][+]|--)(?![" + diactiticsKeywordsRegexPattern + @"0-9])))" ) ;
43
+ private static readonly Regex assignationOrPostFixOperatorRegex = new Regex ( @"^(?> \s*) ((?<assignmentPrefix>[+\-*/%&|^]|<<|>>)?=(?![=>])|(?<postfixOperator>([+][+]|--)(?![" + diactiticsKeywordsRegexPattern + @"0-9])))" ) ;
44
44
private static readonly Regex genericsDecodeRegex = new Regex ( "(?<name>[^,<>]+)(?<isgeneric>[<](?>[^<>]+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?" , RegexOptions . Compiled ) ;
45
- private static readonly Regex genericsEndOnlyOneTrim = new Regex ( @"\s+ [>]\s+ $" , RegexOptions . Compiled ) ;
45
+ private static readonly Regex genericsEndOnlyOneTrim = new Regex ( @"(?>\s*) [>](?>\s*) $" , RegexOptions . Compiled ) ;
46
46
47
47
private static readonly Regex endOfStringWithDollar = new Regex ( "^([^\" {\\ \\ ]|\\ \\ [\\ \\ \" 0abfnrtv])*[\" {]" , RegexOptions . Compiled ) ;
48
48
private static readonly Regex endOfStringWithoutDollar = new Regex ( "^([^\" \\ \\ ]|\\ \\ [\\ \\ \" 0abfnrtv])*[\" ]" , RegexOptions . Compiled ) ;
49
49
private static readonly Regex endOfStringWithDollarWithAt = new Regex ( "^[^\" {]*[\" {]" , RegexOptions . Compiled ) ;
50
50
private static readonly Regex endOfStringWithoutDollarWithAt = new Regex ( "^[^\" ]*[\" ]" , RegexOptions . Compiled ) ;
51
51
private static readonly Regex endOfStringInterpolationRegex = new Regex ( "^('\" '|[^}\" ])*[}\" ]" , RegexOptions . Compiled ) ;
52
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 ) ;
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 ) ;
57
57
58
58
// Depending on OptionInlineNamespacesEvaluationActive. Initialized in constructor
59
- private string InstanceCreationWithNewKeywordRegexPattern { get { return $@ "^new\s+ (?<name>[{ diactiticsKeywordsRegexPattern } ][{ diactiticsKeywordsRegexPattern } 0-9{ ( OptionInlineNamespacesEvaluationActive ? @"\." : string . Empty ) } ]*)\s*(?<isgeneric>[<](?>[^<>]+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?\s*((?<isfunction>[(])|(?<isArray>\[)|(?<isInit>[{{]))?"; } }
60
- private string CastRegexPattern { get { return $@ "^\(\s*(?<typeName>[{ diactiticsKeywordsRegexPattern } ][{ diactiticsKeywordsRegexPattern } 0-9{ ( OptionInlineNamespacesEvaluationActive ? @"\." : string . Empty ) } \[\]<>]*[?]?)\s*\)"; } }
59
+ private string InstanceCreationWithNewKeywordRegexPattern { get { return $@ "^new(?>\s*) (?<name>[{ diactiticsKeywordsRegexPattern } ][{ diactiticsKeywordsRegexPattern } 0-9{ ( OptionInlineNamespacesEvaluationActive ? @"\." : string . Empty ) } ]*)(?> \s*) (?<isgeneric>[<](?>[^<>]+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?(?> \s*) ((?<isfunction>[(])|(?<isArray>\[)|(?<isInit>[{{]))?"; } }
60
+ private string CastRegexPattern { get { return $@ "^\((?> \s*) (?<typeName>[{ diactiticsKeywordsRegexPattern } ][{ diactiticsKeywordsRegexPattern } 0-9{ ( OptionInlineNamespacesEvaluationActive ? @"\." : string . Empty ) } \[\]<>]*[?]?)(?> \s*) \)"; } }
61
61
62
62
private const string primaryTypesRegexPattern = @"(?<=^|[^" + diactiticsKeywordsRegexPattern + @"])(?<primaryType>object|string|bool[?]?|byte[?]?|char[?]?|decimal[?]?|double[?]?|short[?]?|int[?]?|long[?]?|sbyte[?]?|float[?]?|ushort[?]?|uint[?]?|ulong[?]?|void)(?=[^a-zA-Z_]|$)" ;
63
63
@@ -70,12 +70,12 @@ public class ExpressionEvaluator
70
70
private static readonly Regex newLineCharsRegex = new Regex ( @"\r\n|\r|\n" , RegexOptions . Compiled ) ;
71
71
72
72
// For script only
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 ) ;
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 ) ;
79
79
80
80
#endregion
81
81
0 commit comments