]> matita.cs.unibo.it Git - pkg-cerco/acc.git/blob - src/accweb.ml
Package description and copyright added.
[pkg-cerco/acc.git] / src / accweb.ml
1 (* let installation_path = "http://www.pps.jussieu.fr/~yrg/cerco"  *)
2
3 let installation_path = 
4   "http://0.0.0.0:8000" 
5
6 let inputs = [ 
7 (* For the moment:
8   Webify.Direct ("Scratch", 
9           (fun () -> "/* Type your source code here in C. */"));
10 *)
11   Webify.Url (installation_path ^ "/cerco_input.xml")
12
13
14 let processor step (title, contents) = 
15   let to_output title a = 
16     let lang = Languages.to_string (Languages.language_of_ast a) in
17     ("[" 
18      ^ title 
19      ^ lang
20      ^ "]", 
21      (Misc.Timed.profile (Printf.sprintf "Print %s" lang) Languages.print a))
22   in
23   let terminal title s = ("[" ^ title ^ "]", s) in
24   let (intermediate_asts, annotated_ast) = 
25     Acc.process ~step (`Source (title, contents)) 
26   in 
27   let intermediate_asts = 
28     snd (Misc.ListExt.cut_last intermediate_asts) 
29   in
30   let pasts = 
31     to_output "Annotated " annotated_ast
32     :: List.map (to_output "") intermediate_asts 
33   in
34   let (out, err) = Misc.IOExt.get_buffers () in
35   let terminals = [
36     terminal "Standard output" out;
37     terminal "Standard error" err
38   ]
39   in
40   pasts @ terminals
41
42 let now () : float = 
43   let date = jsnew Js.date_now () in
44   Js.to_float (date##getTime ())
45
46 let _ = 
47   Options.set_web_mode ();
48   Misc.Timed.set_profiling_flag true;
49   Misc.Timed.set_now now;
50   Misc.IOExt.set_buffered_mode ();
51   Webify.from_function inputs processor
52
53