@@ -32,6 +32,7 @@ public class ExpressionEvaluator
32
32
33
33
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
34
private static readonly Regex numberRegex = new Regex ( @"^(?<sign>[+-])?\d+(?<hasdecimal>\.?\d+(e[+-]?\d+)?)?(?<type>ul|[fdulm])?" , RegexOptions . IgnoreCase ) ;
35
+ private static readonly Regex hexNumberRegex = new Regex ( @"^(?<sign>[+-])?(?<hexValue>0x[0-9a-f]+)" , RegexOptions . IgnoreCase ) ;
35
36
private static readonly Regex stringBeginningRegex = new Regex ( "^(?<interpolated>[$])?(?<escaped>[@])?[\" ]" ) ;
36
37
private static readonly Regex internalCharRegex = new Regex ( @"^['](\\[']|[^'])*[']" ) ;
37
38
private static readonly Regex indexingBeginningRegex = new Regex ( @"^[?]?\[" ) ;
@@ -50,7 +51,6 @@ public class ExpressionEvaluator
50
51
private static readonly Regex initInNewBeginningRegex = new Regex ( @"^\s*{" ) ;
51
52
private static readonly Regex OtherDimentionArrayInNewBeginningRegex = new Regex ( @"^\s*\[" ) ;
52
53
53
-
54
54
// Depending on OptionInlineNamespacesEvaluationActive. Initialized in constructor
55
55
private string InstanceCreationWithNewKeywordRegexPattern { get { return $@ "^new\s+(?<name>[{ diactiticsKeywordsRegexPattern } ][{ diactiticsKeywordsRegexPattern } 0-9{ ( OptionInlineNamespacesEvaluationActive ? @"\." : string . Empty ) } ]*)\s*(?<isgeneric>[<](?>[^<>]+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?\s*((?<isfunction>[(])|(?<isArray>\[)|(?<isInit>[{{]))?"; } }
56
56
private Regex instanceCreationWithNewKeywordRegex = null ;
@@ -1371,8 +1371,24 @@ private bool EvaluateCast(string restOfExpression, Stack<object> stack, ref int
1371
1371
private bool EvaluateNumber ( string restOfExpression , Stack < object > stack , ref int i )
1372
1372
{
1373
1373
Match numberMatch = numberRegex . Match ( restOfExpression ) ;
1374
+ Match hexMatch = hexNumberRegex . Match ( restOfExpression ) ;
1375
+
1376
+ if ( hexMatch . Success
1377
+ && ( ! hexMatch . Groups [ "sign" ] . Success
1378
+ || stack . Count == 0
1379
+ || stack . Peek ( ) is ExpressionOperator ) )
1380
+ {
1381
+ i += hexMatch . Length ;
1382
+ i -- ;
1383
+
1384
+ if ( hexMatch . Groups [ "sign" ] . Success )
1385
+ stack . Push ( hexMatch . Groups [ "sign" ] . Value . Equals ( "-" ) ? - Convert . ToInt32 ( hexMatch . Groups [ "hexValue" ] . Value , 16 ) : Convert . ToInt32 ( hexMatch . Groups [ "hexValue" ] . Value , 16 ) ) ;
1386
+ else
1387
+ stack . Push ( Convert . ToInt32 ( hexMatch . Value , 16 ) ) ;
1374
1388
1375
- if ( numberMatch . Success
1389
+ return true ;
1390
+ }
1391
+ else if ( numberMatch . Success
1376
1392
&& ( ! numberMatch . Groups [ "sign" ] . Success
1377
1393
|| stack . Count == 0
1378
1394
|| stack . Peek ( ) is ExpressionOperator ) )
0 commit comments