Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

320 nonstandard stop #451

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

320 nonstandard stop #451

wants to merge 4 commits into from

Conversation

hiker
Copy link
Collaborator

@hiker hiker commented Oct 2, 2024

Fixes #320. Adds support for extended stop codes to Fortran 2003, and adds full 2008 support for (even more) flexible expressions.

I hope I did the 2008 part correctly. I esp. wasn't certain how to check if the expressions are constant :(

Copy link

codecov bot commented Oct 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (master@2d8cef7). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #451   +/-   ##
=========================================
  Coverage          ?   92.14%           
=========================================
  Files             ?       86           
  Lines             ?    13834           
  Branches          ?        0           
=========================================
  Hits              ?    12747           
  Misses            ?     1087           
  Partials          ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@arporter arporter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much for this Joerg. Generally all looks good but I'd like a couple more tests to show that parsing STOP statements works in the context of a full parse and that the extension can be switched off. I'd also like some tests to show that the F2003 forms are still accepted by the F2008 parser.
Updated docs build fine (modulo the hundreds of existing warnings) and look good.

Extended arguments for STOP
+++++++++++++++++++++++++++

May compiler support extended arguments for the STOP statement before Fortran 2008.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/May/Many/ and "compilers"

# While non-standard, many compilers support negative numbers, and string
# operations in stop statements, e.g. `stop -1` or `stop str1//str2`.
# With this extension, these statements will be allowed.
_EXTENSIONS += ["extended-stop-format"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps s/-format/-args/ here (and elsewhere) as "format" makes me think of Fortran FORMAT statements?

@@ -2110,6 +2110,14 @@ def test_stop_stmt(): # R849
assert isinstance(obj, tcls), repr(obj)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid we're following the "you touch it, you fix it" approach here so please add a docstring for this test.

"""Test that invalid stop codes are handled."""
with pytest.raises(NoMatchError) as err:
Stop_Code(string)
assert f"Stop_Code: '{string}'" in str(err.value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be on the safe side, please could you add a slightly higher-level test where a STOP statement is parsed in the context of e.g. a program. There have been times when I've added tests like this only to find that the new functionality didn't actually work in practise!

@@ -2110,6 +2110,14 @@ def test_stop_stmt(): # R849
assert isinstance(obj, tcls), repr(obj)
assert str(obj) == "STOP 'hey you'"

obj = tcls('stop "123"//"456"')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could you also test when this extension is disabled.

or scalar-int-constant-expr
"""

subclass_names = ["Scalar_Default_Char_Expr", "Scalar_Int_Expr"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this still permit the Fortran2003 forms to match? Please add a test.

@arporter arporter added reviewed with actions PR has been reviewed and is back with developer and removed under review labels Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reviewed with actions PR has been reviewed and is back with developer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement missing executable-constructs in F2008 (R213)
2 participants