author | wenzelm |
Mon, 24 Sep 2007 13:52:50 +0200 | |
changeset 24688 | a5754ca5c510 |
parent 24600 | 5877b88f262c |
child 24852 | 30da58e0a483 |
permissions | -rw-r--r-- |
24584 | 1 |
(* Title: Pure/ML-Systems/polyml-5.1.ML |
23943 | 2 |
ID: $Id$ |
3 |
||
4 |
Compatibility wrapper for Poly/ML 5.1. |
|
5 |
*) |
|
6 |
||
7 |
use "ML-Systems/polyml.ML"; |
|
23966
25f34ff5eedf
moved exception capture/release to structure Exn;
wenzelm
parents:
23947
diff
changeset
|
8 |
use "ML-Systems/multithreading_polyml.ML"; |
23943 | 9 |
|
10 |
val pointer_eq = PolyML.pointerEq; |
|
11 |
||
12 |
||
13 |
(* improved versions of use_text/file *) |
|
14 |
||
24600
5877b88f262c
use_text/file: tune text (cf. ML_Parse.fix_ints);
wenzelm
parents:
24584
diff
changeset
|
15 |
fun use_text (tune: string -> string) name (print, err) verbose txt = |
23943 | 16 |
let |
24600
5877b88f262c
use_text/file: tune text (cf. ML_Parse.fix_ints);
wenzelm
parents:
24584
diff
changeset
|
17 |
val in_buffer = ref (explode (tune txt)); |
23943 | 18 |
val out_buffer = ref ([]: string list); |
19 |
fun output () = implode (rev (case ! out_buffer of "\n" :: cs => cs | cs => cs)); |
|
20 |
||
21 |
val line_no = ref 1; |
|
22 |
fun line () = ! line_no; |
|
23 |
fun get () = |
|
24 |
(case ! in_buffer of |
|
25 |
[] => "" |
|
26 |
| c :: cs => (in_buffer := cs; if c = "\n" then line_no := ! line_no + 1 else (); c)); |
|
27 |
fun put s = out_buffer := s :: ! out_buffer; |
|
28 |
||
29 |
fun exec () = |
|
30 |
(case ! in_buffer of |
|
31 |
[] => () |
|
32 |
| _ => (PolyML.compilerEx (get, put, line, name) (); exec ())); |
|
33 |
in |
|
34 |
exec () handle exn => (err (output ()); raise exn); |
|
35 |
if verbose then print (output ()) else () |
|
36 |
end; |
|
37 |
||
24600
5877b88f262c
use_text/file: tune text (cf. ML_Parse.fix_ints);
wenzelm
parents:
24584
diff
changeset
|
38 |
fun use_file tune output verbose name = |
23943 | 39 |
let |
40 |
val instream = TextIO.openIn name; |
|
41 |
val txt = TextIO.inputAll instream before TextIO.closeIn instream; |
|
24600
5877b88f262c
use_text/file: tune text (cf. ML_Parse.fix_ints);
wenzelm
parents:
24584
diff
changeset
|
42 |
in use_text tune name output verbose txt end; |