]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ocaml/ocaml/contrib/camlp4/Camlp4/Struct/Grammar/Find.ml
Update
[l4.git] / l4 / pkg / ocaml / ocaml / contrib / camlp4 / Camlp4 / Struct / Grammar / Find.ml
1 (****************************************************************************)
2 (*                                                                          *)
3 (*                              Objective Caml                              *)
4 (*                                                                          *)
5 (*                            INRIA Rocquencourt                            *)
6 (*                                                                          *)
7 (*  Copyright  2006   Institut National de Recherche  en  Informatique et   *)
8 (*  en Automatique.  All rights reserved.  This file is distributed under   *)
9 (*  the terms of the GNU Library General Public License, with the special   *)
10 (*  exception on linking described in LICENSE at the top of the Objective   *)
11 (*  Caml source tree.                                                       *)
12 (*                                                                          *)
13 (****************************************************************************)
14
15 (* Authors:
16  * - Daniel de Rauglaudre: initial version
17  * - Nicolas Pouillard: refactoring
18  *)
19 (*
20       value entry e s =
21         let rec find_levels =
22           fun
23           [ [] -> None
24           | [lev :: levs] ->
25               match find_tree lev.lsuffix with
26               [ None ->
27                   match find_tree lev.lprefix with
28                   [ None -> find_levels levs
29                   | x -> x ]
30               | x -> x ] ]
31         and symbol =
32           fun
33           [ Snterm e -> if e.ename = s then Some e else None
34           | Snterml e _ -> if e.ename = s then Some e else None
35           | Smeta _ sl _ -> find_symbol_list sl
36           | Slist0 s -> find_symbol s
37           | Slist0sep s _ -> find_symbol s
38           | Slist1 s -> find_symbol s
39           | Slist1sep s _ -> find_symbol s
40           | Sopt s -> find_symbol s
41           | Stree t -> find_tree t
42           | Sself | Snext | Stoken _ | Stoken_fun _ -> None ]
43         and symbol_list =
44           fun
45           [ [s :: sl] ->
46               match find_symbol s with
47               [ None -> find_symbol_list sl
48               | x -> x ]
49           | [] -> None ]
50         and tree =
51           fun
52           [ Node {node = s; brother = bro; son = son} ->
53               match find_symbol s with
54               [ None ->
55                   match find_tree bro with
56                   [ None -> find_tree son
57                   | x -> x ]
58               | x -> x ]
59           | LocAct _ _ | DeadEnd -> None ]
60         in
61         match e.edesc with
62         [ Dlevels levs ->
63             match find_levels levs with
64             [ Some e -> e
65             | None -> raise Not_found ]
66         | Dparser _ -> raise Not_found ]
67       ;
68 *)