Commit aa3882f7 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2002-12-11 22:33:40 by cvscast] Empty log message

Original author: cvscast
Date: 2002-12-11 22:33:41+00:00
parent 9a656035
...@@ -292,66 +292,24 @@ let titles_concat = [bib]/<paper>_/<title>_/Char;; ...@@ -292,66 +292,24 @@ let titles_concat = [bib]/<paper>_/<title>_/Char;;
"; ];; "; ];;
let present = "<ul let present = "<ul><li><a href=\"/cgi-bin/cduce?example=functions\">Functions.</a>
><li
><a href=\"/cgi-bin/cduce?example=functions\"
>Functions.</a
>
Several syntaxes to define functions. Several syntaxes to define functions.
</li </li><li><a href=\"/cgi-bin/cduce?example=mutrec\">Mutual recursion.</a>
><li
><a href=\"/cgi-bin/cduce?example=mutrec\"
>Mutual recursion.</a
>
Mutual toplevel definition for types and functions. Mutual toplevel definition for types and functions.
</li </li><li><a href=\"/cgi-bin/cduce?example=seq\">Sequence literals.</a>
><li
><a href=\"/cgi-bin/cduce?example=seq\"
>Sequence literals.</a
>
How to write sequences. How to write sequences.
</li </li><li><a href=\"/cgi-bin/cduce?example=seqtypes\">Sequence types.</a>
><li
><a href=\"/cgi-bin/cduce?example=seqtypes\"
>Sequence types.</a
>
Types for sequences. Types for sequences.
</li </li><li><a href=\"/cgi-bin/cduce?example=integers\">The factorial function.</a>
><li
><a href=\"/cgi-bin/cduce?example=integers\"
>The factorial function.</a
>
What about computing 10000! ? What about computing 10000! ?
</li </li><li><a href=\"/cgi-bin/cduce?example=sumtype\">Sum types.</a>
><li
><a href=\"/cgi-bin/cduce?example=sumtype\"
>Sum types.</a
>
How to simulate ML sum types. How to simulate ML sum types.
</li </li><li><a href=\"/cgi-bin/cduce?example=ovfun\">Overloaded functions.</a>
><li
><a href=\"/cgi-bin/cduce?example=ovfun\"
>Overloaded functions.</a
>
This examples demonstrates the use of overloaded functions. This examples demonstrates the use of overloaded functions.
</li </li><li><a href=\"/cgi-bin/cduce?example=note\">Footnotes.</a>
><li
><a href=\"/cgi-bin/cduce?example=note\"
>Footnotes.</a
>
This example shows how to bind an XML element with surrounding text. This example shows how to bind an XML element with surrounding text.
</li </li><li><a href=\"/cgi-bin/cduce?example=biblio\">Bibliography.</a>
><li
><a href=\"/cgi-bin/cduce?example=biblio\"
>Bibliography.</a
>
The good old XML bibliography example. The good old XML bibliography example.
</li </li><li><a href=\"/cgi-bin/cduce?example=projection\">Projection.</a>
><li
><a href=\"/cgi-bin/cduce?example=projection\"
>Projection.</a
>
Syntactic sugar for projection. Syntactic sugar for projection.
</li </li></ul>";;
></ul \ No newline at end of file
>";;
\ No newline at end of file
...@@ -43,60 +43,89 @@ let example code = ...@@ -43,60 +43,89 @@ let example code =
try List.assoc code Examples.examples try List.assoc code Examples.examples
with Not_found -> "" with Not_found -> ""
let begin_table = let begin_table = "<div class=\"box\">"
"<table width='100%' border=0 cellspacing=0 cellpadding=2 bgcolor=black> let end_table = "</div>"
<tr><td>
<table width='100%' border=0 cellspacing=0 cellpadding=3 bgcolor=white>
<tr><td>"
let end_table = "</td></tr></table></td></tr></table><br>"
let persistant = ref false let persistant = ref false
let session_id = ref "" let session_id = ref ""
let (|||) p x = p x; p
let (||=) p () = ()
let html_header p = let html_header p =
p "<html><head><title>CDuce online prototype</title></head>"; p "
p "<body bgcolor='#BBDDFF'>"; <?xml version=\"1.0\" encoding=\"iso-8859-1\"?>
p begin_table; <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
p "<h1>CDuce online prototype</h1>"; \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
p end_table; <html>
<head>
<meta content=\"text/html; charset=iso-8859-1\"
http-equiv=\"Content-Type\"/>
<link type=\"text/css\" href=\"/cduce2.css\" rel=\"stylesheet\"/>
<title>CDuce online prototype</title>
</head>
<body>
<div class=\"title\"> <h1>CDuce online prototype</h1> </div>
<div id=\"Sidelog\">
<div class=\"box\">
<ul>
<li><a href=\"/\">Main page</a></li>
<li><a href=\"/memento.html\">CDuce Memento</a></li>
</ul>
</div>
";
if !persistant then if !persistant then
(p begin_table; p "
p "You're running the CDuce prototype in session mode: values and </div>
<div id=\"Content\">
<div class=\"box\">
<p>You're running the CDuce prototype in session mode: values and
types accepted by CDuce when you click 'Submit' will be available types accepted by CDuce when you click 'Submit' will be available
for subsequent requests."; for subsequent requests.</p>
(* p "<small> (session #"; p !session_id; p ")</small>"; *) </div>
p end_table) "
else else
(p begin_table; p ||| "
p "This page is a front-end to a prototype implementation of CDuce."; <div class=\"box\">
p "You can start from one of the predefined examples below or try "; <p>
p "with you own program..."; You can start from one of the predefined examples below or try
p "The session mode remembers CDuce definitions across requests."; with you own program...</p>
p Examples.present; " ||| Examples.present ||| "</div></div><div id=\"Content\">"
p end_table) ||= ()
let html_form p content = let html_form p content =
p begin_table; p "
p "<h2>Input</h2>"; <div class=\"box\">
p "<form method=post>"; <h2>Input</h2>
p "<input type=submit name=exec value='Submit to CDuce'>"; <form method=\"post\" action=\"/cgi-bin/cduce\">
if !persistant then( <p><input type=\"submit\" name=\"exec\" value=\"Submit to CDuce\"/> ";
p "<input type=submit name=dump value='Show current environment'>"; if !persistant then
p "<input type=submit name=close value='Close session'>"; p ||| "
p "<input type=hidden name=session value='"; p !session_id; p "'>"; <input type=\"submit\" name=\"dump\" value=\"Show current environment\"/>
) else ( <input type=\"submit\" name=\"close\" value=\"Close session\"/>
p "<input type=submit name=open value=\"Initiate session\">"; <input type=\"hidden\" name=\"session\" value=\"" ||| !session_id
); ||| "\"/>" ||= ()
p "<br><textarea name=prog cols=80 rows=25>"; p content; p "</textarea>"; else
p "</form>"; p "<input type=\"submit\" name=\"open\" value=\"Initiate session\"/>
p end_table <small>
The session mode remembers CDuce definitions across requests.
</small>
";
p ||| "</p><p><textarea name=\"prog\" cols=\"80\" rows=\"25\">"
||| content
||| "</textarea></p></form></div>"
||= ()
let html_footer p = let html_footer p =
p "</body></html>\n" p "
</div>
</body>
</html>
"
let () = let () =
...@@ -171,7 +200,7 @@ let main (cgi : Netcgi.std_activation) = ...@@ -171,7 +200,7 @@ let main (cgi : Netcgi.std_activation) =
try try
let nb_sessions = flush_sessions () in let nb_sessions = flush_sessions () in
cgi # set_header cgi # set_header
~content_type:"text/html; charset=\"iso-8859-1\"" (* ~content_type:"text/html; charset=\"iso-8859-1\"" *)
(); ();
let cmd = let cmd =
...@@ -227,10 +256,8 @@ let main (cgi : Netcgi.std_activation) = ...@@ -227,10 +256,8 @@ let main (cgi : Netcgi.std_activation) =
let ok = Cduce.run ppf ppf input in let ok = Cduce.run ppf ppf input in
if ok then Format.fprintf ppf "@\nOk.@\n"; if ok then Format.fprintf ppf "@\nOk.@\n";
let res = Format.flush_str_formatter () in let res = Format.flush_str_formatter () in
p begin_table; p "<div class=\"box\"><h2>Results</h2><pre>";
p "<h2>Results</h2>"; cut (cgi # output # output_char) 80 res; p "</pre></div>";
p "<pre>"; cut (cgi # output # output_char) 80 res; p "</pre>";
p end_table;
if ok then (dialog ""; store_state ()) else dialog src; if ok then (dialog ""; store_state ()) else dialog src;
in in
...@@ -240,10 +267,8 @@ let main (cgi : Netcgi.std_activation) = ...@@ -240,10 +267,8 @@ let main (cgi : Netcgi.std_activation) =
Cduce.dump_env ppf; Cduce.dump_env ppf;
let res = Format.flush_str_formatter () in let res = Format.flush_str_formatter () in
p begin_table; p "<div class=\"box\"><h2>Current session environment</h2>";
p "<h2>Current session environment</h2>"; p ("<pre>" ^ res ^ "</pre></div>");
p ("<pre>" ^ res ^ "</pre>");
p end_table;
dialog src dialog src
in in
...@@ -260,21 +285,19 @@ let main (cgi : Netcgi.std_activation) = ...@@ -260,21 +285,19 @@ let main (cgi : Netcgi.std_activation) =
| `Close -> dialog "" | `Close -> dialog ""
| `Example -> dialog (example (cgi # argument_value "example")) | `Example -> dialog (example (cgi # argument_value "example"))
); );
p begin_table; p "
p "<h2>About the prototype</h2>"; <div class=\"box\"><h2>About the prototype</h2>
p "CDuce is under active development; some features may not work properly."; <p>
p "We are planning a beta release for the beginning of 2003. "; CDuce is under active development; some features may not work properly.
p "The prototype is written in "; We are planning a beta release for the beginning of 2003.
p "<a href='http://www.caml.inria.fr'>Objective Caml</a>, "; The prototype is written in
p "and uses several OCaml packages: "; <a href='http://www.caml.inria.fr'>Objective Caml</a>,
p "<a href='http://caml.inria.fr/camlp4'>Camlp4</a>, "; and uses several OCaml packages:
p "<a href='http://ocamlnet.sourceforge.net/'>OCamlnet</a>, "; <a href='http://caml.inria.fr/camlp4'>Camlp4</a>,
p "<a href='http://www.ocaml-programming.de/programming/pxp.html'>PXP</a>, "; <a href='http://ocamlnet.sourceforge.net/'>OCamlnet</a>,
p "<a href='http://www.eleves.ens.fr/home/frisch/soft#wlex'>wlex</a>."; <a href='http://www.ocaml-programming.de/programming/pxp.html'>PXP</a>,
p "<p>"; <a href='http://www.eleves.ens.fr/home/frisch/soft#wlex'>wlex</a>.</p>
p "<a href='mailto:Alain.Frisch@ens.fr'>Webmaster</a>"; <p><a href='mailto:Alain.Frisch@ens.fr'>Webmaster</a></p></div>";
p end_table;
html_footer p; html_footer p;
cgi # output # commit_work() cgi # output # commit_work()
with with
......
...@@ -78,7 +78,7 @@ let html_hilight ppf (i,j) = ...@@ -78,7 +78,7 @@ let html_hilight ppf (i,j) =
let i0 = beg_of_line s i in let i0 = beg_of_line s i in
let j0 = end_of_line s j in let j0 = end_of_line s j in
Format.fprintf ppf Format.fprintf ppf
"<i>%s<font color=red><b>%s</b></font>%s</i>@." "<i>%s<font color=\"red\"><b>%s</b></font>%s</i>@."
(extr s i0 i) (extr s i0 i)
(extr s i j) (extr s i j)
(extr s j j0) (extr s j j0)
......
...@@ -29,10 +29,10 @@ let string_of_xml v= ...@@ -29,10 +29,10 @@ let string_of_xml v=
let comment s = wms ("<!--" ^ s ^ "-->") let comment s = wms ("<!--" ^ s ^ "-->")
and write_att (n,v) = wms (" " ^ n ^ "=\""); wds v; wms "\"" in and write_att (n,v) = wms (" " ^ n ^ "=\""); wds v; wms "\"" in
let element_start name attrs = let element_start name attrs =
wms ("<" ^ name); List.iter write_att attrs; wms "\n>" wms ("<" ^ name); List.iter write_att attrs; wms ">"
and empty_element name attrs = and empty_element name attrs =
wms ("<" ^ name); List.iter write_att attrs; wms "/>" wms ("<" ^ name); List.iter write_att attrs; wms "/>"
and element_end name = wms ("</" ^ name ^ "\n>") and element_end name = wms ("</" ^ name ^ ">")
and document_start () = and document_start () =
(* wms ("<?xml version='1.0' encoding='" ^ (* wms ("<?xml version='1.0' encoding='" ^
Netconversion.string_of_encoding to_enc ^ Netconversion.string_of_encoding to_enc ^
......
...@@ -40,6 +40,9 @@ p { ...@@ -40,6 +40,9 @@ p {
text-align: justify; text-align: justify;
margin: 1ex 1em 0 1em; margin: 1ex 1em 0 1em;
} }
pre {
margin: 1ex 1em 0 1em;
}
div.abstract { div.abstract {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment