fortran-lang / fprettify

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

Variable name "val_2d" causes problems with plus/minus #68

Closed implicitall closed 3 years ago

implicitall commented 4 years ago

I happened to have variables named "val_0d", "val_1d", "val_2d". A particular line of code in the init.py file does not like these names.

PLUSMINUS_RE = re.compile( r"(?<=[\w)]])(?<![\d.][de])\s(+|-)\s", RE_FLAGS)

I'm not sure of the best way to fix that regular expression but I think it does not handle that corner case.

pseewald commented 4 years ago

Thanks for pointing out the regex that causes this behaviour. The regex is trying to exclude occurrences of - in real literals such as 1e-3 and 1d-3 and thus failing for variables ending with 1d, 2d, ...