ldap.2.4.0-ldap_filterparser.opp.exp 3.09 KB
Newer Older
1
File "ldap.2.4.0-ldap_filterparser.mly", line 38, characters 7-11:
2
3
4
5
Warning: the token WHSP is unused.
%{
  open Ldap_types

6
7
8
9
10
  let star_escape_rex = Pcre.regexp ~study:true ("\\" ^ "\\2a")
  let lparen_escape_rex = Pcre.regexp ~study:true ("\\" ^ "\\28")
  let rparen_escape_rex = Pcre.regexp ~study:true ("\\" ^ "\\29")
  let backslash_escape_rex = Pcre.regexp ~study:true ("\\" ^ "\\5c")
  let null_escape_rex = Pcre.regexp ~study:true ("\\" ^ "\\00")
11
12
13
14
  let unescape s =
    (Pcre.qreplace ~rex:star_escape_rex ~templ:"*"
       (Pcre.qreplace ~rex:lparen_escape_rex ~templ:"("
          (Pcre.qreplace ~rex:rparen_escape_rex ~templ:")"
15
             (Pcre.qreplace ~rex:null_escape_rex ~templ:"\000"
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
                (Pcre.qreplace ~rex:backslash_escape_rex ~templ:"\\" s)))))
%}
%start filter_and_eof
%token AND
%token <string * string> ATTRAPPROX
%token <string * string> ATTREQUAL
%token <string * Ldap_types.substring_component> ATTREQUALSUB
%token <string * string option * string> ATTREXTENDEDDN
%token <string * string * string> ATTREXTENDEDMATCH
%token <string * string> ATTRGTE
%token <string * string> ATTRLTE
%token <string> ATTRPRESENT
%token EOF
%token LPAREN
%token NOT
%token OR
%token RPAREN
%token WHSP
%type <Ldap_types.filter> filter_and_eof
%%

filterlist:
  _1 = filterlist _2 = filter
    {                    (_2 :: _1)}
| _1 = filter
    {         ([_1])}

filter:
  _1 = LPAREN _2 = AND _3 = filterlist _4 = RPAREN
    {                               (`And _3)}
| _1 = LPAREN _2 = OR _3 = filterlist _4 = RPAREN
    {                              (`Or _3)}
| _1 = LPAREN _2 = NOT _3 = filter _4 = RPAREN
    {                           (`Not _3)}
| _1 = LPAREN _2 = filter _3 = RPAREN
    {                       (_2)}
| _1 = ATTREQUALSUB
    {               (`Substrings {attrtype=(fst _1);substrings=(snd _1)})}
| _1 = ATTREQUAL
    {            (`EqualityMatch {attributeDesc=(fst _1);assertionValue=(unescape (snd _1))})}
| _1 = ATTRGTE
    {          (`GreaterOrEqual {attributeDesc=(fst _1);assertionValue=(unescape (snd _1))})}
| _1 = ATTRLTE
    {          (`LessOrEqual {attributeDesc=(fst _1);assertionValue=(unescape (snd _1))})}
| _1 = ATTRPRESENT
    {              (`Present _1)}
| _1 = ATTRAPPROX
    {             (`ApproxMatch {attributeDesc=(fst _1);assertionValue=(unescape (snd _1))})}
| _1 = ATTREXTENDEDMATCH
    {                    (let (a, oid, v) = _1 in
                       `ExtensibleMatch
                         {matchingRule=(Some (unescape oid));
                          ruletype=(Some (unescape a));
                          matchValue=(unescape v);
                          dnAttributes=false})}
| _1 = ATTREXTENDEDDN
    {                 (let (a, oid, v) = _1 in
                    `ExtensibleMatch
                      {matchingRule=(match oid with
                                         Some s -> Some (unescape s)
                                       | None -> None);
                       ruletype=(Some (unescape a));
                       matchValue=(unescape v);
                       dnAttributes=true})}

filter_and_eof:
  _1 = filter _2 = EOF
    {             (_1)}

%%