This commit is contained in:
swrup 2026-02-10 04:24:05 +01:00
parent b234654de8
commit e501816bcc

View file

@ -38,13 +38,18 @@ module Parse_data = struct
take_while1 ident_char >>| String.lowercase_ascii take_while1 ident_char >>| String.lowercase_ascii
let line = take_till is_eol <* end_of_line let line = take_till is_eol <* end_of_line
let blank = blanks <* end_of_line >>| fun () -> Blank let blank_line = blanks <* end_of_line >>| fun () -> Blank
let comment = blanks *> (char '#' <|> char '%') *> line >>| fun s -> Comment s let comment = blanks *> (char '#' <|> char '%') *> line >>| fun s -> Comment s
let header = char '[' *> id <* char ']' <* end_of_line >>| fun s -> Header s
let header =
blanks *> char '[' *> id <* char ']' <* blanks <* end_of_line >>| fun s ->
Header s
let item_value = let item_value =
let unquoted_value = let unquoted_value =
take_while1 (fun c -> not (is_whitespace c || is_eol c)) <* end_of_line take_while1 (fun c -> not (is_whitespace c || is_eol c))
<* blanks
<* end_of_line
in in
let quoted_value = let quoted_value =
char '"' *> take_till is_eol <* end_of_line >>= fun s -> char '"' *> take_till is_eol <* end_of_line >>= fun s ->
@ -62,7 +67,8 @@ module Parse_data = struct
id id
(blanks *> char '=' *> blanks *> item_value) (blanks *> char '=' *> blanks *> item_value)
let config = many (choice [ blank; comment; header; item ]) <* end_of_input let config =
many (choice [ blank_line; comment; header; item ]) <* end_of_input
let fold_sections l = let fold_sections l =
let rec loop section_l item_l l = let rec loop section_l item_l l =