@@ -460,17 +460,14 @@ def logical_result(self):
460
460
)
461
461
462
462
463
- def c_file_source (fp , relaxed = False , directives_only = False ):
463
+ def c_file_source (fp , directives_only = False ):
464
464
"""
465
465
Process file fp in terms of logical (sloc) and physical lines of C code.
466
466
Yield blocks of logical lines of code with physical extents.
467
467
Return total lines at exit.
468
- Relaxed allows for inconsistent state at the end of parsing, usefule for
469
- special composition cases.
470
468
directives_only sets up parser to only process directive lines such that
471
469
the output can be fed to another file source (i.e. Fortran).
472
470
"""
473
-
474
471
current_physical_line = one_space_line ()
475
472
cleaner = c_cleaner (current_physical_line , directives_only )
476
473
@@ -479,6 +476,7 @@ def c_file_source(fp, relaxed=False, directives_only=False):
479
476
total_sloc = 0
480
477
481
478
physical_line_num = 0
479
+ continued = False
482
480
for physical_line_num , line in enumerate (fp , start = 1 ):
483
481
current_physical_line .__init__ ()
484
482
end = len (line )
@@ -513,22 +511,28 @@ def c_file_source(fp, relaxed=False, directives_only=False):
513
511
yield curr_line
514
512
515
513
total_sloc += curr_line .physical_reset ()
516
- if not relaxed and not cleaner .state == ["TOPLEVEL" ]:
514
+
515
+ # Even if code is technically wrong, we should only fail when necessary.
516
+ parsing_failed = not cleaner .state == ["TOPLEVEL" ]
517
+ if continued :
518
+ log .warning ("backslash-newline at end of file" )
519
+ parsing_failed = False
520
+
521
+ if parsing_failed :
517
522
raise RuntimeError (
518
- "Parser must end at top level without 'relaxed' mode." ,
523
+ "Parsing failed. Please open a bug report at: "
524
+ "https://github.com/intel/code-base-investigator/issues/new?template=bug_report.yml" , # noqa: E501
519
525
)
520
526
521
527
return (total_sloc , total_physical_lines )
522
528
523
529
524
- def fortran_file_source (fp , relaxed = False ):
530
+ def fortran_file_source (fp ):
525
531
"""
526
532
Process file fp in terms of logical (sloc) and physical lines of
527
533
fixed-form Fortran code.
528
534
Yield blocks of logical lines of code with physical extents.
529
535
Return total lines at exit.
530
- Relaxed allows for inconsistent state at the end of parsing, usefule for
531
- special composition cases.
532
536
"""
533
537
534
538
current_physical_line = one_space_line ()
@@ -593,9 +597,12 @@ def fortran_file_source(fp, relaxed=False):
593
597
yield curr_line
594
598
595
599
total_sloc += curr_line .physical_reset ()
596
- if not relaxed and not cleaner .state == ["TOPLEVEL" ]:
600
+
601
+ parsing_failed = not cleaner .state == ["TOPLEVEL" ]
602
+ if parsing_failed :
597
603
raise RuntimeError (
598
- "Parser must end at top level without 'relaxed' mode." ,
604
+ "Parsing failed. Please open a bug report at: "
605
+ "https://github.com/intel/code-base-investigator/issues/new?template=bug_report.yml" , # noqa: E501
599
606
)
600
607
601
608
return (total_sloc , total_physical_lines )
@@ -642,7 +649,7 @@ def process(self, lineiter):
642
649
pass
643
650
644
651
645
- def asm_file_source (fp , relaxed = False ):
652
+ def asm_file_source (fp ):
646
653
"""
647
654
Process file fp in terms of logical (sloc) and physical lines of ASM code.
648
655
Yield blocks of logical lines of code with physical extents.
0 commit comments