public void Visit(ControlUnit node)
        {
            node.Expression.Accept(this);

            if (node.ConditionTrueBlock != null)
            {
                node.ConditionTrueBlock.Accept(this);
            }

            if (node.ConditionFalseBlock != null)
            {
                node.ConditionFalseBlock.Accept(this);
            }
        }
        public void Visit(ControlUnit node)
        {
            node.Expression.Accept(this);

            YesnoWrapper conditionstate = (YesnoWrapper)ReferenceTables.GetValue(node.Expression);
            if (node.ConditionTrueBlock != null && conditionstate.Value.HasValue && conditionstate.Value.Value)
            {
                node.ConditionTrueBlock.Accept(this);
            }

            if (node.ConditionFalseBlock != null && conditionstate.Value.HasValue && !conditionstate.Value.Value)
            {
                node.ConditionFalseBlock.Accept(this);
            }
        }
        public void Visit(ControlUnit node)
        {
            YesnoWrapper evaluatedResult = (YesnoWrapper)ReferenceTables.GetValueOrNull(node.Expression);
            _parentExpressionDidNotEvaluate = !evaluatedResult.ToBool();

            if (node.ConditionTrueBlock != null)
            {
                node.ConditionTrueBlock.Accept(this);
            }

            _parentExpressionDidNotEvaluate = false;
            if (node.ConditionFalseBlock != null)
            {
                node.ConditionFalseBlock.Accept(this);
            }
        }
 public void Visit(ControlUnit node)
 {
 }
Exemple #5
0
        public override void ExitControlUnit(QLParser.ControlUnitContext context)
        {
            IList<ElementBase> children = GetChildren();

            ControlUnit controlUnit;
            if (children.Count() == 3)
            {
                controlUnit = new ControlUnit(
                    (Expression)children[0],
                    (Block)children[1],
                    (Block)children[2],
                    SourceLocation.CreateFor(context)
                    );
            }
            else if (children.Count() == 2)
            {
                controlUnit = new ControlUnit(
                    (Expression)children[0],
                    (Block)children[1],
                    SourceLocation.CreateFor(context)
                    );
            }
            else
            {
                _astBuilderExceptions.Add(new ParserError("Bad number of controlUnit children:" + children.Count()));
                return;
            }

            AppendToAST(controlUnit);
        }