]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/hbugs/scripts/ls_tutors.ml
ocaml 3.09 transition
[helm.git] / helm / ocaml / hbugs / scripts / ls_tutors.ml
1 #!/usr/bin/ocamlrun /usr/bin/ocaml
2 (*
3  * Copyright (C) 2003-2004:
4  *    Stefano Zacchiroli <zack@cs.unibo.it>
5  *    for the HELM Team http://helm.cs.unibo.it/
6  *
7  *  This file is part of HELM, an Hypertextual, Electronic
8  *  Library of Mathematics, developed at the Computer Science
9  *  Department, University of Bologna, Italy.
10  *
11  *  HELM is free software; you can redistribute it and/or
12  *  modify it under the terms of the GNU General Public License
13  *  as published by the Free Software Foundation; either version 2
14  *  of the License, or (at your option) any later version.
15  *
16  *  HELM is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with HELM; if not, write to the Free Software
23  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston,
24  *  MA  02111-1307, USA.
25  *
26  *  For details, see the HELM World-Wide-Web page,
27  *  http://helm.cs.unibo.it/
28  *)
29
30 (* Usage: ls_tutors.ml        # lists all tutors
31  *        ls_tutors.ml -auto  # lists only generated tutors
32  *)
33
34 #use "topfind"
35 #require "pxp"
36 open Printf
37 open Pxp_document
38 open Pxp_dtd
39 open Pxp_types
40 open Pxp_yacc
41
42 let index = "data/tutors_index.xml"
43 let auto_only =
44   try
45     (match Sys.argv.(1) with "-auto" -> true | _ -> false)
46   with Invalid_argument _ -> false
47 let parse_xml fname =
48   parse_wfdocument_entity default_config (from_file fname) default_spec
49 let is_tutor node =
50   match node#node_type with T_element "tutor" -> true | _ -> false
51 let main () =
52   List.iter
53     (fun tutor ->
54       try
55         (match tutor#attribute "source" with
56         | Value s ->
57             if not auto_only then
58               print_endline s
59             else  (* we should print only generated tutors *)
60               (try
61                 ignore (find_element "no_auto" tutor);
62               with Not_found ->
63                 print_endline s)
64         | _ -> assert false)
65       with Not_found -> assert false)
66     (List.filter is_tutor (parse_xml index)#root#sub_nodes)
67 let _ = main ()
68