@@ -818,7 +818,6 @@ def __init__(self, path: str = None, pp_suffixes: list = None):
818
818
self .preproc : bool = False
819
819
self .ast : fortran_ast = None
820
820
self .hash : str = None
821
- self .line : str = None
822
821
if path :
823
822
_ , file_ext = os .path .splitext (os .path .basename (path ))
824
823
if pp_suffixes :
@@ -1303,17 +1302,16 @@ def parse(
1303
1302
multi_lines .extendleft (line_stripped .split (";" ))
1304
1303
line = multi_lines .pop ()
1305
1304
line_stripped = line
1306
- self .line = line
1307
1305
# Test for scope end
1308
1306
if file_ast .END_SCOPE_REGEX is not None :
1309
1307
match = FRegex .END_WORD .match (line_no_comment )
1310
1308
# Handle end statement
1311
- if self ._parse_end_scope_word (
1309
+ if self .parse_end_scope_word (
1312
1310
line_no_comment , line_number , file_ast , match
1313
1311
):
1314
1312
continue
1315
1313
# Look for old-style end of DO loops with line labels
1316
- if self ._parse_do_fixed_format (
1314
+ if self .parse_do_fixed_format (
1317
1315
line , line_number , file_ast , line_label , block_id_stack
1318
1316
):
1319
1317
continue
@@ -1638,10 +1636,27 @@ def parse(
1638
1636
log .debug (f"{ error ['range' ]} : { error ['message' ]} " )
1639
1637
return file_ast
1640
1638
1641
- def _parse_end_scope_word (
1639
+ def parse_end_scope_word (
1642
1640
self , line : str , ln : int , file_ast : fortran_ast , match : re .Match
1643
- ):
1644
- # TODO: line.strip() is the normal line, make it self.line
1641
+ ) -> bool :
1642
+ """Parses END keyword marking the end of scopes
1643
+
1644
+ Parameters
1645
+ ----------
1646
+ line : str
1647
+ Document line
1648
+ ln : int
1649
+ Line number
1650
+ file_ast : fortran_ast
1651
+ AST object
1652
+ match : re.Match
1653
+ END word regular expression match
1654
+
1655
+ Returns
1656
+ -------
1657
+ bool
1658
+ True if a AST scope is closed, False otherwise
1659
+ """
1645
1660
if match is None :
1646
1661
return False
1647
1662
@@ -1666,7 +1681,7 @@ def _parse_end_scope_word(
1666
1681
return True
1667
1682
return False
1668
1683
1669
- def _parse_do_fixed_format (
1684
+ def parse_do_fixed_format (
1670
1685
self ,
1671
1686
line : str ,
1672
1687
ln : int ,
@@ -1683,7 +1698,7 @@ def _parse_do_fixed_format(
1683
1698
file_ast .end_scope (ln )
1684
1699
block_id_stack .pop ()
1685
1700
did_close = True
1686
- self .parser_debug ("DO" , self . line , ln , scope = True )
1701
+ self .parser_debug ("DO" , line , ln , scope = True )
1687
1702
if did_close :
1688
1703
return True
1689
1704
return False
@@ -1701,7 +1716,7 @@ def _parse_implicit(self, line: str, ln: int, file_ast: fortran_ast):
1701
1716
else :
1702
1717
file_ast .current_scope .set_implicit (True , ln )
1703
1718
1704
- self .parser_debug ("IMPLICIT" , self . line , ln )
1719
+ self .parser_debug ("IMPLICIT" , line , ln )
1705
1720
return True
1706
1721
1707
1722
def _parse_contains (self , line : str , ln : int , file_ast : fortran_ast ):
@@ -1718,7 +1733,7 @@ def _parse_contains(self, line: str, ln: int, file_ast: fortran_ast):
1718
1733
msg = "Multiple CONTAINS statements in scope"
1719
1734
if msg :
1720
1735
file_ast .add_error (msg , Severity .error , ln , match .start (1 ), match .end (1 ))
1721
- self .parser_debug ("CONTAINS" , self . line , ln )
1736
+ self .parser_debug ("CONTAINS" , line , ln )
1722
1737
return True
1723
1738
1724
1739
def parse_docs (self , line : str , ln : int , file_ast : fortran_ast , docs : list [str ]):
0 commit comments