stfc / fparser

This project maintains and develops a Fortran parser called fparser2 written purely in Python which supports Fortran 2003 and some Fortran 2008. A legacy parser fparser1 is also available but is not supported. The parsers were originally part of the f2py project by Pearu Peterson.
https://fparser.readthedocs.io
Other
61 stars 29 forks source link

fparser2 failed to parse a forall statement that has a complex assignment statement #145

Closed grnydawn closed 5 years ago

grnydawn commented 5 years ago

Following line failed with FortranSyntaxError exception.

forall (up = 1:upn-1) flwafact(up,ew,ns) = 0.5d0 * (sum(flwa(up:up+1,ew,ns)) / 2.d0)**p1

rupertford commented 5 years ago

This problem should be fixed when PRs #152 and #154 are on master. I tested this out on a branch and it works ...

xed67771@arcgdel01:~/proj/fparser/src/fparser$ git checkout -b tmp_issue_145 forall_stmt_bug
Switched to a new branch 'tmp_issue_145'
xed67771@arcgdel01:~/proj/fparser/src/fparser$ git merge forall_construct_stmt_bug
Auto-merging src/fparser/two/Fortran2003.py
Merge made by the 'recursive' strategy.
 src/fparser/two/Fortran2003.py                                      |  77 +++++++++++++++++------
 src/fparser/two/tests/fortran2003/test_executable_construct_r213.py |   3 -
 src/fparser/two/tests/fortran2003/test_forall_header_r754.py        | 118 ++++++++++++++++++++++++++++++++++++
 src/fparser/two/tests/test_fortran2003.py                           |  12 ----
 4 files changed, 177 insertions(+), 33 deletions(-)
 create mode 100644 src/fparser/two/tests/fortran2003/test_forall_header_r754.py
xed67771@arcgdel01:~/proj/fparser/src/fparser$ cat tmp.f90
program test
   forall (up = 1:upn-1) flwafact(up,ew,ns) = 0.5d0 * (sum(flwa(up:up+1,ew,ns)) / 2.d0)**p1
   !forall (up = 1:upn,i=1:2) flwafact(up,ew,ns) = 0.5d0
   !forall (i=1:2,j=1:2) a(i,j) = i+j
end program test
xed67771@arcgdel01:~/proj/fparser/src/fparser$ scripts/fparser2.py tmp.f90
PROGRAM test
  FORALL (up = 1 : upn - 1) flwafact(up, ew, ns) = 0.5D0 * (sum(flwa(up : up + 1, ew, ns)) / 2.D0) ** p1
END PROGRAM test
xed67771@arcgdel01:~/proj/fparser/src/fparser$ 
rupertford commented 5 years ago

152 and #154 are now on master. I've checked that the provided example is parsed successfully (and it is) so I'm closing this issue.