equal
deleted
inserted
replaced
47 fn () => brk (99999, 0), en); |
47 fn () => brk (99999, 0), en); |
48 |
48 |
49 |
49 |
50 (* ML command execution -- 'eval' *) |
50 (* ML command execution -- 'eval' *) |
51 |
51 |
|
52 local |
|
53 |
|
54 fun drop_last [] = [] |
|
55 | drop_last [x] = [] |
|
56 | drop_last (x :: xs) = x :: drop_last xs; |
|
57 |
|
58 val drop_last_char = implode o drop_last o explode; |
|
59 |
|
60 in |
|
61 |
52 fun use_text print verbose txt = |
62 fun use_text print verbose txt = |
53 let |
63 let |
54 val in_buffer = ref (explode txt); |
64 val in_buffer = ref (explode txt); |
55 val out_buffer = ref ([]: string list); |
65 val out_buffer = ref ([]: string list); |
56 |
66 |
63 fun exec () = |
73 fun exec () = |
64 (case ! in_buffer of |
74 (case ! in_buffer of |
65 [] => () |
75 [] => () |
66 | _ => (PolyML.compiler (get, put) (); exec ())); |
76 | _ => (PolyML.compiler (get, put) (); exec ())); |
67 |
77 |
68 fun show_output () = print (implode (rev (! out_buffer))); |
78 fun show_output () = print (drop_last_char (implode (rev (! out_buffer)))); |
69 in |
79 in |
70 exec () handle exn => (show_output (); raise exn); |
80 exec () handle exn => (show_output (); raise exn); |
71 if verbose then show_output () else () |
81 if verbose then show_output () else () |
72 end; |
82 end; |
73 |
83 |
80 fun exhibit_interrupt f x = f x; |
90 fun exhibit_interrupt f x = f x; |
81 |
91 |
82 |
92 |
83 |
93 |
84 (** OS related **) |
94 (** OS related **) |
85 |
|
86 local |
|
87 |
|
88 fun drop_last [] = [] |
|
89 | drop_last [x] = [] |
|
90 | drop_last (x :: xs) = x :: drop_last xs; |
|
91 |
|
92 val drop_last_char = implode o drop_last o explode; |
|
93 |
|
94 in |
|
95 |
|
96 |
95 |
97 (* system command execution *) |
96 (* system command execution *) |
98 |
97 |
99 (*execute Unix command which doesn't take any input from stdin and |
98 (*execute Unix command which doesn't take any input from stdin and |
100 sends its output to stdout*) |
99 sends its output to stdout*) |