3 * https://tools.ietf.org/html/rfc1738
6 type scheme
= Scheme
of string
7 type uid
= Uid
of string
8 type pwd
= Pwd
of string
9 type host
= Host
of string
10 type port
= Port
of string
11 type path
= Path
of string
12 type name
= Name
of string
13 type value = Value
of string
36 and of_
(Scheme o
) = o
in
37 conv
to_ of_
(pcre
"https?")
41 and of_
(Uid o
) = o
in
42 conv
to_ of_
(pcre
"[^:]*")
46 and of_
(Pwd o
) = o
in
47 conv
to_ of_
(pcre
"[^@]*")
51 and of_
(Host o
) = o
in
52 conv
to_ of_
(pcre
"[^:/?]*")
56 and of_
(Port o
) = o
in
57 conv
to_ of_
(pcre
"[0-9]+")
61 and of_
(Path o
) = o
in
62 conv
to_ of_
(pcre
"[^?&]*")
66 and of_
(Name o
) = o
in
67 conv
to_ of_
(pcre
"[^=&]+")
71 and of_
(Value o
) = o
in
72 conv
to_ of_
(pcre
"[^&]*")
75 let to_ (name, value) = {name; value}
76 and of_
{name; value} = (name, value)
78 conv
to_ of_
(str
"&" *> name'
<&> str
"=" *> value'
)
83 (* https://gabriel.radanne.net/papers/tyre/tyre_paper.pdf#page=9 *)
85 let to_ ((scheme, ((uid, pwd), (host, port))), (path, query)) =
86 {scheme; uid; pwd; host; port; path; query}
87 and of_
{scheme; uid; pwd; host; port; path; query} =
88 ((scheme, ((uid, pwd), (host, port))), (path, query))
91 (scheme'
<* char '
:'
<* str
"//" <&>
92 ((uid'
<* char '
:'
<&> pwd'
<* char '
@'
) <&>
93 (host'
<* char '
:'
<&> port'
))) <&>
97 let full'
= compile
full
101 match Tyre.exec
P.full' str
with
102 | Error _
-> failwith
"gibt's nicht."