// ELSE IF
        public override ASTNode VisitElseIfStmt(CLUBSParser.ElseIfStmtContext context)
        {
            ElseIfNode node = new ElseIfNode(new SourcePosition(context.start));

            node.Predicate = Visit(context.expr()) as ExpressionNode;
            node.Block     = Visit(context.blockStmt()) as BlockNode;

            return(node);
        }
Ejemplo n.º 2
0
        // ELSE IF
        public override TypeNode Visit(ElseIfNode node, object obj)
        {
            TypeNode predicateType = Visit(node.Predicate);

            // If predicate type is not Bool, log error
            if (predicateType != StandardTypes.Bool)
            {
                ErrorLogger.LogError(new IncompatibleTypesError(predicateType, StandardTypes.Bool, node.Predicate.SourcePosition));
                return(new ErrorTypeNode(node.SourcePosition));
            }
            Visit(node.Block);

            return(null);
        }
Ejemplo n.º 3
0
 public abstract T Visit(ElseIfNode node, object obj);
Ejemplo n.º 4
0
 // ELSE IF
 public override string Visit(ElseIfNode node, object obj)
 {
     return($"else if ({Visit(node.Predicate)}) {Visit(node.Block)}");
 }