// SPDX-FileCopyrightText: 2024 Christoph Sax <c_sax@mailbox.org>
//
// SPDX-License-Identifier: EUPL-1.2

PRINT "This is A"

PRIVATE &private_macro

&private_macro="1"


IF &private_macro
(
    // No docstring

    // Docstring
    // Part A
    // Part B
    PRIVATE &nested_macro

    &nested_macro = 0x0--0x100

    Data.Set &nested_macro 1.
)

; First subroutine
SUBROUTINE subA
(
    PRIVATE &a
    ENTRY &a

    RETURN
)

subB:
(
    ENTRY &a &b

    &local_macro="local"
)

GLOBAL &global_macro
LOCAL &local_macro

GOSUB subA

// This is a subroutine call
GOSUB subB

DO ../b/b.cmm

// This is subscript call
RUN ../c.cmm

SUBROUTINE subC
(
    ENTRY &first

    PRINT "&inner_macro"+"&outer_macro"
)

LOCAL &outer_macro

SUBROUTINE subD
(
    LOCAL &inner_macro

    GOSUB subC "first"
)

SUBROUTINE subE
(
    LOCAL &inner_macro
    LOCAL &outer_macro

    GOSUB subC "first"
)

GOSUB subD

subF:
(
    ENTRY &x

    PRINT "&x"

    GOSUB subG
)

SUBROUTINE subG
(
    PRINT "&x"

    GOSUB subH
)

SUBROUTINE subH
(
    PARAMETERS &x

    PRINT "&x"

    GOSUB subI
)

SUBROUTINE subI
(
    PRINT "&x"

    ENTRY &x
    GOSUB subJ
)

SUBROUTINE subJ
(
    PRINT "&x"
)

GOSUB subF "param"

subK:
(
    GOSUB subL
)

subL:
(
    PRINT "&inf"
    GOSUB subK
)

SUBROUTINE subM
(
    PRINT "&def_after_sub"
)

GLOBAL &def_after_sub
LOCAL &inf

PRINT "&from_c_cmm"

subN:
    PRINT "StartN"

    PRINT "EndN"
    (
        RETURN
    )

subO:
    PRINT "StartO"

    PRIVATE &a
    &a="EndO"

    silent.RETURN &a

labelA:
    Data.In D:0x8000

GOTO labelA

PRINT "&from_c_cmm"

&implicit=&private_macro+1

GOSUB subP

SUBROUTINE subP
(
    &implicit=&implicit+5.
    RETURN
)

SUBROUTINE subQ
(
    PRIVATE &param
    PARAMETERS &param

    PRINT "&param"
)
