Skip to content

Commit

Permalink
parse the new header comments
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-wieser committed Jul 19, 2023
1 parent 3c376e1 commit 9f02380
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions get_mathlib4_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
commit_re = re.compile(r"^! (leanprover-community/[a-z]*) commit ([0-9a-f]*)")
import_re = re.compile(r"^import ([^ ]*)")

align_import_re = re.compile(
r'^#align_import ([^ ]*) from "(leanprover-community/[a-z]*)" ?@ ?"([0-9a-f]*)"')

def parse_name(name: str) -> tuple[str]:
"""Parse a lean name including french quotes"""
components = re.compile(r"((?:[^.«»]|«.*?»)*)(?:(\.)|$)", re.UNICODE)
Expand Down Expand Up @@ -46,10 +49,18 @@ def get_mathlib4_module_commit_info(contents):
if m:
module = parse_name(m.group(1))
m = commit_re.match(line)
if m:
if m and module:
repo = m.group(1)
commit = m.group(2)
if import_re.match(line):
break

m = align_import_re.match(line)
if m:
module = parse_name(m.group(1))
repo = m.group(2)
commit = m.group(3)
# TODO: parse multiple `#align_import`s? We don't want to read the whole file unless we
# have to.
break
return module, repo, commit

Expand Down

0 comments on commit 9f02380

Please sign in to comment.