]> matita.cs.unibo.it Git - helm.git/blob - DEVEL/ocaml-http/0.1.4-3/cookie_lexer.mll
tagging
[helm.git] / DEVEL / ocaml-http / 0.1.4-3 / cookie_lexer.mll
1 (*
2   OCaml HTTP - do it yourself (fully OCaml) HTTP daemon
3
4   Copyright (C) <2002-2007> Stefano Zacchiroli <zack@cs.unibo.it>
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU Library General Public License as
8   published by the Free Software Foundation, version 2.
9
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   GNU Library General Public License for more details.
14
15   You should have received a copy of the GNU Library General Public
16   License along with this program; if not, write to the Free Software
17   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
18   USA
19 *)
20
21 {
22   type cookie_token =
23     [ `QSTRING of string (* quoted string, argument is the content (no quotes) *)
24     | `SEP               (* cookie separator (i.e. ";") *)
25     | `TOKEN of string   (* unitary token *)
26     | `ASSIGN            (* equal sign *)
27     | `EOF               (* end of file *)
28     ]
29 }
30
31 rule token = parse
32   | [' ' '\t' '\n' '\r'] { token lexbuf }
33   | '"' ([^ '"'] | "\\\"")* '"' as lexeme
34       {
35         let len = String.length lexeme in
36         let content = String.sub lexeme 1 (len - 2) in
37         `QSTRING content
38       }
39   | ';' { `SEP }
40   | '=' { `ASSIGN }
41   | [^ ' ' '\t' '\n' '\r' '\7f' '\0'-'\1f' '\'' '<' '=' '>' ',' ';' ':' '?' '/'
42        '(' ')' '[' ']' '{' '}' '@' '\\']+ as lexeme
43       {
44         `TOKEN lexeme
45       }
46   | eof            { `EOF }
47