Skip to content
Snippets Groups Projects
Commit 4918b196 authored by Björn Brandenburg's avatar Björn Brandenburg
Browse files

proofloc.py: do not count proofs that have been commented out

parent 8ae21891
No related branches found
No related tags found
1 merge request!60Move "classic" Prosa to rt.classic namespace and update documentation
...@@ -27,6 +27,9 @@ r""" ...@@ -27,6 +27,9 @@ r"""
""" """
, re.VERBOSE) , re.VERBOSE)
COMMENT_START_PATTERN = re.compile(r"\(\*")
COMMENT_END_PATTERN = re.compile(r"\*\)")
def banner(fname): def banner(fname):
fill1 = (76 - len(fname)) // 2 fill1 = (76 - len(fname)) // 2
fill2 = 76 - len(fname) - fill1 fill2 = 76 - len(fname) - fill1
...@@ -41,25 +44,31 @@ def silent(tag, line_number, line): ...@@ -41,25 +44,31 @@ def silent(tag, line_number, line):
def process_file(fname, annotate=silent): def process_file(fname, annotate=silent):
proofs = [] proofs = []
in_proof = False in_proof = False
in_comment = 0
claim = '???' claim = '???'
with open(fname) as f: with open(fname) as f:
for i, line in enumerate(f): for i, line in enumerate(f):
# simplification: we assume comment start/end not on otherwise
# significant lines
in_comment += len(COMMENT_START_PATTERN.findall(line))
in_comment -= len(COMMENT_END_PATTERN.findall(line))
assert in_comment >= 0
name_match = CLAIM_NAME_PATTERN.search(line) name_match = CLAIM_NAME_PATTERN.search(line)
if not name_match is None: if not name_match is None:
claim = name_match.group(2) claim = name_match.group(2)
if in_proof: if in_proof:
if PROOF_END_PATTERN.search(line): if not in_comment and PROOF_END_PATTERN.search(line):
annotate('###', i, line) annotate('###', i, line)
proofs.append( (fname, start + 1, claim, i - start - 1) ) proofs.append( (fname, start + 1, claim, i - start - 1) )
in_proof = False in_proof = False
claim = '???' claim = '???'
else: else:
annotate(' P ', i, line) annotate(' P ', i, line)
elif SINGLE_LINE_PROOF_PATTERN.search(line): elif not in_comment and SINGLE_LINE_PROOF_PATTERN.search(line):
annotate('*P*', i, line) annotate('*P*', i, line)
proofs.append( (fname, i + 1, claim, 1) ) proofs.append( (fname, i + 1, claim, 1) )
claim = '???' claim = '???'
elif PROOF_START_PATTERN.search(line): elif not in_comment and PROOF_START_PATTERN.search(line):
annotate('***', i, line) annotate('***', i, line)
in_proof = True in_proof = True
start = i start = i
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment