Skip to content

Commit

Permalink
Disregard variants for now, add eras
Browse files Browse the repository at this point in the history
  • Loading branch information
ak-coram committed Jul 15, 2023
1 parent 2a8aa52 commit 2ac147b
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions chronogram-cldr-parser.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
,entity))))))

(let* (;; Months
(parse-month (gen-parse-fn "month" #'plump:text :integer-type t))
(parse-month (gen-parse-fn "month:not([alt])" #'plump:text :integer-type t))
(parse-month-width (gen-parse-fn "monthWidth" parse-month
:intern-type t))
(parse-month-context
(gen-parse-fn "months > monthContext" parse-month-width
:intern-type t))

;; Days
(parse-day (gen-parse-fn "day" #'plump:text :intern-type t))
(parse-day (gen-parse-fn "day:not([alt])" #'plump:text :intern-type t))
(parse-day-width (gen-parse-fn "dayWidth"
parse-day
:intern-type t))
Expand All @@ -43,7 +43,7 @@
:intern-type t))

;; Quarters
(parse-quarter (gen-parse-fn "quarter" #'plump:text
(parse-quarter (gen-parse-fn "quarter:not([alt])" #'plump:text
:integer-type t))
(parse-quarter-width (gen-parse-fn "quarterWidth"
parse-quarter
Expand All @@ -53,24 +53,44 @@
:intern-type t))

;; Day periods
(parse-day-period (gen-parse-fn "dayPeriod" #'plump:text
(parse-day-period (gen-parse-fn "dayPeriod:not([alt])" #'plump:text
:intern-type t))
(parse-day-period-width (gen-parse-fn "dayPeriodWidth"
parse-day-period
:intern-type t))
(parse-day-period-context (gen-parse-fn "dayPeriods > dayPeriodContext"
parse-day-period-width
:intern-type t))

;; Eras
(parse-era-names (gen-parse-fn "eras > eraNames > era:not([alt])"
#'plump:text
:integer-type t))
(parse-era-abbreviations (gen-parse-fn "eras > eraAbbr > era:not([alt])"
#'plump:text
:integer-type t))
(parse-era-narrow (gen-parse-fn "eras > eraNarrow > era:not([alt])"
#'plump:text
:integer-type t))
(parse-eras
(lambda (calendar)
`((abbreviated . ,(funcall parse-era-abbreviations calendar))
(narrow . ,(funcall parse-era-narrow calendar))
(wide . ,(funcall parse-era-names calendar)))))

;; Calendar
(parse-calendar
(gen-parse-fn "ldml > dates > calendars > calendar"
(lambda (calendar)
`((months . ,(funcall parse-month-context calendar))
(days . ,(funcall parse-day-context calendar))
(quarters . ,(funcall parse-quarter-context calendar))
(day-periods . ,(funcall parse-day-period-context calendar))))
(day-periods . ,(funcall parse-day-period-context calendar))
(eras . ,(funcall parse-eras calendar))))
:intern-type t)))
(defun parse-cldr (contents)
(let ((root (plump:parse contents)))
(list (cons 'calendars (funcall parse-calendar root))))))

;; (parse-cldr (uiop:read-file-string "cldr/common/main/hu.xml"))

0 comments on commit 2ac147b

Please sign in to comment.