@@ -215,7 +215,9 @@ protected enum TryBlockEvaluatedState
215
215
protected static object IndexingOperatorFunc ( dynamic left , dynamic right )
216
216
{
217
217
if ( left is NullConditionalNullValue )
218
+ {
218
219
return left ;
220
+ }
219
221
else if ( left is BubbleExceptionContainer )
220
222
{
221
223
return left ;
@@ -1528,20 +1530,7 @@ public object Evaluate(string expression)
1528
1530
1529
1531
for ( int i = 0 ; i < expression . Length ; i ++ )
1530
1532
{
1531
- if ( ! ParsingMethods . Any ( parsingMethod =>
1532
- {
1533
- bool ? pRes = parsingMethod ( expression , stack , ref i ) ;
1534
- //Possibility to implement an option to toggle left associativity
1535
- //If "null" is returned, an error occured while parsing
1536
- if ( pRes . HasValue )
1537
- {
1538
- return pRes . Value ; //normal case
1539
- }
1540
- else
1541
- {
1542
- return true ; //Go on with parsing without throwing an exception. We want to reach the stack processing.
1543
- }
1544
- } ) )
1533
+ if ( ! ParsingMethods . Any ( parsingMethod => parsingMethod ( expression , stack , ref i ) ) )
1545
1534
{
1546
1535
string s = expression . Substring ( i , 1 ) ;
1547
1536
@@ -1573,7 +1562,7 @@ public object Evaluate(string expression)
1573
1562
1574
1563
#region Sub parts evaluate methods (protected virtual)
1575
1564
1576
- protected virtual bool ? EvaluateCast ( string expression , Stack < object > stack , ref int i )
1565
+ protected virtual bool EvaluateCast ( string expression , Stack < object > stack , ref int i )
1577
1566
{
1578
1567
Match castMatch = Regex . Match ( expression . Substring ( i ) , CastRegexPattern , optionCaseSensitiveEvaluationActive ? RegexOptions . None : RegexOptions . IgnoreCase ) ;
1579
1568
@@ -1595,7 +1584,7 @@ public object Evaluate(string expression)
1595
1584
return false ;
1596
1585
}
1597
1586
1598
- protected virtual bool ? EvaluateNumber ( string expression , Stack < object > stack , ref int i )
1587
+ protected virtual bool EvaluateNumber ( string expression , Stack < object > stack , ref int i )
1599
1588
{
1600
1589
string restOfExpression = expression . Substring ( i ) ;
1601
1590
Match numberMatch = Regex . Match ( restOfExpression , numberRegexPattern , RegexOptions . IgnoreCase ) ;
@@ -1658,7 +1647,7 @@ public object Evaluate(string expression)
1658
1647
}
1659
1648
}
1660
1649
1661
- protected virtual bool ? EvaluateInstanceCreationWithNewKeyword ( string expression , Stack < object > stack , ref int i )
1650
+ protected virtual bool EvaluateInstanceCreationWithNewKeyword ( string expression , Stack < object > stack , ref int i )
1662
1651
{
1663
1652
if ( ! OptionNewKeywordEvaluationActive )
1664
1653
return false ;
@@ -1828,7 +1817,7 @@ void Init(object element, List<string> initArgs)
1828
1817
}
1829
1818
}
1830
1819
1831
- protected virtual bool ? EvaluateVarOrFunc ( string expression , Stack < object > stack , ref int i )
1820
+ protected virtual bool EvaluateVarOrFunc ( string expression , Stack < object > stack , ref int i )
1832
1821
{
1833
1822
Match varFuncMatch = varOrFunctionRegEx . Match ( expression . Substring ( i ) ) ;
1834
1823
@@ -1889,7 +1878,7 @@ void Init(object element, List<string> initArgs)
1889
1878
else if ( obj is BubbleExceptionContainer )
1890
1879
{
1891
1880
stack . Push ( obj ) ;
1892
- return null ;
1881
+ return true ;
1893
1882
}
1894
1883
else
1895
1884
{
@@ -1997,7 +1986,7 @@ void Init(object element, List<string> initArgs)
1997
1986
{
1998
1987
Exception = new ExpressionEvaluatorSyntaxErrorException ( $ "The call of the method \" { varFuncName } \" on type [{ objType } ] generate this error : { ex . InnerException ? . Message ?? ex . Message } ", ex )
1999
1988
} ) ;
2000
- return null ; //Signals an error to the parsing method array call
1989
+ return true ; //Signals an error to the parsing method array call
2001
1990
}
2002
1991
}
2003
1992
else
@@ -2081,7 +2070,7 @@ void Init(object element, List<string> initArgs)
2081
2070
else if ( obj is BubbleExceptionContainer )
2082
2071
{
2083
2072
stack . Push ( obj ) ;
2084
- return null ;
2073
+ return true ;
2085
2074
}
2086
2075
else
2087
2076
{
@@ -2234,7 +2223,13 @@ void Init(object element, List<string> initArgs)
2234
2223
}
2235
2224
catch ( Exception ex )
2236
2225
{
2237
- throw new ExpressionEvaluatorSyntaxErrorException ( $ "[{ objType } ] object has no public Property or Member named \" { varFuncName } \" .", ex ) ;
2226
+ //Transport the exception in stack.
2227
+ stack . Push ( new BubbleExceptionContainer ( )
2228
+ {
2229
+ Exception = new ExpressionEvaluatorSyntaxErrorException ( $ "[{ objType } ] object has no public Property or Member named \" { varFuncName } \" .", ex )
2230
+ } ) ;
2231
+ i -- ;
2232
+ return true ; //Signals an error to the parsing method array call
2238
2233
}
2239
2234
}
2240
2235
else
@@ -2441,7 +2436,7 @@ void Init(object element, List<string> initArgs)
2441
2436
}
2442
2437
}
2443
2438
2444
- protected virtual bool ? EvaluateChar ( string expression , Stack < object > stack , ref int i )
2439
+ protected virtual bool EvaluateChar ( string expression , Stack < object > stack , ref int i )
2445
2440
{
2446
2441
if ( ! OptionCharEvaluationActive )
2447
2442
return false ;
@@ -2492,7 +2487,7 @@ void Init(object element, List<string> initArgs)
2492
2487
}
2493
2488
}
2494
2489
2495
- protected virtual bool ? EvaluateOperators ( string expression , Stack < object > stack , ref int i )
2490
+ protected virtual bool EvaluateOperators ( string expression , Stack < object > stack , ref int i )
2496
2491
{
2497
2492
string regexPattern = "^(" + string . Join ( "|" , operatorsDictionary
2498
2493
. Keys
@@ -2512,7 +2507,7 @@ void Init(object element, List<string> initArgs)
2512
2507
return false ;
2513
2508
}
2514
2509
2515
- protected virtual bool ? EvaluateTernaryConditionalOperator ( string expression , Stack < object > stack , ref int i )
2510
+ protected virtual bool EvaluateTernaryConditionalOperator ( string expression , Stack < object > stack , ref int i )
2516
2511
{
2517
2512
if ( expression . Substring ( i , 1 ) . Equals ( "?" ) )
2518
2513
{
@@ -2552,7 +2547,7 @@ void Init(object element, List<string> initArgs)
2552
2547
return false ;
2553
2548
}
2554
2549
2555
- protected virtual bool ? EvaluateParenthis ( string expression , Stack < object > stack , ref int i )
2550
+ protected virtual bool EvaluateParenthis ( string expression , Stack < object > stack , ref int i )
2556
2551
{
2557
2552
string s = expression . Substring ( i , 1 ) ;
2558
2553
@@ -2603,7 +2598,7 @@ protected virtual void CorrectStackWithUnaryPlusOrMinusBeforeParenthisIfNecessar
2603
2598
}
2604
2599
}
2605
2600
2606
- protected virtual bool ? EvaluateIndexing ( string expression , Stack < object > stack , ref int i )
2601
+ protected virtual bool EvaluateIndexing ( string expression , Stack < object > stack , ref int i )
2607
2602
{
2608
2603
if ( ! OptionIndexingActive )
2609
2604
return false ;
@@ -2731,7 +2726,7 @@ protected virtual void CorrectStackWithUnaryPlusOrMinusBeforeParenthisIfNecessar
2731
2726
return false ;
2732
2727
}
2733
2728
2734
- protected virtual bool ? EvaluateString ( string expression , Stack < object > stack , ref int i )
2729
+ protected virtual bool EvaluateString ( string expression , Stack < object > stack , ref int i )
2735
2730
{
2736
2731
if ( ! OptionStringEvaluationActive )
2737
2732
return false ;
@@ -3013,7 +3008,7 @@ public string RemoveComments(string scriptWithComments)
3013
3008
3014
3009
#region Utils methods for parsing and interpretation
3015
3010
3016
- protected delegate bool ? ParsingMethodDelegate ( string expression , Stack < object > stack , ref int i ) ;
3011
+ protected delegate bool ParsingMethodDelegate ( string expression , Stack < object > stack , ref int i ) ;
3017
3012
3018
3013
protected delegate dynamic InternalDelegate ( params dynamic [ ] args ) ;
3019
3014
0 commit comments