xref: /Universal-ctags/Units/parser-fypp.r/run-guest.d/input.fy (revision 30d7c2c0dc5a7d1e3ae465553b679540bcfc128c)
1#! This test case is derived from #1810, a pull request submitted by @p-vitt
2#! and parser-fortran.r/fortran-interface.d/input.f90.
3#! Callable needs only string argument
4#:def debug_code(code)
5  #:if DEBUG > 0
6    $:code
7  #:endif
8#:enddef debug_code
9
10#! Pass code block as first positional argument
11#:call debug_code
12  if (size(array) > 100) then
13    print *, "DEBUG: spuriously large array"
14  end if
15#:endcall debug_code
16
17program helloworld
18print *, "Hello, world."
19end program helloworld
20
21module test_interface
22#! Callable needs also non-string argument types
23#:def repeat_code(code, repeat)
24  #:for ind in range(repeat)
25    $:code
26  #:endfor
27#:enddef repeat_code
28  type atype
29  end type atype
30  ! operator overload
31  interface operator(+)
32    ! subprogram prototype
33    type(atype) function add(a, b)
34      import atype
35      type(atype), intent(in) :: a, b
36    end function add
37  end interface operator(+)
38  ! wrap subprogram prototypes
39  interface ! anonymous interface
40    subroutine suba()
41    end subroutine suba
42    subroutine subb()
43    end subroutine subb
44  end interface
45  ! define generic subprograms
46#! fypp preprocessor comments  here, and
47  interface get
48#! there
49    ! subprogram name list
50    module procedure get_1d
51    module procedure get_2d
52  end interface get
53contains
54  ! definition of subprograms
55  subroutine get_1d(a)
56    real a(:)
57  end subroutine get_1d
58#! Pass code block as positional argument and 3 as keyword argument "repeat"
59#:call repeat_code(repeat=3)
60this will be repeated 3 times
61#:endcall repeat_code
62  subroutine get_2d(a)
63    real a(:, :)
64  end subroutine get_2d
65end module test_interface
66
67
68