public void Construct(CommonTree syntaxIf) { //Condition var syntaxCondition = syntaxIf.GetChild(0).CastTo <CommonTree>(); ConditionExpression = TreeHelper.GetExpression(this, Scope, syntaxCondition); ConditionExpression.Construct(syntaxCondition); //check if we have an empty block if (syntaxIf.ChildCount < 2) { return; } //True var syntaxTrueStatementsBlock = syntaxIf.GetChild(1).CastTo <CommonTree>(); TrueCaseBlockStatement = TreeHelper.GetStatements(this, Scope, syntaxTrueStatementsBlock) .First(); TrueCaseBlockStatement.Construct(syntaxTrueStatementsBlock); //False if (syntaxIf.ChildCount < 3) { return; } var syntaxFalseStatementsBlock = syntaxIf.GetChild(2).CastTo <CommonTree>(); FasleCaseBlockStatement = TreeHelper.GetStatements(this, Scope, syntaxFalseStatementsBlock) .First(); FasleCaseBlockStatement.Construct(syntaxFalseStatementsBlock); }
public void Construct(CommonTree syntaxFor) { //Initialization var syntaxForInitialization = syntaxFor.GetChild(0).CastTo<CommonTree>(); if (syntaxForInitialization.ChildCount > 0) { //TODO: IMPLEMENT / FIX THIS syntaxForInitialization.Children.Cast<CommonTree>() .ForEach(syntaxVarDeclarationOrAssignment => { InitializationStatement = TreeHelper.GetStatements(this, Scope, syntaxVarDeclarationOrAssignment).First(); InitializationStatement.Construct(syntaxVarDeclarationOrAssignment); }); } //Condition var syntaxForCondition = syntaxFor.GetChild(1).CastTo<CommonTree>(); if (syntaxForCondition.ChildCount > 0) { syntaxForCondition.Children.Cast<CommonTree>() .ForEach(syntaxBoolExpression => { ConditionExpression = TreeHelper.GetExpression(this, Scope, syntaxBoolExpression); ConditionExpression.Construct(syntaxBoolExpression); }); } //Iteration var syntaxForIteration = syntaxFor.GetChild(2).CastTo<CommonTree>(); if (syntaxForIteration.ChildCount > 0) { syntaxForIteration.Children.Cast<CommonTree>() .ForEach(syntaxVarAssignment => { IterationStatement = TreeHelper.GetStatements(this, Scope, syntaxVarAssignment).First(); //if(iterationExpression is Varial) IterationStatement.Construct(syntaxVarAssignment); }); } //Block if (syntaxFor.ChildCount > 3) { var syntaxForBlock = syntaxFor.GetChild(3).CastTo<CommonTree>(); BlockOrSingleStatement = TreeHelper.GetStatements(this, Scope, syntaxForBlock).First(); BlockOrSingleStatement.Construct(syntaxForBlock); } }