File: test_negative.ml

package info (click to toggle)
pxp 1.1.4-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 6,944 kB
  • ctags: 1,728
  • sloc: ml: 15,005; xml: 2,583; sh: 972; makefile: 677
file content (102 lines) | stat: -rw-r--r-- 2,194 bytes parent folder | download
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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
(* $Id: test_negative.ml,v 1.6 2000/07/14 14:57:12 gerd Exp $
 * ----------------------------------------------------------------------
 *
 *)


open Pxp_document;;
open Pxp_yacc;;
open Pxp_types;;

let error_happened = ref false;;

let rec print_error e =
  print_endline (string_of_exn e)
;;

class warner =
  object 
    method warn w =
      print_endline ("WARNING: " ^ w)
  end
;;

let parse debug wf iso88591 filename =
  try 
  let config =
      { default_config with 
	  warner = new warner;
          debugging_mode = debug;
          encoding = if iso88591 then `Enc_iso88591 else `Enc_utf8;
	  idref_pass = true;
      }
  in
    let parse_fn =
      if wf then parse_wfdocument_entity 
      else 
	let index = new hash_index in
	parse_document_entity 
	  ?transform_dtd:None 
	  ~id_index:(index :> 'ext index)
    in
    let tree =
      parse_fn
	config
	(from_file filename)
	default_spec
    in
    print_endline "Parsed without error";
  with
      e ->
	error_happened := true;
	print_error e
;;


let main() =
  let debug = ref false in
  let wf = ref false in
  let iso88591 = ref false in
  let files = ref [] in
  Arg.parse
      [ "-d",   Arg.Set debug, "turn debugging mode on";
	"-wf",  Arg.Set wf,    "check only on well-formedness";
        "-iso-8859-1", Arg.Set iso88591, "use ISO-8859-1 as internal encoding instead of UTF-8";
      ]
      (fun x -> files := x :: !files)
      "
usage: test_negative [options] file ...

List of options:";
  files := List.rev !files;
  List.iter (parse !debug !wf !iso88591) !files;
;;


main();
if !error_happened then exit(1);;

(* ======================================================================
 * History:
 * 
 * $Log: test_negative.ml,v $
 * Revision 1.6  2000/07/14 14:57:12  gerd
 * 	Updated: warner
 *
 * Revision 1.5  2000/07/14 14:20:11  gerd
 * 	Updated because of PXP interface changes.
 *
 * Revision 1.4  2000/07/09 01:49:09  gerd
 * 	Updated because of PXP interface changes.
 *
 * Revision 1.3  2000/06/04 20:31:21  gerd
 * 	Updates because of renamed PXP modules.
 *
 * Revision 1.2  2000/05/28 17:23:22  gerd
 * 	Updated.
 *
 * Revision 1.1  2000/05/01 15:58:50  gerd
 * 	Initial revision.
 *
 * 
 *)