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
64 stars 29 forks source link

use __init__ to import Fortran2008 classes (towards #411) #417

Closed rupertford closed 1 year ago

rupertford commented 1 year ago

To split the Fortran2008.py file into a file per class we also need to create an init file within a Fortran2008 directory that allows us to import the Fortran2008 classes as if they were in a single file and generate any required files there as well. This PR does this first part and moves the Fortran2008.py file into the Fortran2008 directory. A subsequent PR will actually split the Fortran2008 file.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (ca11947) 91.76% compared to head (9370504) 91.77%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #417 +/- ## ======================================= Coverage 91.76% 91.77% ======================================= Files 37 38 +1 Lines 13399 13415 +16 ======================================= + Hits 12296 12312 +16 Misses 1103 1103 ``` | [Impacted Files](https://app.codecov.io/gh/stfc/fparser/pull/417?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=stfc) | Coverage Δ | | |---|---|---| | [src/fparser/two/Fortran2008/Fortran2008.py](https://app.codecov.io/gh/stfc/fparser/pull/417?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=stfc#diff-c3JjL2ZwYXJzZXIvdHdvL0ZvcnRyYW4yMDA4L0ZvcnRyYW4yMDA4LnB5) | `99.47% <100.00%> (ø)` | | | [src/fparser/two/Fortran2008/\_\_init\_\_.py](https://app.codecov.io/gh/stfc/fparser/pull/417?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=stfc#diff-c3JjL2ZwYXJzZXIvdHdvL0ZvcnRyYW4yMDA4L19faW5pdF9fLnB5) | `100.00% <100.00%> (ø)` | | | [src/fparser/two/parser.py](https://app.codecov.io/gh/stfc/fparser/pull/417?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=stfc#diff-c3JjL2ZwYXJzZXIvdHdvL3BhcnNlci5weQ==) | `92.04% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

rupertford commented 1 year ago

Ready for first review from @arporter or @sergisiso

rupertford commented 1 year ago

Ready for next review from @arporter

rupertford commented 1 year ago

I was all set to merge this but then tried it with PSyclone and get two test failures (both in psyir/symbols/datatype_test.py), e.g.:

>       ptree = Fortran2008.Declaration_Construct(
            string_reader)
E       AttributeError: module 'fparser.two.Fortran2008' has no attribute 'Declaration_Construct'

Please could you take a look?

This is a bug in PSyclone datatypes.py. Declaration_Construct is not a new class in Fortran2008 so should be referenced as Fortran2003.Declaration_Construct. It worked previously as we include Declaration_Construct in Fortran2008.py due to it being subclassed by Declaration_Construct_C1112, but now we pull in the Fortran2008 classes from __init__.py which (rightly) does not include any Fortran2003 classes. I've created PSyclone issue 2169.

rupertford commented 1 year ago

Ready for next review from @arporter