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.866 kb
(*
Copyright © 2011 MLstate
This file is part of OPA.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
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.