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 28 forks source link

Structure-constructor matching is incorrect #255

Open arporter opened 4 years ago

arporter commented 4 years ago

As described in #252, fparser2's matching of structure constructors seems to be somewhat broken. In particular, it has a Structure_Constructor_2 class that refers to R457.b. However I've been unable to find any such rule in the Fortran2003 standard and because it matches "keyword = value" type patterns we end up with a=1 etc. being matched as a structure constructor.

There is also an explicit test (in test_fortran2003.py) that "some_var(a=1, b)" matches as a structure constructor when in fact this is forbidden by C486 (R458):

The keyword= may be omitted from a component-spec only if the keyword= has been
omitted from each preceding component-spec in the constructor.
arporter commented 4 years ago

If I remove Structure_Constructor_2 from the subclass_names of Structure_Constructor (which seems like the right thing to do) then we get three test failures. This requires investigation.

rupertford commented 3 years ago

Issue #283 and PR #285 are removing Structure_Constructor_2.