Commit ada70ed1 authored by Pietro Abate's avatar Pietro Abate

[r2005-03-04 17:03:54 by afrisch] Need to link in OCaml units

Original author: afrisch
Date: 2005-03-04 17:05:34+00:00
parent 358b5d40
Beppe 2004-02-21
Write a config file in caml htat sets the variables of Makefile.conf
======================================================================
Beppe 2004-02-21
Write unix man page for validate and dtd2cduce.
Update man page for cduce
======================================================================
Beppe 2003-11-30
Add url support for non selfcontained documents and expat
======================================================================
Beppe 2003-11-15
Make a configure file so that
1. add the .exe suffix in case of
Cygwin environment. Also put complete path to the install command
(which otherwise under Cygwin calls the INSTALL file)
2. set NATIVE on the presence of ocamlopt
Beppe 2003-11-17
1. done
======================================================================
Beppe 2003-07-01
Ajouter des delimitateurs pour pouvoir ecrire du xml verbatim
zack propose """ """ moi je pensais {{ }}
======================================================================
Beppe 2003-01-17
Il faudrait que les tags soyent compatibles avec le standard XML
Name ::= (Letter | '_' | ':') (NameChar)*
NameChar ::= Letter | Digit | '.' | '-' | '_' | ':'
| CombiningChar | Extender
Donc en particulier au moins permettre _ et : comme debut de tag et . -
au milieu du tag
Alain 2003-05-15
En fait, il vaut mieux imposer les contraintes de Namespaces
(ie, au plus un : ).
C'est presque fait au niveau du lexer; il suffit de trouver une
syntaxe quand le source est en Latin1 pour mettre des charactères
non représentables dans les identificateurs/tags.
======================================================================
Alain 2003-01-20
Warning ou erreur pour une déclaration:
type T = ...
avec T==Empty
Ou alors, dès que l'on rencontre une expression de type vide ?
Regarder plus en general la section Error mining du Design paper
Alain 2003-05-15
Fait: détection des déclaration de type qui donnent un type vide
======================================================================
Beppe 2003-03-02
Add an operator random(n)
é
======================================================================
Beppe 2003-01-23
Add comparison operators for integers (< > >= <= ==) booleans
and ifthenelse
(Add floats????)
Alain 2003-05-15
Booléens: type Bool = `True | `False
if-then-else
Comparaison << >> = <= >= sur toutes les valeurs non-fonctionnelles
======================================================================
Beppe 2003-01-23
Add libraries inclusion
Alain 2003-03-16
Implemented source file inclusion as a temporary solution
======================================================================
Beppe 2003-01-23
Add the following types.
......@@ -138,91 +18,6 @@ Alain 2003-05-15
representation interne, on ne veut pas distinguer section CDATA, etc...
======================================================================
Alain 2003-03-16
Issue a warning for inclusion loops
Alain 2003-05-15
Done
======================================================================
Alain 2003-03-16
Pretty-printing (or at least decent-printing) of types
Decompilation of regexp
Detection of defined names
Alain 2003-06-17
Fait, il y a qq temps déjà
======================================================================
Zack 2003-05-08
Support for unary "-"
Alain 2005-05-15
Fait (pas très satisfaisant: a-b est un identificateur;
1-2 ne marche pas non plus; etc...)
======================================================================
Alain 2003-05-15
Terminer support pour Unicode:
load_xml charge représentation UTF-8; adapter print_xml
noms de tags et identificateurs en UTF-8 en interne
Alain 2003-06-17
Fait, il y a qq temps déjà
Il reste:
- donner la possibilité d'utiliser des identificateurs/tags
Unicode dans un source CDuce en Latin1
- source en UTF8 (ou autre)
Alain 2003-09-23
Avec le passage à ulex, on gagne la possibilité de changer
l'encoding du source
======================================================================
Alain 2003-05-15
Support pour namespaces.
Deux solutions: utiliser paires à la place des tags dans les
éléments XML, ou faire que les tags/atomes soient des paires.
Syntaxe pour déclarer des préfixes dans les sources.
Etudier les problèmes avec print_xml (ex: XHTML a besoin
d'avoir un prefixe bien défini...)
Alain 2003-09-23
Fait il y a longtemps.
======================================================================
Alain 2003-05-19
Noeud spécial dans l'AST pour les sequences et les chaines
(meilleurs messages d'erreurs + meilleure implémentation des chaines).
Alain 2003-06-17
Fait
======================================================================
Alain 2003-05-29
let fun f (...) ===> let f (...)
Alain 2003-06-17
Fait, il y a qq temps déjà
======================================================================
Alain 2004-01-22
......
#!/bin/sh
FLAGS=
LINK=
NATIVE=true
while true; do
case "$1" in
......@@ -11,23 +13,41 @@ while true; do
;;
-p)
FLAGS="$FLAGS -I `ocamlfind query $2`"
LINK="$LINK -package $2"
shift
shift
;;
-l)
LINK="$LINK $2"
shift
shift
;;
-byte)
NATIVE=false
shift
;;
*)
break
;;
esac
done
echo $FLAGS
TARG=$1
PRIMS=$2
if [ "${TARG}" = "" ] || [ "${PRIMS}" = "" ]; then
echo "Usage: cduce_mktop [(-I path | -p package) ...] <target> <primitive file>"
echo "Usage: cduce_mktop [(-I path | -p package | -l unit.cmo/cma/cmx/cmxa) ...] <target> <primitive file>"
exit 2
fi
exec ocamlfind ocamlc -package cduce -o $TARG -linkpkg -pp "mlcduce_wrapper $FLAGS" -impl $PRIMS
if [ ${NATIVE} = "true" ]; then
CAML=ocamlopt
else
CAML=ocamlc
fi
echo "Effective flags for CDuce: $FLAGS"
echo "Effective flags for OCaml: $LINK"
exec ocamlfind $CAML -package cduce -o $TARG $FLAGS -linkpkg -pp "mlcduce_wrapper $FLAGS" $LINK -impl $PRIMS
......@@ -53,6 +53,7 @@ and typ_descr = function
| Builtin ("Cduce_lib.Value.t", []) -> Types.any
| Builtin ("Cduce_lib.Encodings.Utf8.t", []) -> Builtin_defs.string
| Builtin ("unit", []) -> Sequence.nil_type
| Builtin ("option", [t]) -> Sequence.option (typ t)
| Var i -> Types.descr (!vars).(i)
| _ -> assert false
......@@ -296,6 +297,9 @@ and to_cd_descr e = function
<:expr< Value.ocaml2cduce_string_utf8 $e$ >>
| Builtin ("unit", []) -> <:expr< do { $e$; Value.nil } >>
| Var _ -> e
| Builtin ("option", [t]) ->
<:expr< Value.ocaml2cduce_option $lid:to_cd_fun t$ $e$ >>
| _ -> assert false
and tuple_to_cd tl vars = List.map2 (fun t id -> to_cd <:expr< $lid:id$ >> t) tl vars
......@@ -420,6 +424,8 @@ and to_ml_descr e = function
| Builtin ("Cduce_lib.Encodings.Utf8.t", []) ->
<:expr< Value.cduce2ocaml_string_utf8 $e$ >>
| Builtin ("unit", []) -> <:expr< ignore $e$ >>
| Builtin ("option", [t]) ->
<:expr< Value.cduce2ocaml_option $lid:to_ml_fun t$ $e$ >>
| Var _ -> e
| _ -> assert false
......@@ -571,7 +577,7 @@ let register b s args =
let wrapper values =
gen_types := false;
let exts = List.rev_map
(fun (s,t) ->
(fun (s,t) ->
let v = to_cd <:expr< $lid:s$ >> t in
<:str_item<
Librarian.register_static_external $str:String.escaped s$ $v$ >>)
......
......@@ -86,6 +86,7 @@ let builtins =
"list"; "Pervasives.ref";
"unit"; "array";
"Big_int.big_int";
"option";
"Cduce_lib.Value.t"; "Cduce_lib.Encodings.Utf8.t"
]
......@@ -204,9 +205,13 @@ let load_cmi name =
List.fold_left
(fun accu v -> match v with
| Tsig_value (id,_) ->
let n = name ^ "." ^ (Ident.name id) in
(try (n, (fst (find_value n))) :: accu
with PolyAbstract _ -> accu)
let id = Ident.name id in
(match id.[0] with
| 'a'..'z' | '_' ->
let n = name ^ "." ^ id in
(try (n, (fst (find_value n))) :: accu
with PolyAbstract _ -> accu)
| _ -> accu (* operator *))
| _ -> accu
) [] sg
......
......@@ -652,3 +652,16 @@ let print_utf8 v =
let float n =
Abstract (Builtin_defs.float_abs, Obj.repr n)
let cduce2ocaml_option f v =
match normalize v with
| Pair (x,y) -> Some (f x)
| _ -> None
let ocaml2cduce_option f = function
| Some x -> Pair (f x, nil)
| None -> nil
......@@ -119,7 +119,8 @@ val ocaml2cduce_char : char -> t
val cduce2ocaml_char : t -> char
val ocaml2cduce_bigint : Big_int.big_int -> t
val cduce2ocaml_bigint : t -> Big_int.big_int
val ocaml2cduce_option: ('a -> t) -> 'a option -> t
val cduce2ocaml_option: (t -> 'a) -> t -> 'a option
val print_utf8: U.t -> unit
......@@ -65,6 +65,9 @@ let star t = Types.descr (star_node (Types.cons t))
let plus t = let t = Types.cons t in Types.times t (star_node t)
let string = star (Types.Char.any)
let option t =
Types.cup (Types.times t nil_node) nil_type
let repet min max t =
let t = Types.cons t in
let tail = match max with
......
......@@ -19,6 +19,8 @@ val map_tree:
val star: Types.t -> Types.t
(* For a type t, returns [t*] *)
val plus: Types.t -> Types.t
val option: Types.Node.t -> Types.t
(* returns [t?] *)
val repet: int -> int option -> Types.t -> Types.t
(* min, max *)
......
......@@ -59,7 +59,7 @@ Basic OCaml types <code>char</code>, <code>int</code>, <code>string</code>,
Tuple types <code>%%t%%1 * ... * %%t%%n</code> are translated to nested CDuce
product types <code>(T(%%t%%1),(...,T(%%t%%n))...)</code>. A function type
<code>%%t%% -> %%s%%</code> is translated to <code>T(%%t%%) -> T(%%s%%)</code>.
Labels and optional labels on the argument of the arrow are discarded.
Labels on the argument of the arrow are discarded.
</li>
<li>
......@@ -68,6 +68,11 @@ sequence type <code>[ T(%%t%%)* ]</code>. An array type
<code>%%t%% array</code> has the same translation.
</li>
<li>
A option type <code>%%t%% option</code> is translated to
the type <code>[ T(%%t%%)? ]</code>.
</li>
<li>
A variant type with a declaration <code>A1 of %%t%%1 | ... | An of
%%t%%n</code> is translated to a type <code>(`A1,T(%%t%%1)) | ... |
......@@ -145,6 +150,9 @@ The canonical translation is summarized in the following box:
<tr><td><tt><i>t</i> array</tt></td>
<td><tt>[ T(<i>t</i>)* ]</tt></td></tr>
<tr><td><tt><i>t</i> option</tt></td>
<td><tt>[ T(<i>t</i>)? ]</tt></td></tr>
<tr><td><tt>A of <i>t</i> | B of <i>s</i> | C</tt></td>
<td><tt>(`A, T(<i>t</i>)) | (`B, T(<i>s</i>)) | `C</tt></td></tr>
......@@ -362,7 +370,7 @@ toplevel with built-in support for some OCaml modules / functions.
</p>
<sample>
cduce_mktop [-I path | -p package ... ] [target] [primitive file]
cduce_mktop [-I path | -p package | -l unit ... | -byte ] [target] [primitive file]
</sample>
<p>
......@@ -374,12 +382,18 @@ the name of an OCaml unit (like <code>List</code>). Empty lines
and lines starting with a sharp character are ignored.
</p>
<p>
The <code>-byte</code> flag forces the creation of the bytecode
version of the toplevel (by defaut, the toplevel is produced with ocamlopt).
</p>
<p>
The leading <code>-I</code> options enrich the search path for OCaml
units. The <code>-p</code> options serves a similar purpose; their
arguments are findlib package names. All these paths are included
in the produced toplevel.
in the produced toplevel. The <code>-l</code> options give
the OCaml units to be linked in (e.g. <code>x.cmx</code> or
<code>x.cmxa</code>)(the <code>-p</code> option automatically
include the units).
</p>
<p>
In a custom toplevel, the directive <code>#builtins</code> prints the name
of embedded OCaml values.
......
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