If

Conditionally executes on block of statements depending on the evaluation of a logical expression, a stmt node.

声明

语法

If(expr test, stmt* body, stmt* orelse)

参数

test contains statement or condition to be tested. body contains block of 0 or more statements to be executed as per evaluation of test. orelse contains pointer target to else block.

返回值

无。

描述

If conditionally executes one block of constructs or statements depending on the evaluation of a logical expression. If a construct name is specfied at the beginning of an IF THEN statement, the same name must appear in the corresponding END IF statement. If a construct name is specified on an ELSE IF or ELSE statement, the same name must appear in the corresponding IF THEN and END IF statements.

Depending on the evaluation of the logical expression, one block or no block is executed.

The logical expressions are evaluated in the order in which they appear, until a true value is found or an ELSE or END IF statement is encountered.

Once a true value is found or an ELSE statement is encountered, the block immediately following it is executed and the construct execution terminates.

类型

expression and block of statements, including a pointer.

示例

program if
implicit none
if (.false.) error stop
end

ASR:

(TranslationUnit
    (SymbolTable
        1
        {
            if_01:
                (Program
                    (SymbolTable
                        2
                        {

                        })
                    if_01
                    []
                    [(If
                        (LogicalConstant
                            .false.
                            (Logical 4 [])
                        )
                        [(ErrorStop
                            ()
                        )]
                        []
                    )]
                )

        })
    []
)

也可以看看

IfArithmetic