Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-functions are contained in a function #212

Merged
merged 1 commit into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions examples/subroutine_contains_issue101/test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,30 @@ function member_function3(a) result(b)
b = 3 * a
end function member_function3
end subroutine routine_member_procedures2

function function_member_procedures(in1, in2, out1, out2) result(out3)
! Test member subroutine and function
implicit none
integer, intent(in) :: in1, in2
integer, intent(out) :: out1, out2
integer :: out3

out1 = member_function(in1)
out2 = member_function2(in2)
out3 = out1 + out2
contains
function member_function(a) result(b)
implicit none
integer, intent(in) :: a
integer :: b

b = 3 * a + 2
end function member_function
function member_function2(a) result(b)
implicit none
integer, intent(in) :: a
integer :: b

b = 2 * a
end function member_function2
end function function_member_procedures
73 changes: 49 additions & 24 deletions f90wrap/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ def check_funct(cl, file, grab_hold_doc=True):

cl = file.next()

cont = 0
subroutine_lines = []
while True:

Expand All @@ -956,35 +957,59 @@ def check_funct(cl, file, grab_hold_doc=True):
cl = file.next()
continue

# Doc comment - return value
check = check_doc_rv(cl, file)
if check[0] != None:
out.ret_val_doc.append(check[0])
# contains statement
check = check_cont(cl, file)
if check[0] is not None:
cont = 1
cl = check[1]
continue

# Doc comment
check = check_doc(cl, file)
if check[0] != None:
out.doc.append(check[0])
cl = check[1]
continue
if cont == 0:
# Doc comment - return value
check = check_doc_rv(cl, file)
if check[0] != None:
out.ret_val_doc.append(check[0])
cl = check[1]
continue

# Interface section
check = check_interface_decl(cl, file)
if check[0] != None:
for a in check[0].procedures:
out.arguments.append(a)
cl = check[1]
continue
# Doc comment
check = check_doc(cl, file)
if check[0] != None:
out.doc.append(check[0])
cl = check[1]
continue

# Argument
check = check_arg(cl, file)
if check[0] != None:
for a in check[0]:
out.arguments.append(a)
# Interface section
check = check_interface_decl(cl, file)
if check[0] != None:
for a in check[0].procedures:
out.arguments.append(a)
cl = check[1]
continue
continue

# Argument
check = check_arg(cl, file)
if check[0] != None:
for a in check[0]:
out.arguments.append(a)
cl = check[1]
continue

else:
while True :
# Subroutine definition
check = check_subt(cl, file)
if check[0] is not None:
# Discard contained subroutine
cl = check[1]
continue

# Function definition
check = check_funct(cl, file)
if check[0] is not None:
# Discard contained function
cl = check[1]
continue
break

m = re.match(funct_end, cl)

Expand Down
Loading