Skip to content

Commit cd216c2

Browse files
committed
Remove "relaxed" parsing mode
This parsing mode has never been enabled, and referring to it when parsing fails does not help end users. Instead, we should: - Treat any parsing failure as a bug; and - Selectively permit certain failures (with warnings). Signed-off-by: John Pennycook <[email protected]>
1 parent bd86a4f commit cd216c2

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

codebasin/file_source.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -460,13 +460,11 @@ def logical_result(self):
460460
)
461461

462462

463-
def c_file_source(fp, relaxed=False, directives_only=False):
463+
def c_file_source(fp, directives_only=False):
464464
"""
465465
Process file fp in terms of logical (sloc) and physical lines of C code.
466466
Yield blocks of logical lines of code with physical extents.
467467
Return total lines at exit.
468-
Relaxed allows for inconsistent state at the end of parsing, usefule for
469-
special composition cases.
470468
directives_only sets up parser to only process directive lines such that
471469
the output can be fed to another file source (i.e. Fortran).
472470
"""
@@ -513,22 +511,21 @@ def c_file_source(fp, relaxed=False, directives_only=False):
513511
yield curr_line
514512

515513
total_sloc += curr_line.physical_reset()
516-
if not relaxed and not cleaner.state == ["TOPLEVEL"]:
514+
if not cleaner.state == ["TOPLEVEL"]:
517515
raise RuntimeError(
518-
"Parser must end at top level without 'relaxed' mode.",
516+
"Parsing failed. Please open a bug report at: "
517+
"https://github.com/intel/code-base-investigator/issues/new?template=bug_report.yml.", # noqa: E501
519518
)
520519

521520
return (total_sloc, total_physical_lines)
522521

523522

524-
def fortran_file_source(fp, relaxed=False):
523+
def fortran_file_source(fp):
525524
"""
526525
Process file fp in terms of logical (sloc) and physical lines of
527526
fixed-form Fortran code.
528527
Yield blocks of logical lines of code with physical extents.
529528
Return total lines at exit.
530-
Relaxed allows for inconsistent state at the end of parsing, usefule for
531-
special composition cases.
532529
"""
533530

534531
current_physical_line = one_space_line()
@@ -593,9 +590,10 @@ def fortran_file_source(fp, relaxed=False):
593590
yield curr_line
594591

595592
total_sloc += curr_line.physical_reset()
596-
if not relaxed and not cleaner.state == ["TOPLEVEL"]:
593+
if not cleaner.state == ["TOPLEVEL"]:
597594
raise RuntimeError(
598-
"Parser must end at top level without 'relaxed' mode.",
595+
"Parsing failed. Please open a bug report at: "
596+
"https://github.com/intel/code-base-investigator/issues/new?template=bug_report.yml.", # noqa: E501
599597
)
600598

601599
return (total_sloc, total_physical_lines)
@@ -642,7 +640,7 @@ def process(self, lineiter):
642640
pass
643641

644642

645-
def asm_file_source(fp, relaxed=False):
643+
def asm_file_source(fp):
646644
"""
647645
Process file fp in terms of logical (sloc) and physical lines of ASM code.
648646
Yield blocks of logical lines of code with physical extents.

0 commit comments

Comments
 (0)