From 5833971a52a4e6e078988fa88738e5a5180cce36 Mon Sep 17 00:00:00 2001 From: Ryan Kavanagh Date: Tue, 2 Jun 2020 14:27:47 -0400 Subject: Split common parsing functions into separate function --- gemini/mimeType.ml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'gemini/mimeType.ml') diff --git a/gemini/mimeType.ml b/gemini/mimeType.ml index 1682416..0cfd063 100644 --- a/gemini/mimeType.ml +++ b/gemini/mimeType.ml @@ -33,19 +33,10 @@ struct (* FIXME: parameter does not handle quoted strings and does not try to ensure that everything is well-formed *) let open Angstrom in - let lift_or p q b = p b || q b in - let is_letter = function - | 'a' .. 'z' | 'A' .. 'Z' -> true - | _ -> false in - let is_digit = function - | '0' .. '9' -> true - | _ -> false in + let open ParseCommon.ParseCommon in let is_symbol = function | '!' | '#' | '$' | '&' | '-' | '^' | '_' | '.' | '+' -> true | _ -> false in - let is_space = function - | ' ' | '\t' -> true - | _ -> false in let take_all = take_while (fun _ -> true) in let maybe p = option None (lift (fun s -> Some s) p) in @@ -59,7 +50,7 @@ struct let parse = lift3 create_mimetype (restricted_name "type") ((char '/' *> restricted_name) "subtype") - (maybe (char ';' *> skip_while is_space *> parameter)) + (maybe (char ';' *> skip_while is_whitespace *> parameter)) "mimetype" in match Angstrom.parse_string ~consume:All parse s with | Ok x -> x -- cgit v1.2.3