-
Notifications
You must be signed in to change notification settings - Fork 7
/
imap_rules.ml
38 lines (33 loc) · 1.08 KB
/
imap_rules.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(** Copyright (c) 2008,2009 Anil Madhavapeddy <[email protected]>
** See the COPYING file included in this distribution for licensing details *)
open Imap_parser
open Imap_terms
module Rules = struct
module Number = struct
(* 1*DIGIT *)
type t = int32
let test = Terminal.DIGIT.test
let one p =
(* Grab the digit characters *)
match repeat ~min:1 ~max:0 Terminal.DIGIT.one p with
|None -> None
|Some (p,dl) ->
let v = ref 0l in
let mult = ref 1 in
for i = List.length dl - 1 downto 0 do
let digit = Terminal.DIGIT.to_int (List.nth dl i) in
v := Int32.add !v (Int32.of_int (digit * !mult));
mult := !mult * 10;
done;
Some (p,!v)
end
module Body_fld_lines = struct
(* number *)
type t = Number.t
let test = Number.test
let one = Number.one
end
module Quoted_specials = struct
(* DQUOTE / 'blackslash *)
end
end