Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -----------------------------------------------------------------------------
# BSD 3-Clause License
#
# Copyright (c) 2020-2024, Science and Technology Facilities Council.
# Copyright (c) 2020-2025, Science and Technology Facilities Council.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.13']
python-version: ['3.9', '3.10', '3.13']
steps:
- uses: actions/checkout@v3
with:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Modifications by (in alphabetical order):
* P. Vitt, University of Siegen, Germany
* A. Voysey, UK Met Office


29/08/2025 PR #477 for #476. Add Python 3.9 testing back to support upstream requirements.

31/07/2025 PR #474 for #473. Syntax error when parsing a file containing purely comments if
ignore_comments=True

Expand Down
60 changes: 34 additions & 26 deletions src/fparser/two/Fortran2003.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

# Modified work Copyright (c) 2017-2024 Science and Technology
# Modified work Copyright (c) 2017-2025 Science and Technology
# Facilities Council.
# Original work Copyright (c) 1999-2008 Pearu Peterson

Expand Down Expand Up @@ -1411,7 +1411,17 @@ class Char_Selector(Base): # R424
use_names = ["Type_Param_Value", "Scalar_Int_Initialization_Expr"]

@staticmethod
def match(string):
def match(string: str):
"""
Attempts to match the supplied text as a char-selector.

:param string: the text to attempt to match.

:returns: the matched Char_Selector object or None.
:rtype: Union[None, Tuple[Optional[Type_Param_Value],
Scalar_Int_Initialization_Expr]]

"""
if string[0] + string[-1] != "()":
return
line, repmap = string_replace_map(string[1:-1].strip())
Expand All @@ -1432,7 +1442,8 @@ def match(string):
v = repmap(v)
line = repmap(line)
return Type_Param_Value(v), Scalar_Int_Initialization_Expr(line)
elif line[:4].upper() == "KIND" and line[4:].lstrip().startswith("="):

if line[:4].upper() == "KIND" and line[4:].lstrip().startswith("="):
line = line[4:].lstrip()
line = line[1:].lstrip()
i = line.find(",")
Expand All @@ -1447,17 +1458,16 @@ def match(string):
return
v = v[1:].lstrip()
return Type_Param_Value(v), Scalar_Int_Initialization_Expr(line)
else:
i = line.find(",")
if i == -1:
return
v = line[:i].rstrip()
line = line[i + 1 :].lstrip()
if line[:4].upper() == "KIND" and line[4:].lstrip().startswith("="):
line = line[4:].lstrip()
line = line[1:].lstrip()
return Type_Param_Value(v), Scalar_Int_Initialization_Expr(line)
return None

i = line.find(",")
if i == -1:
return
v = line[:i].rstrip()
line = line[i + 1 :].lstrip()
if line[:4].upper() == "KIND" and line[4:].lstrip().startswith("="):
line = line[4:].lstrip()
line = line[1:].lstrip()
return Type_Param_Value(v), Scalar_Int_Initialization_Expr(line)

def tostr(self):
if self.items[0] is None:
Expand Down Expand Up @@ -4590,24 +4600,22 @@ class Implicit_Stmt(StmtBase): # R549
use_names = ["Implicit_Spec_List"]

@staticmethod
def match(string):
def match(string: str):
"""
Attempts to match the supplied string with an IMPLICIT statement.

:param string: the string to attempt to match.

:returns: the Implicit_Spec_List resulting from the match or None.
:rtype: Union[None, Tuple[str], Tuple[Implicit_Spec_List]]

"""
if string[:8].upper() != "IMPLICIT":
return
line = string[8:].lstrip()
if len(line) == 4 and line.upper() == "NONE":
return ("NONE",)
return (Implicit_Spec_List(line),)
for w, cls in [
(pattern.abs_implicit_none, None),
("IMPLICIT", Implicit_Spec_List),
]:
try:
obj = WORDClsBase.match(w, cls, string)
except NoMatchError:
obj = None
if obj is not None:
return obj
return None

def tostr(self):
return "IMPLICIT %s" % (self.items[0])
Expand Down