Example #1
0
        /// <summary>
        /// Checks the static semantic constraints of an AssertNode.
        /// </summary>
        /// <returns>An ISemanticCheckValue.</returns>
        /// <param name="node">Node.</param>
        public ISemanticCheckValue VisitAssertNode(AssertNode node)
        {
            // get the evaluation of this node
            IProperty evaluation = node.Accept(this.typeChecker).asProperty();

            // check that the evaluation is a boolean value
            if (!checkPropertyType(evaluation, TokenType.BOOL_VAL))
            {
                analyzer.notifyError(new IllegalTypeError(node));
            }

            return(voidProperty);
        }
Example #2
0
        /// <summary>
        /// Visits the assert node.
        /// </summary>
        /// <returns>An ISemanticCheckValue.</returns>
        /// <param name="node">Node.</param>
        public ISemanticCheckValue VisitAssertNode(AssertNode node)
        {
            // Evaluate the expression and if the result is false, execute the IOPrintNode
            // to inform the user about the failed assertion.
            // Note that this does not halt the execution!
            IProperty evaluation = node.Accept(this.evaluator).asProperty();

            if (!evaluation.asBoolean())
            {
                node.IOPrintNode.Accept(this);
            }

            return(voidProperty);
        }