@@ -32,6 +32,7 @@ public class ExpressionEvaluator
3232
3333 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 ) ;
3434 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 ) ;
3536 private static readonly Regex stringBeginningRegex = new Regex ( "^(?<interpolated>[$])?(?<escaped>[@])?[\" ]" ) ;
3637 private static readonly Regex internalCharRegex = new Regex ( @"^['](\\[']|[^'])*[']" ) ;
3738 private static readonly Regex indexingBeginningRegex = new Regex ( @"^[?]?\[" ) ;
@@ -50,7 +51,6 @@ public class ExpressionEvaluator
5051 private static readonly Regex initInNewBeginningRegex = new Regex ( @"^\s*{" ) ;
5152 private static readonly Regex OtherDimentionArrayInNewBeginningRegex = new Regex ( @"^\s*\[" ) ;
5253
53-
5454 // Depending on OptionInlineNamespacesEvaluationActive. Initialized in constructor
5555 private string InstanceCreationWithNewKeywordRegexPattern { get { return $@ "^new\s+(?<name>[{ diactiticsKeywordsRegexPattern } ][{ diactiticsKeywordsRegexPattern } 0-9{ ( OptionInlineNamespacesEvaluationActive ? @"\." : string . Empty ) } ]*)\s*(?<isgeneric>[<](?>[^<>]+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?\s*((?<isfunction>[(])|(?<isArray>\[)|(?<isInit>[{{]))?"; } }
5656 private Regex instanceCreationWithNewKeywordRegex = null ;
@@ -1371,8 +1371,24 @@ private bool EvaluateCast(string restOfExpression, Stack<object> stack, ref int
13711371 private bool EvaluateNumber ( string restOfExpression , Stack < object > stack , ref int i )
13721372 {
13731373 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 ) ) ;
13741388
1375- if ( numberMatch . Success
1389+ return true ;
1390+ }
1391+ else if ( numberMatch . Success
13761392 && ( ! numberMatch . Groups [ "sign" ] . Success
13771393 || stack . Count == 0
13781394 || stack . Peek ( ) is ExpressionOperator ) )
0 commit comments