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 reports syntax error on line after error #116

Closed arporter closed 5 years ago

arporter commented 5 years ago

When parsing the following Fortran:

MODULE continuity_a030e_mod
  IMPLICIT NONE
  TYPE, EXTENDS(kernel_type) :: continuity_a030e_type
    TYPE(arg), DIMENSION(10) :: meta_args = (/arg(write, ct, pointwise), <snip/> /)
    INTEGER :: iterates_over = internal_pts
    INTEGER :: index_offset = offset_ne
    CONTAINS
    PROCEDURE, NOPASS :: code => continuity_a030e_code
  END TYPE continuity

CONTAINS SUBROUTINE continuity_a030e_code(ji, jj, ssha, sshn, sshn_u, sshn_v, hu, hv, un, vn, rdt, e12t)

fparser2 says:

E           fparser.two.Fortran2003.FortranSyntaxError: at line 17
E           >>>  CONTAINS

whereas the error is actually the fact that the name of the type in the end type statement doesn't match with that in the opening type statement.

rupertford commented 5 years ago

This bug has been fixed in #121. The reported error is now ...

rupert@ubuntu:~/proj/fparser/src/fparser$ cat test.f90
MODULE continuity_mod
  IMPLICIT NONE
  TYPE, EXTENDS(kernel_type) :: continuity_a030e_type
    TYPE(arg), DIMENSION(10) :: meta_args = 2
    INTEGER :: iterates_over = internal_pts
    INTEGER :: index_offset = offset_ne
    CONTAINS
    PROCEDURE, NOPASS :: code => continuity_a030e_code
 END TYPE continuity_a030e
end module continuity_mod
rupert@ubuntu:~/proj/fparser/src/fparser$ ./scripts/fparser2.py test.f90 
Syntax error: at line 9
>>> END TYPE continuity_a030e
Expecting name 'continuity_a030e_type'
rupert@ubuntu:~/proj/fparser/src/fparser$ 
rupertford commented 5 years ago

@arporter. Are you OK with me closing this issue?

arporter commented 5 years ago

Of course :-)