Skip to content

Commit

Permalink
prettify_cp2k: fix "=>" handling in variable decl, add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-zero committed Nov 4, 2020
1 parent 60a01ae commit 310603e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tools/prettify/prettify_cp2k/normalizeFortranFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
rf"""
\s*(?P<var>{VALID_NAME})
\s*(?P<rest>(:?\((?P<param>{NESTED_PAREN_1TO3_CONTENTS})\))?
\s*(?:=\s*(?P<value>(?:
\s*(?:(?P<assignment>=>?)\s*(?P<value>(?:
{NOT_PUNC_COMMA}+|
{BRAC_OPEN}(?:{NOT_PUNC}|{BRAC_OPEN}{NOT_PUNC}*{BRAC_CLOSE}|{QUOTED})*{BRAC_CLOSE}|
{QUOTED})+))?)?
Expand Down Expand Up @@ -402,7 +402,7 @@ def parseRoutine(inFile, logger):
if m2.group("param"):
var += "(" + m2.group("param") + ")"
if m2.group("value"):
var += " = "
var += " {} ".format(m2["assignment"])
var += m2.group("value")
decl["vars"].append(var)
str = str[m2.span()[1] :]
Expand Down
3 changes: 2 additions & 1 deletion tools/prettify/prettify_cp2k/selftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@
USE example, ONLY: dp, test_routine, test_function, test_type, str_function
IMPLICIT NONE
INTEGER :: r, i, j, k, l, my_integer, m
INTEGER :: r, i, j, k, l, my_integer, m, saved_var = 10
INTEGER, DIMENSION(5) :: arr
INTEGER, DIMENSION(20) :: big_arr
INTEGER :: ENDIF
TYPE(test_type) :: t
REAL(KIND=dp) :: r1, r2, r3, r4, r5, r6
INTEGER, POINTER :: point
INTEGER, POINTER :: point_init => NULL()
point => NULL()
Expand Down

0 comments on commit 310603e

Please sign in to comment.