This commit is contained in:
parent
b234654de8
commit
e501816bcc
1 changed files with 10 additions and 4 deletions
|
|
@ -38,13 +38,18 @@ module Parse_data = struct
|
|||
take_while1 ident_char >>| String.lowercase_ascii
|
||||
|
||||
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 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 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
|
||||
let quoted_value =
|
||||
char '"' *> take_till is_eol <* end_of_line >>= fun s ->
|
||||
|
|
@ -62,7 +67,8 @@ module Parse_data = struct
|
|||
id
|
||||
(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 rec loop section_l item_l l =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue