Skip to content
Newer
Older
100644 42 lines (35 sloc) 1.43 KB
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 # mime.types file parser
19
20 {{
21 let make l =
22 (* Printf.eprintf "%d MIME types loaded\n%!" (List.length l) ; *)
23 List.fold_left (
24 fun ((m1, m2) as acc) x ->
25 match x with None -> acc | Some (t, el) ->
26 StringMap.add t el m1,
27 List.fold_left (fun acc x -> StringMap.add x t acc) m2 el
28 ) (StringMap.empty, StringMap.empty) l
29 }}
30
31 # FIXME: EOF ?
32 +File : {string list StringMap.t * string StringMap.t} <- Line* {{ make __1 }}
33 Line <- [#] (!EOL .)* EOL {{ None }}
34 / Ident Space+ (Ident Space* {{__1}})* EOL {{ Some (__1, __3) }}
35 / (!EOL . {{__2}})* EOL {{ (*Printf.eprintf "error: line='%s'\n" (string_of_chars __1) ;*) None }}
36 Ident <- Char+ {{ Tgrammar.string_of_chars __1 }}
37 Char <- !FullSpace . {{ __2 }}
38 Space <- ' ' / '\t'
39 FullSpace <- Space / EOL
40 EOL <- '\r\n' / '\n' / '\r'
41 #EOF <- !.
Something went wrong with that request. Please try again.