Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

58 lines (44 sloc) 1.895 kb
(*
Copyright © 2011 MLstate
This file is part of OPA.
OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.
OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.
You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)
types:{{
open BaseChar
type url = { secure : bool
; host : string (* FIXME : en fait, plus précis que string *)
; port : int
; abs_path : string
; query : string }
(* FIXME: il faudrait mettre query : string stringmap !
afin d'avoir une vraie égalité quel que soit l'ordre des arguments *)
}}
+url : {url} <- ("http:" {{ false }} / "https:" {{ true }}) "//" host ([:] port {{__2}})? abspath? ([?] query {{__2}})?
{{ { secure = __1
; host = __3
; port = (match __4 with None -> (if __1 then 443 else 80) | Some p -> p)
; abs_path = (match __5 with None -> "/" | Some p -> p)
; query = (match __6 with None -> "" | Some q -> q) } }}
path <- char+ {{ Tgrammar.string_of_chars __1 }}
# FIXME: préciser nom.nom.nom
host <- hostchar+ {{ Tgrammar.string_of_chars __1 }}
port <- [0-9]+ {{ Tgrammar.int_of_chars __1 }}
# FIXME: préciser
abspath <- [/] char* {{ Tgrammar.string_of_chars __2 }}
# FIXME: préciser
query <- char+ {{ Tgrammar.string_of_chars __1 }}
hexa <- [0-9A-Fa-f]
hostchar <- [0-9a-z.\-] {{__1}}
/ [A-Z] {{ char_of_int (int_of_char __1 + 32) }}
# Vérifier...
char <- [+] {{ ' ' }}
/ [%] hexa hexa {{ char_of_int (16 * hexa_value __2 + hexa_value __1) }}
/ ![%?] . {{ __2 }}
Jump to Line
Something went wrong with that request. Please try again.