diff options
author | Alban Gruin | 2021-10-04 12:37:53 +0200 |
---|---|---|
committer | Alban Gruin | 2021-10-04 12:37:53 +0200 |
commit | cee4a3ef6aba480b54ae32b427ce4579832e5d69 (patch) | |
tree | 9fc88ad4d5b7a50b04a7af38c2c9d54de0d4615d | |
parent | 8cb5040483bd9849d4e6972e608aff7b2ae03dd3 (diff) |
course: fix parsing issues
The constructors Location and Summary were inverted, causing confusion
in the loc_and_sum_to_location and loc_and_sum_to_summary functions.
For instance, if no location was found, the summary would be empty (even
though it was found), and the location would be the name of the event.
This fixes these names and functions to work properly.
Signed-off-by: Alban Gruin <alban at pa1ch dot fr>
-rw-r--r-- | src/course.ml | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/course.ml b/src/course.ml index 4b9c914..5ce2564 100644 --- a/src/course.ml +++ b/src/course.ml @@ -49,20 +49,20 @@ let replace_entities str = type loc_and_sum = | Nothing | Groups of string list - | Location of string list * string - | Summary of string list * string * string + | Summary of string list * string + | Location of string list * string * string let loc_and_sum_to_groups = function | Nothing -> [] - | Groups groups | Location (groups, _) | Summary (groups, _, _) -> groups + | Groups groups | Summary (groups, _) | Location (groups, _, _) -> groups let loc_and_sum_to_location = function - | Nothing | Groups _ -> "" - | Location (_, location) | Summary (_, location, _) -> location + | Nothing | Groups _ | Summary _ -> "" + | Location (_, _, location) -> location let loc_and_sum_to_summary category = function - | Nothing | Groups _ | Location _ -> category - | Summary (_, _, summary) -> + | Nothing | Groups _ -> category + | Summary (_, summary) | Location (_, summary, _) -> let summary = match Astring.String.cut ~sep:" - " summary with | None -> summary | Some (_, str) -> str in @@ -90,9 +90,9 @@ let location_and_summary str = let parts = Astring.String.cuts ~empty:false ~sep str in List.fold_right (fun str -> function | Nothing -> check_groups str - | Groups groups -> Location (groups, replace_entities str) - | Location (groups, summary) -> Summary (groups, replace_entities str, summary) - | Summary _ as res -> res) + | Groups groups -> Summary (groups, replace_entities str) + | Summary (groups, summary) -> Location (groups, summary, replace_entities str) + | Location _ as res -> res) parts Nothing let date = |