Commit 58b311ad authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-05-25 17:26:23 by cvscast] Doc

Original author: cvscast
Date: 2003-05-25 17:26:23+00:00
parent b9c7e1ea
...@@ -28,24 +28,24 @@ Overview of the distribution ...@@ -28,24 +28,24 @@ Overview of the distribution
See the INSTALL file for Installation instructions. See the INSTALL file for Installation instructions.
1. CDuce command-line interpreter 1. CDuce command-line interpreter / toplevel
For performance reasons, it is advised to build it using OCaml native code For performance reasons, it is advised to build it using OCaml native code
compiler (by default in the Makefile). compiler (by default in the Makefile).
Usage: Usage:
cduce [options] [CDuce files] -- [arguments for the CDuce program] cduce [options] [CDuce files] --arg [arguments for the CDuce program]
The arguments following the -- are passed to the CDuce program The arguments following the --arg are passed to the CDuce program
in the argv variable (having type [ String* ], which means: sequence in the argv variable (having type [ String* ], which means: sequence
of character strings). of character strings).
The option -quiet suppresses normal output (typing, results). It is The option --quiet suppresses normal output (typing, results). It is
normally used when the CDuce interpreter is used in the context normally used when the CDuce interpreter is used in the context
of batch processing. of batch processing.
The option -dump followed by a filename allows persistence between The option --dump followed by a filename allows persistence between
several invocations of the interpreter: the current environment several invocations of the interpreter: the current environment
(defined types and values) is saved to the file when the interpreter (defined types and values) is saved to the file when the interpreter
terminates and it is restored if the interpreter is started again with terminates and it is restored if the interpreter is started again with
...@@ -53,7 +53,10 @@ the same option. Note that only the arguments after -- on the first ...@@ -53,7 +53,10 @@ the same option. Note that only the arguments after -- on the first
invocation in a session are passed to the CDuce program. invocation in a session are passed to the CDuce program.
When no CDuce file is given on the command line, the interpreter When no CDuce file is given on the command line, the interpreter
uses the standard input. behaves as a toplevel. Phrases are interpreted when the user type
";;". Of course, mutually recursive definition (types or functions)
must be entirely contained in an adjacent sequence of phrases
(without ";;" inbetween).
2. CDuce CGI interface 2. CDuce CGI interface
......
...@@ -55,7 +55,6 @@ let read i = ...@@ -55,7 +55,6 @@ let read i =
flush stdout; flush stdout;
first_line := false; first_line := false;
let c = input_char stdin in let c = input_char stdin in
flush stderr;
bol := (not first) && c = '\n'; bol := (not first) && c = '\n';
Some c Some c
...@@ -68,7 +67,7 @@ let toploop () = ...@@ -68,7 +67,7 @@ let toploop () =
ignore (Cduce.toplevel ppf ppf_err input); ignore (Cduce.toplevel ppf ppf_err input);
loop () in loop () in
try loop () try loop ()
with End_of_file -> exit 0 with End_of_file -> ()
let do_file s = let do_file s =
let chan = open_in s in let chan = open_in s in
......
(* All the types submitted at once are mutually recursive *) (* Adjacent type declarations are mutually recursive *)
type T = <t>S;; type T = <t>S;;
type S = [ (Char | T)* ];; type S = [ (Char | T)* ];;
let x : S = [ 'abc' <t>['def'] 'ghi' ];; let x : S = [ 'abc' <t>['def'] 'ghi' ];;
(* Consecutive function definitions (without any other toplevel phrase (* Similarly for toplevel function definitions *)
in the middle) are grouped together *)
let fun f (x : Int) : Int = g x;; let fun f (x : Int) : Int = g x;;
let fun g (x : Int) : Int = 3;; let fun g (x : Int) : Int = 3;;
......
...@@ -40,11 +40,32 @@ CDuce program(s). </li> ...@@ -40,11 +40,32 @@ CDuce program(s). </li>
version number and exit immediately.</li> version number and exit immediately.</li>
<li>All the other arguments on the command line are considered CDuce <li>All the other arguments on the command line are considered CDuce
scripts, which are executed successively. If no CDuce file is given on scripts, which are executed successively.</li>
the command line, the interpreter uses the standard input. </li>
</ul> </ul>
</box> </box>
<box title="Toplevel" link="toplevel">
<p>
If no CDuce file is given on the command line, the interpreter
behaves as an interactive toplevel.
</p>
<p>
Toplevel phrases are processed after each <code>;;</code>.
Mutually recursive declaration of types or functions
must be contained in a single adjacent sequence of phrases
(without <code>;;</code> inbetween).
</p>
<p>
The toplevel has no line editing facilities.
You can use an external wrapper such as
<a href="http://pauillac.inria.fr/~ddr/">ledit</a>.
</p>
</box>
</page> </page>
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