Skip to content

Commit

Permalink
Clean up edtf parser code (remove old test case comments)
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed Nov 21, 2024
1 parent ed23f6c commit 646f739
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/undate/converters/edtf/edtf.lark
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ date: year | year "-" month | year "-" month "-" day

year: /-?\d+/
month: /(0[1-9])|(1[0-2])/
day: /([0-2][1-9])|(3[0-1])/
day: /([0-2][0-9])|(3[0-1])/

timeinterval: date "/" date

Expand Down
41 changes: 2 additions & 39 deletions src/undate/converters/edtf/parser.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,8 @@
import os.path
import pathlib

from lark import Lark

grammar_path = os.path.join(os.path.dirname(__file__), "edtf.lark")
grammar_path = pathlib.Path(__file__).parent / "edtf.lark"

with open(grammar_path) as grammar:
edtf_parser = Lark(grammar.read(), start="edtf")


# testcases = [
# "1984",
# "1984-05",
# "1984-12",
# "1001-03-30",
# "1000/2000",
# "1000-01/2000-05-01",
# # level 1
# "Y170000002",
# "2001-21", # spring 2001
# # qualifiers
# "1984?",
# "2004-06~",
# "2004-06-11%",
# # unspecified digits from right
# "201X",
# "20XX",
# "2004-XX",
# "1985-04-XX",
# "1985-XX-XX",
# # open ended intervals
# "1985-04-12/..",
# "1985-04/..",
# "../1985-04-12",
# "/1985-04-12",
# "1984-13",
# ]

# for testcase in testcases:
# print(f"\n{testcase}")
# tree = edtf_parser.parse(testcase)
# print(tree.pretty())


# error_cases = ["1984-13", "Y1702"]

0 comments on commit 646f739

Please sign in to comment.