@@ -468,7 +468,6 @@ def c_file_source(fp, directives_only=False):
468
468
directives_only sets up parser to only process directive lines such that
469
469
the output can be fed to another file source (i.e. Fortran).
470
470
"""
471
-
472
471
current_physical_line = one_space_line ()
473
472
cleaner = c_cleaner (current_physical_line , directives_only )
474
473
@@ -477,6 +476,7 @@ def c_file_source(fp, directives_only=False):
477
476
total_sloc = 0
478
477
479
478
physical_line_num = 0
479
+ continued = False
480
480
for physical_line_num , line in enumerate (fp , start = 1 ):
481
481
current_physical_line .__init__ ()
482
482
end = len (line )
@@ -511,7 +511,14 @@ def c_file_source(fp, directives_only=False):
511
511
yield curr_line
512
512
513
513
total_sloc += curr_line .physical_reset ()
514
- if 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 :
515
522
raise RuntimeError (
516
523
"Parsing failed. Please open a bug report at: "
517
524
"https://github.com/intel/code-base-investigator/issues/new?template=bug_report.yml." , # noqa: E501
@@ -590,7 +597,9 @@ def fortran_file_source(fp):
590
597
yield curr_line
591
598
592
599
total_sloc += curr_line .physical_reset ()
593
- if not cleaner .state == ["TOPLEVEL" ]:
600
+
601
+ parsing_failed = not cleaner .state == ["TOPLEVEL" ]
602
+ if parsing_failed :
594
603
raise RuntimeError (
595
604
"Parsing failed. Please open a bug report at: "
596
605
"https://github.com/intel/code-base-investigator/issues/new?template=bug_report.yml." , # noqa: E501
0 commit comments