fortran-lang / fprettify

auto-formatter for modern fortran source code
https://pypi.python.org/pypi/fprettify
Other
370 stars 76 forks source link

module procedure in submodule #70

Open implicitall opened 4 years ago

implicitall commented 4 years ago

I found that "module procedure" handling is a bit tricky. In a submodule, "module procedure" acts as a subroutine with no parameters. In an interface, it just is a generic. My hack to handle this was to add new regular expressions for module procedures. Unfortunately, for module procedures in the interface declaration, the outside scope had to be checked so that it did not cause a scope increase. That doesn't seem like an elegant solution but I don't know of another way. In any case, the point is that "module procedure" has an issue.

implicitall commented 4 years ago

Also, not to mention submodule, which is similar to a module but with a parent parameter. submodule(parent) child

pseewald commented 4 years ago

Could you give an example?

implicitall commented 4 years ago

https://github.com/scivision/fortran-submodule/blob/master/src/child.f90

implicitall commented 4 years ago

https://github.com/modern-fortran/generic-procedures/blob/master/src/mod_average.f90

In this example you don’t have to have the “::” for the generic if you don’t want. That could be a trick for parsing though if it was mandatory.