Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 45 lines (36 sloc) 1.451 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 (* The lexer definition *)
19 {
20 open RequestParse
21 open Printf
22
23 type lexical_error = Illegal_character
24
25 exception Lexical_error of lexical_error * int * int
26 }
27
28 rule token = parse
29 ([^':' ' ' '\t' '\n' '\r'])+ { WORD (Lexing.lexeme lexbuf) }
30 | [' ' '\t']+ { SPACE (Lexing.lexeme lexbuf) }
31 | '\r' '\n' { EOL }
32 | '\r' { EOL }
33 | '\n' { EOL }
34 | ":" { COLON }
35 | eof { EOF }
36 | _ { raise (Lexical_error(Illegal_character, Lexing.lexeme_start lexbuf, Lexing.lexeme_end lexbuf)) }
37
38 {
39 let parse_request str =
40 let buffer = Lexing.from_string str in
41 let res() = request (fun _ -> token buffer) (Lexing.from_string "dummy") in
42 try ((Lexing.lexeme_end buffer, res()):int * RequestType.parse_request)
43 with Lexical_error _ | Parsing.Parse_error -> Lexing.lexeme_end buffer, RequestType.Incomplete
44 }
Something went wrong with that request. Please try again.