Exit

Immediate termination of the program with status, a statement node.

声明

语法

Exit()

参数

无。

返回值

STATUS is passed to the parent process or calling process on exit.

描述

Exit causes immediate termination of the program with status. If status is omitted it returns the canonical succes for the system.

It is useful for exit from loops or process.

类型

Not applicable.

示例

program exit
    implicit none
    integer :: i
    i = 1
    do
        i = i + 1
        if (i == 10) exit
    end do
end program exit

ASR:

(TranslationUnit
    (SymbolTable
        1
        {
            doloop_08:
                (Program
                    (SymbolTable
                        2
                        {
                            i:
                                (Variable
                                    2
                                    i
                                    Local
                                    ()
                                    ()
                                    Default
                                    (Integer 4 [])
                                    Source
                                    Public
                                    Required
                                    .false.
                                )

                        })
                    doloop_08
                    []
                    [(=
                        (Var 2 i)
                        (IntegerConstant 1 (Integer 4 []))
                        ()
                    )
                    (WhileLoop
                        (LogicalConstant
                            .true.
                            (Logical 4 [])
                        )
                        [(=
                            (Var 2 i)
                            (IntegerBinOp
                                (Var 2 i)
                                Add
                                (IntegerConstant 1 (Integer 4 []))
                                (Integer 4 [])
                                ()
                            )
                            ()
                        )
                        (If
                            (IntegerCompare
                                (Var 2 i)
                                Eq
                                (IntegerConstant 3 (Integer 4 []))
                                (Logical 4 [])
                                ()
                            )
                            [(Exit)]
                            []
                        )]
                    )]
                )

        })
    []
)

也可以看看