@@ -1306,9 +1306,7 @@ def parse(
1306
1306
if file_ast .END_SCOPE_REGEX is not None :
1307
1307
match = FRegex .END_WORD .match (line_no_comment )
1308
1308
# Handle end statement
1309
- if self .parse_end_scope_word (
1310
- line_no_comment , line_no , file_ast , match
1311
- ):
1309
+ if self .parse_end_scope_word (line_no_comment , line_no , file_ast , match ):
1312
1310
continue
1313
1311
# Look for old-style end of DO loops with line labels
1314
1312
if self .parse_do_fixed_format (
@@ -1323,7 +1321,7 @@ def parse(
1323
1321
if self ._parse_implicit (line_no_comment , line_no , file_ast ):
1324
1322
continue
1325
1323
# Mark contains statement
1326
- if self ._parse_contains (line_no_comment , line_no , file_ast ):
1324
+ if self .parse_contains (line_no_comment , line_no , file_ast ):
1327
1325
continue
1328
1326
# Loop through tests
1329
1327
obj_read = self .get_fortran_definition (line )
@@ -1343,7 +1341,7 @@ def parse(
1343
1341
if file_ast .current_scope .get_type () == INTERFACE_TYPE_ID :
1344
1342
for var_name in obj_info .var_names :
1345
1343
file_ast .add_int_member (var_name )
1346
- log .debug (' %s !!! INTERFACE-PRO - Ln:%d' , line .strip (), line_no )
1344
+ log .debug (" %s !!! INTERFACE-PRO - Ln:%d" , line .strip (), line_no )
1347
1345
continue
1348
1346
procedure_def = True
1349
1347
link_name = get_paren_substring (desc_string )
@@ -1409,24 +1407,24 @@ def parse(
1409
1407
1410
1408
# if not merge_external:
1411
1409
file_ast .add_variable (new_var )
1412
- log .debug (' %s !!! VARIABLE - Ln:%d' , line , line_no )
1410
+ log .debug (" %s !!! VARIABLE - Ln:%d" , line , line_no )
1413
1411
1414
1412
elif obj_type == "mod" :
1415
1413
new_mod = fortran_module (file_ast , line_no , obj_info )
1416
1414
file_ast .add_scope (new_mod , FRegex .END_MOD )
1417
- log .debug (' %s !!! MODULE - Ln:%d' , line , line_no )
1415
+ log .debug (" %s !!! MODULE - Ln:%d" , line , line_no )
1418
1416
1419
1417
elif obj_type == "smod" :
1420
1418
new_smod = fortran_submodule (
1421
1419
file_ast , line_no , obj_info .name , ancestor_name = obj_info .parent
1422
1420
)
1423
1421
file_ast .add_scope (new_smod , FRegex .END_SMOD )
1424
- log .debug (' %s !!! SUBMODULE - Ln:%d' , line , line_no )
1422
+ log .debug (" %s !!! SUBMODULE - Ln:%d" , line , line_no )
1425
1423
1426
1424
elif obj_type == "prog" :
1427
1425
new_prog = fortran_program (file_ast , line_no , obj_info )
1428
1426
file_ast .add_scope (new_prog , FRegex .END_PROG )
1429
- log .debug (' %s !!! PROGRAM - Ln:%d' , line , line_no )
1427
+ log .debug (" %s !!! PROGRAM - Ln:%d" , line , line_no )
1430
1428
1431
1429
elif obj_type == "sub" :
1432
1430
keywords , _ = map_keywords (obj_info .keywords )
@@ -1439,7 +1437,7 @@ def parse(
1439
1437
keywords = keywords ,
1440
1438
)
1441
1439
file_ast .add_scope (new_sub , FRegex .END_SUB )
1442
- log .debug (' %s !!! SUBROUTINE - Ln:%d' , line , line_no )
1440
+ log .debug (" %s !!! SUBROUTINE - Ln:%d" , line , line_no )
1443
1441
1444
1442
elif obj_type == "fun" :
1445
1443
keywords , _ = map_keywords (obj_info .keywords )
@@ -1467,7 +1465,7 @@ def parse(
1467
1465
keyword_info = keyword_info ,
1468
1466
)
1469
1467
file_ast .add_variable (new_obj )
1470
- log .debug (' %s !!! FUNCTION - Ln:%d' , line , line_no )
1468
+ log .debug (" %s !!! FUNCTION - Ln:%d" , line , line_no )
1471
1469
1472
1470
elif obj_type == "block" :
1473
1471
name = obj_info
@@ -1476,7 +1474,7 @@ def parse(
1476
1474
name = f"#BLOCK{ counters ['block' ]} "
1477
1475
new_block = fortran_block (file_ast , line_no , name )
1478
1476
file_ast .add_scope (new_block , FRegex .END_BLOCK , req_container = True )
1479
- log .debug (' %s !!! BLOCK - Ln:%d' , line , line_no )
1477
+ log .debug (" %s !!! BLOCK - Ln:%d" , line , line_no )
1480
1478
1481
1479
elif obj_type == "do" :
1482
1480
counters ["do" ] += 1
@@ -1485,7 +1483,7 @@ def parse(
1485
1483
block_id_stack .append (obj_info )
1486
1484
new_do = fortran_do (file_ast , line_no , name )
1487
1485
file_ast .add_scope (new_do , FRegex .END_DO , req_container = True )
1488
- log .debug (' %s !!! DO - Ln:%d' , line , line_no )
1486
+ log .debug (" %s !!! DO - Ln:%d" , line , line_no )
1489
1487
1490
1488
elif obj_type == "where" :
1491
1489
# Add block if WHERE is not single line
@@ -1494,7 +1492,7 @@ def parse(
1494
1492
name = f"#WHERE{ counters ['do' ]} "
1495
1493
new_do = fortran_where (file_ast , line_no , name )
1496
1494
file_ast .add_scope (new_do , FRegex .END_WHERE , req_container = True )
1497
- log .debug (' %s !!! WHERE - Ln:%d' , line , line_no )
1495
+ log .debug (" %s !!! WHERE - Ln:%d" , line , line_no )
1498
1496
1499
1497
elif obj_type == "assoc" :
1500
1498
counters ["block" ] += 1
@@ -1514,14 +1512,14 @@ def parse(
1514
1512
)
1515
1513
except ValueError :
1516
1514
pass
1517
- log .debug (' %s !!! ASSOCIATE - Ln:%d' , line , line_no )
1515
+ log .debug (" %s !!! ASSOCIATE - Ln:%d" , line , line_no )
1518
1516
1519
1517
elif obj_type == "if" :
1520
1518
counters ["if" ] += 1
1521
1519
name = f"#IF{ counters ['if' ]} "
1522
1520
new_if = fortran_if (file_ast , line_no , name )
1523
1521
file_ast .add_scope (new_if , FRegex .END_IF , req_container = True )
1524
- log .debug (' %s !!! IF - Ln:%d' , line , line_no )
1522
+ log .debug (" %s !!! IF - Ln:%d" , line , line_no )
1525
1523
1526
1524
elif obj_type == "select" :
1527
1525
counters ["select" ] += 1
@@ -1536,22 +1534,22 @@ def parse(
1536
1534
)
1537
1535
if new_var is not None :
1538
1536
file_ast .add_variable (new_var )
1539
- log .debug (' %s !!! SELECT - Ln:%d' , line , line_no )
1537
+ log .debug (" %s !!! SELECT - Ln:%d" , line , line_no )
1540
1538
1541
1539
elif obj_type == "typ" :
1542
1540
keywords , _ = map_keywords (obj_info .keywords )
1543
1541
new_type = fortran_type (file_ast , line_no , obj_info .name , keywords )
1544
1542
if obj_info .parent is not None :
1545
1543
new_type .set_inherit (obj_info .parent )
1546
1544
file_ast .add_scope (new_type , FRegex .END_TYPED , req_container = True )
1547
- log .debug (' %s !!! TYPE - Ln:%d' , line , line_no )
1545
+ log .debug (" %s !!! TYPE - Ln:%d" , line , line_no )
1548
1546
1549
1547
elif obj_type == "enum" :
1550
1548
counters ["block" ] += 1
1551
1549
name = f"#ENUM{ counters ['block' ]} "
1552
1550
new_enum = fortran_enum (file_ast , line_no , name )
1553
1551
file_ast .add_scope (new_enum , FRegex .END_ENUMD , req_container = True )
1554
- log .debug (' %s !!! ENUM - Ln:%d' , line , line_no )
1552
+ log .debug (" %s !!! ENUM - Ln:%d" , line , line_no )
1555
1553
1556
1554
elif obj_type == "int" :
1557
1555
name = obj_info .name
@@ -1562,7 +1560,7 @@ def parse(
1562
1560
file_ast , line_no , name , abstract = obj_info .abstract
1563
1561
)
1564
1562
file_ast .add_scope (new_int , FRegex .END_INT , req_container = True )
1565
- log .debug (' %s !!! INTERFACE - Ln:%d' , line , line_no )
1563
+ log .debug (" %s !!! INTERFACE - Ln:%d" , line , line_no )
1566
1564
1567
1565
elif obj_type == "gen" :
1568
1566
new_int = fortran_int (
@@ -1573,19 +1571,19 @@ def parse(
1573
1571
for pro_link in obj_info .pro_links :
1574
1572
file_ast .add_int_member (pro_link )
1575
1573
file_ast .end_scope (line_no )
1576
- log .debug (' %s !!! GENERIC - Ln:%d' , line , line_no )
1574
+ log .debug (" %s !!! GENERIC - Ln:%d" , line , line_no )
1577
1575
1578
1576
elif obj_type == "int_pro" :
1579
1577
if file_ast .current_scope is not None :
1580
1578
if file_ast .current_scope .get_type () == INTERFACE_TYPE_ID :
1581
1579
for name in obj_info :
1582
1580
file_ast .add_int_member (name )
1583
- log .debug (' %s !!! INTERFACE-PRO - Ln:%d' , line , line_no )
1581
+ log .debug (" %s !!! INTERFACE-PRO - Ln:%d" , line , line_no )
1584
1582
1585
1583
elif file_ast .current_scope .get_type () == SUBMODULE_TYPE_ID :
1586
1584
new_impl = fortran_scope (file_ast , line_no , obj_info [0 ])
1587
1585
file_ast .add_scope (new_impl , FRegex .END_PRO )
1588
- log .debug (' %s !!! INTERFACE-IMPL - Ln:%d' , line , line_no )
1586
+ log .debug (" %s !!! INTERFACE-IMPL - Ln:%d" , line , line_no )
1589
1587
1590
1588
elif obj_type == "use" :
1591
1589
file_ast .add_use (
@@ -1594,15 +1592,15 @@ def parse(
1594
1592
obj_info .only_list ,
1595
1593
obj_info .rename_map ,
1596
1594
)
1597
- log .debug (' %s !!! USE - Ln:%d' , line , line_no )
1595
+ log .debug (" %s !!! USE - Ln:%d" , line , line_no )
1598
1596
1599
1597
elif obj_type == "import" :
1600
1598
file_ast .add_use ("#IMPORT" , line_no , obj_info )
1601
- log .debug (' %s !!! IMPORT - Ln:%d' , line , line_no )
1599
+ log .debug (" %s !!! IMPORT - Ln:%d" , line , line_no )
1602
1600
1603
1601
elif obj_type == "inc" :
1604
1602
file_ast .add_include (obj_info , line_no )
1605
- log .debug (' %s !!! INCLUDE - Ln:%d' , line , line_no )
1603
+ log .debug (" %s !!! INCLUDE - Ln:%d" , line , line_no )
1606
1604
1607
1605
elif obj_type == "vis" :
1608
1606
if file_ast .current_scope is None :
@@ -1618,7 +1616,7 @@ def parse(
1618
1616
else :
1619
1617
for word in obj_info .obj_names :
1620
1618
file_ast .add_public (word )
1621
- log .debug (' %s !!! VISIBILITY - Ln:%d' , line , line_no )
1619
+ log .debug (" %s !!! VISIBILITY - Ln:%d" , line , line_no )
1622
1620
1623
1621
file_ast .close_file (line_no )
1624
1622
if debug :
@@ -1698,7 +1696,7 @@ def parse_do_fixed_format(
1698
1696
file_ast .end_scope (ln )
1699
1697
block_id_stack .pop ()
1700
1698
did_close = True
1701
- log .debug (' %s !!! END DO-LABELLED - Ln:%d' , line , ln )
1699
+ log .debug (" %s !!! END DO-LABELLED - Ln:%d" , line , ln )
1702
1700
if did_close :
1703
1701
return True
1704
1702
return False
@@ -1716,10 +1714,26 @@ def _parse_implicit(self, line: str, ln: int, file_ast: fortran_ast):
1716
1714
else :
1717
1715
file_ast .current_scope .set_implicit (True , ln )
1718
1716
1719
- log .debug (' %s !!! IMPLICIT - Ln:%d' , line , ln )
1717
+ log .debug (" %s !!! IMPLICIT - Ln:%d" , line , ln )
1720
1718
return True
1721
1719
1722
- def _parse_contains (self , line : str , ln : int , file_ast : fortran_ast ):
1720
+ def parse_contains (self , line : str , ln : int , file_ast : fortran_ast ) -> bool :
1721
+ """Parse contain statements
1722
+
1723
+ Parameters
1724
+ ----------
1725
+ line : str
1726
+ Document line
1727
+ ln : int
1728
+ Line number
1729
+ file_ast : fortran_ast
1730
+ AST object
1731
+
1732
+ Returns
1733
+ -------
1734
+ bool
1735
+ True if a contains is present, False otherwise
1736
+ """
1723
1737
match = FRegex .CONTAINS .match (line )
1724
1738
if match is None :
1725
1739
return False
@@ -1733,7 +1747,7 @@ def _parse_contains(self, line: str, ln: int, file_ast: fortran_ast):
1733
1747
msg = "Multiple CONTAINS statements in scope"
1734
1748
if msg :
1735
1749
file_ast .add_error (msg , Severity .error , ln , match .start (1 ), match .end (1 ))
1736
- log .debug (' %s !!! CONTAINS - Ln:%d' , line , ln )
1750
+ log .debug (" %s !!! CONTAINS - Ln:%d" , line , ln )
1737
1751
return True
1738
1752
1739
1753
def parse_docs (self , line : str , ln : int , file_ast : fortran_ast , docs : list [str ]):
0 commit comments