Skip to content

Commit e5f7af5

Browse files
committed
try catch in progress
1 parent e20f3f9 commit e5f7af5

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

CodingSeb.ExpressionEvaluator/ExpressionEvaluator.cs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ private object ScriptEvaluate(string script, ref bool valueReturned, ref bool br
730730
IfBlockEvaluatedState ifBlockEvaluatedState = IfBlockEvaluatedState.NoBlockEvaluated;
731731
TryBlockEvaluatedState tryBlockEvaluatedState = TryBlockEvaluatedState.NoBlockEvaluated;
732732
List<List<string>> ifElseStatementsList = new List<List<string>>();
733+
List<List<string>> tryStatementsList = new List<List<string>>();
733734

734735
object ManageJumpStatementsOrExpressionEval(string expression)
735736
{
@@ -819,6 +820,20 @@ void ExecuteIfList()
819820
}
820821
}
821822

823+
void ExecuteTryList()
824+
{
825+
if(tryStatementsList.Count > 0)
826+
{
827+
828+
}
829+
}
830+
831+
void ExecuteBlocksStacks()
832+
{
833+
ExecuteTryList();
834+
ExecuteIfList();
835+
}
836+
822837
int i = 0;
823838

824839
while (!isReturn && !isBreak && !isContinue && i < script.Length)
@@ -903,16 +918,19 @@ void ExecuteIfList()
903918
}
904919
else
905920
{
906-
ExecuteIfList();
921+
ExecuteBlocksStacks();
907922

908923
if (keyword.Equals("if"))
909924
{
910925
ifElseStatementsList.Add(new List<string>() { keywordAttributes[0], subScript });
911926
ifBlockEvaluatedState = IfBlockEvaluatedState.If;
927+
tryBlockEvaluatedState = TryBlockEvaluatedState.NoBlockEvaluated;
912928
}
913929
else if(keyword.Equals("try"))
914930
{
915-
931+
tryStatementsList.Add(new List<string>() { subScript });
932+
ifBlockEvaluatedState = IfBlockEvaluatedState.NoBlockEvaluated;
933+
tryBlockEvaluatedState = TryBlockEvaluatedState.Try;
916934
}
917935
else if (keyword.Equals("do"))
918936
{
@@ -1040,7 +1058,7 @@ void forAction(int index)
10401058
}
10411059
else
10421060
{
1043-
ExecuteIfList();
1061+
ExecuteBlocksStacks();
10441062

10451063
if (TryParseStringAndParenthisAndCurlyBrackets(ref i)) { }
10461064
else if (script.Length - i > 2 && script.Substring(i, 3).Equals("';'"))
@@ -1061,7 +1079,7 @@ void forAction(int index)
10611079
if (!script.Substring(startOfExpression).Trim().Equals(string.Empty) && !isReturn && !isBreak && !isContinue)
10621080
throw new ExpressionEvaluatorSyntaxErrorException("A [;] character is missing.");
10631081

1064-
ExecuteIfList();
1082+
ExecuteBlocksStacks();
10651083

10661084
valueReturned = isReturn;
10671085
breakCalled = isBreak;

0 commit comments

Comments
 (0)