예제 #1
0
    private Statement assertStatement()
    {
        match("LEFT_PAREN");
        var assert = new Statement.Assert(expression());

        match("RIGHT_PAREN");
        return(assert);
    }
예제 #2
0
    public object visitAssertStmt(Statement.Assert stmt)
    {
        if (!((bool)stmt.Expression.Accept(this)))
        {
            Console.WriteLine(string.Format("Line {0}: Assertion failed", stmt.GetLine()));
        }

        return(null);
    }
예제 #3
0
    public bool visitAssertStmt(Statement.Assert stmt)
    {
        if (stmt.Expression.Accept(expressionAnalyzer) != "bool")
        {
            ErrorWriter.Write(stmt.Expression, "Cannot assert non-boolean expression");
            return(false);
        }

        return(true);
    }