fortran-lang / fprettify

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

Add indentation for where and forall constructs with a parser to en-/disable it @aradi #85

Closed helmutwecke closed 3 years ago

helmutwecke commented 3 years ago

Hello @pseewald,

I added a functionality that indents where and forall constructs, when its parser is True. When the parser is False (default), the original functionality of where and forall statements is preserved. This addition was made by request of @aradi who is interested in using fprettify.

Best regards, Helmut Wecke

pseewald commented 3 years ago

Thanks a lot! I think the indentation for forall works correctly for forall constructs (forall ... end forall) but fails for forall statements (on a single line). Is this why you introduced the --statement-constructs option?

I prefer that this new features works for both cases, but I know that parsing forall is difficult. I'll have a closer look into this.

helmutwecke commented 3 years ago

Hello,

We introduced the --statement-constructs option, because we only work with where and forall constucts in DFTB+. We do not use where or forall statements. For such cases I think it is a good idea to have an option to choose only blocks. If this option is not chosen, then fprettify will work as it did before, which means only with the where and forall one-line statements.

pseewald commented 3 years ago

As promised, I worked on a stable parser that works for both where / forall constructs and statements. Indentation is enabled by default and --statement-constructs is not needed. Let me know if there are issues with any of the new features.