public final void ifStmt() throws RecognitionException
    {
        
        AST ast1 = null, ast2 = null, ast3 = null;
        
        try {
            // CPP.g:345:3: ( 'if' '(' expr ')' stmt ( options {k=1; } : 'else' stmt )? )
            // CPP.g:345:5: 'if' '(' expr ')' stmt ( options {k=1; } : 'else' stmt )?
            {
                this.match(this.input, 45, FOLLOW_45_in_ifStmt1350);
                if (this.state.failed) {
                    return;
                }
                this.match(this.input, 42, FOLLOW_42_in_ifStmt1357);
                if (this.state.failed) {
                    return;
                }
                this.pushFollow(FOLLOW_expr_in_ifStmt1364);
                this.expr();
                
                this.state._fsp--;
                if (this.state.failed) {
                    return;
                }
                if (this.state.backtracking == 0) {
                    ast1 = this.out;
                    this.out = null;
                }
                this.match(this.input, 43, FOLLOW_43_in_ifStmt1372);
                if (this.state.failed) {
                    return;
                }
                this.pushFollow(FOLLOW_stmt_in_ifStmt1379);
                this.stmt();
                
                this.state._fsp--;
                if (this.state.failed) {
                    return;
                }
                if (this.state.backtracking == 0) {
                    ast2 = this.out;
                    this.out = null;
                }
                // CPP.g:350:5: ( options {k=1; } : 'else' stmt )?
                int alt20 = 2;
                int LA20_0 = this.input.LA(1);
                
                if ((LA20_0 == 46)) {
                	
                    if ((this.synpred42_CPP())) {
                        alt20 = 1;
                    }
                }
                switch (alt20)
                {
                    case 1:
                        // CPP.g:351:5: 'else' stmt
                    {
                        this.match(this.input, 46, FOLLOW_46_in_ifStmt1400);
                        if (this.state.failed) {
                            return;
                        }
                        this.pushFollow(FOLLOW_stmt_in_ifStmt1407);
                        this.stmt();
                        
                        this.state._fsp--;
                        if (this.state.failed) {
                            return;
                        }
                        if (this.state.backtracking == 0) {
                            ast3 = this.out;
                            this.out = null;
                        }
                        
                    }
                        break;
                    
                }
                
                if (this.state.backtracking == 0) {
                    
                    if (ast3 == null) {
                        this.out = new IfThenStmtAST((ExprAST) ast1, (OneStmtAST) ast2);
                    }
                    else {
                        this.out = new IfThenElseStmtAST((ExprAST) ast1, (OneStmtAST) ast2, (OneStmtAST) ast3);
                    }
                    
                }
                
            }
            
        }
        catch (RecognitionException re) {
            this.reportError(re);
            this.recover(this.input, re);
        } finally {
        }
        return;
    }