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

[r2003-10-07 19:36:59 by cvscast] Broutilles

Original author: cvscast
Date: 2003-10-07 19:37:00+00:00
parent 4c112fc2
...@@ -18,7 +18,7 @@ ocaml => 3.07 ...@@ -18,7 +18,7 @@ ocaml => 3.07
findlib findlib
http://www.ocaml-programming.de/packages http://www.ocaml-programming.de/packages
ulex ulex
http://www.cduce.org/download/ulex-0.2.tar.gz http://www.cduce.org/download
pcre-ocaml pcre-ocaml
http://www.ai.univie.ac.at/~markus/home/ocaml_sources.html http://www.ai.univie.ac.at/~markus/home/ocaml_sources.html
ocamlnet ocamlnet
...@@ -26,26 +26,22 @@ ocamlnet ...@@ -26,26 +26,22 @@ ocamlnet
pxp => 1.9.93 pxp => 1.9.93
http://www.ocaml-programming.de/packages/documentation/pxp/index_dev.html http://www.ocaml-programming.de/packages/documentation/pxp/index_dev.html
Important notes: Important notes:
- Ocaml: cduce uses recursive modules so versions of ocaml before 3.07 - OCaml: cduce uses recursive modules so versions of OCaml before 3.07
will not work. Also the standard distributions has two bugs that make will not work. Also the standard distribution has two bugs that make
cduce compilation fail. Patch ocaml source by CDuce compilation fail. Patch OCaml source by
http://caml.inria.fr/bin/caml-bugs/fixed?id=1863;page=77;user=guest http://caml.inria.fr/bin/caml-bugs/fixed?id=1863;page=77;user=guest
http://www.cduce.org/download/patch-ocaml-3.07 http://www.cduce.org/download/patch-ocaml-3.07
or (better) install ocaml cvs version or (better) install OCaml cvs version
cvs -d":pserver:anoncvs@camlcvs.inria.fr:/caml" login cvs -d":pserver:anoncvs@camlcvs.inria.fr:/caml" login
hit enter key when asked for password hit enter key when asked for password
cvs -d":pserver:anoncvs@camlcvs.inria.fr:/caml" co ocaml cvs -d":pserver:anoncvs@camlcvs.inria.fr:/caml" co ocaml
- the packages above must be installed in the order we used above. In
particular ulex _must_ be installed before pcre-ocaml and pxp.
- pcre-ocaml: you may also need to install the PCRE library - pcre-ocaml: you may also need to install the PCRE library
from http://www.pcre.org/ [red-hat users, 4.3 package does from http://www.pcre.org/ [red-hat users: 4.3 package does
not work with the latest pcre-ocaml version, use tarballs] not work with the latest pcre-ocaml version, use tarballs]
>= 5.03 recommended but previous versions may work >= 5.03 recommended but previous versions may work
...@@ -105,6 +101,8 @@ PXP_WLEX=true : use wlex for parsing UTF-8 XML files ...@@ -105,6 +101,8 @@ PXP_WLEX=true : use wlex for parsing UTF-8 XML files
PXP_WLEX=false: use ocamllex for parsing UTF-8 XML files PXP_WLEX=false: use ocamllex for parsing UTF-8 XML files
default: false (ocamllex is faster; wlex is more compact) default: false (ocamllex is faster; wlex is more compact)
EXPAT=true: build expat support (see below)
PREFIX=/usr/local by default: where to install CDuce files (see PREFIX=/usr/local by default: where to install CDuce files (see
Makefile.conf) Makefile.conf)
...@@ -117,21 +115,18 @@ You can also modify Makefile.conf to set values for these choices. ...@@ -117,21 +115,18 @@ You can also modify Makefile.conf to set values for these choices.
Support for the expat parser Support for the expat parser
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
This release includes an experimental support for the expat XML CDuce can uses two XML parsers: PXP and expat. PXP is needed
parser, using the OCaml wrapper written by Maas-Maarten Zeeman, and to build CDuce, and expat support can be additionnaly added.
included in the expat/ subdirectory for convenience (see Here is how to do so.
expat/README).
If you have the expat C library installed, you can build You need to install the expat C library and the OCaml wrapper.
the OCaml wrapper: The wrapper can be found at:
cd expat http://home.wanadoo.nl/maas/ocaml/
make all (* may need to modify Makefile.conf *)
make install (* may require root privileges *)
cd ..
Then set EXPAT=true in Makefile.conf, and rebuild CDuce Once the wrapper and be installed, you can build CDuce with
(make clean && make all). the Makefile option EXPAT=true (which can be set on make command
line or in Makefile.conf).
The interpreter is now using expat for loading XML files. The interpreter is now using expat for loading XML files.
You can still use PXP by providing the --pxp switch on the command You can still use PXP by providing the --pxp switch on the command
...@@ -140,5 +135,3 @@ line. ...@@ -140,5 +135,3 @@ line.
Note: the current wrapper for expat does not support inclusion Note: the current wrapper for expat does not support inclusion
of external entities. Moreover, the error messages in case of of external entities. Moreover, the error messages in case of
ill-formed XML are less informative than PXP's. ill-formed XML are less informative than PXP's.
...@@ -8,7 +8,7 @@ else ...@@ -8,7 +8,7 @@ else
PACKAGES += pxp-lex-utf8 PACKAGES += pxp-lex-utf8
endif endif
SYNTAX = -I misc/ pa_extend.cmo q_symbol.cmo \ SYNTAX = -I misc/ q_symbol.cmo \
-symbol cduce_version=\"$(VERSION)\" \ -symbol cduce_version=\"$(VERSION)\" \
-symbol build_date=\"$(shell date +%Y-%m-%d)\" \ -symbol build_date=\"$(shell date +%Y-%m-%d)\" \
-symbol session_dir=\"$(SESSION_DIR)\" -symbol session_dir=\"$(SESSION_DIR)\"
......
...@@ -8,6 +8,19 @@ type env = { ...@@ -8,6 +8,19 @@ type env = {
let empty = { vars = Env.empty; stack_size = 0 } let empty = { vars = Env.empty; stack_size = 0 }
let serialize s env =
Serialize.Put.env Id.serialize Lambda.Put.var_loc Env.iter s env.vars;
Serialize.Put.int s env.stack_size
let deserialize s =
let vars =
Serialize.Get.env Id.deserialize Lambda.Get.var_loc Env.add Env.empty s in
let size = Serialize.Get.int s in
{ vars = vars; stack_size = size }
let find x env = let find x env =
try Env.find x env.vars try Env.find x env.vars
with Not_found -> with Not_found ->
......
...@@ -28,8 +28,8 @@ types/ident.cmo: misc/q_symbol.cmo misc/encodings.cmi misc/ns.cmi misc/pool.cmi ...@@ -28,8 +28,8 @@ types/ident.cmo: misc/q_symbol.cmo misc/encodings.cmi misc/ns.cmi misc/pool.cmi
types/sortedList.cmi types/sortedList.cmi
types/ident.cmx: misc/q_symbol.cmo misc/encodings.cmx misc/ns.cmx misc/pool.cmx \ types/ident.cmx: misc/q_symbol.cmo misc/encodings.cmx misc/ns.cmx misc/pool.cmx \
types/sortedList.cmx types/sortedList.cmx
types/intervals.cmo: misc/q_symbol.cmo misc/custom.cmo misc/serialize.cmi types/intervals.cmi types/intervals.cmo: misc/q_symbol.cmo misc/serialize.cmi types/intervals.cmi
types/intervals.cmx: misc/q_symbol.cmo misc/custom.cmx misc/serialize.cmx types/intervals.cmi types/intervals.cmx: misc/q_symbol.cmo misc/serialize.cmx types/intervals.cmi
types/chars.cmo: misc/q_symbol.cmo misc/custom.cmo types/chars.cmi types/chars.cmo: misc/q_symbol.cmo misc/custom.cmo types/chars.cmi
types/chars.cmx: misc/q_symbol.cmo misc/custom.cmx types/chars.cmi types/chars.cmx: misc/q_symbol.cmo misc/custom.cmx types/chars.cmi
types/atoms.cmo: misc/q_symbol.cmo misc/custom.cmo misc/encodings.cmi misc/ns.cmi misc/pool.cmi \ types/atoms.cmo: misc/q_symbol.cmo misc/custom.cmo misc/encodings.cmi misc/ns.cmi misc/pool.cmi \
...@@ -115,17 +115,17 @@ typing/typed.cmo: misc/q_symbol.cmo types/ident.cmo parser/location.cmi types/pa ...@@ -115,17 +115,17 @@ typing/typed.cmo: misc/q_symbol.cmo types/ident.cmo parser/location.cmi types/pa
typing/typed.cmx: misc/q_symbol.cmo types/ident.cmx parser/location.cmx types/patterns.cmx \ typing/typed.cmx: misc/q_symbol.cmo types/ident.cmx parser/location.cmx types/patterns.cmx \
types/types.cmx types/types.cmx
typing/typer.cmo: misc/q_symbol.cmo parser/ast.cmo types/atoms.cmi types/builtin_defs.cmi \ typing/typer.cmo: misc/q_symbol.cmo parser/ast.cmo types/atoms.cmi types/builtin_defs.cmi \
types/chars.cmi misc/custom.cmo types/ident.cmo parser/location.cmi \ types/chars.cmi types/ident.cmo parser/location.cmi misc/ns.cmi \
misc/ns.cmi types/patterns.cmi schema/schema_builtin.cmi \ types/patterns.cmi schema/schema_builtin.cmi schema/schema_types.cmi \
schema/schema_types.cmi schema/schema_validator.cmi types/sequence.cmi \ schema/schema_validator.cmi types/sequence.cmi misc/serialize.cmi \
misc/serialize.cmi misc/state.cmi misc/stats.cmi typing/typed.cmo \ misc/state.cmi misc/stats.cmi typing/typed.cmo types/types.cmi \
types/types.cmi typing/typer.cmi typing/typer.cmi
typing/typer.cmx: misc/q_symbol.cmo parser/ast.cmx types/atoms.cmx types/builtin_defs.cmx \ typing/typer.cmx: misc/q_symbol.cmo parser/ast.cmx types/atoms.cmx types/builtin_defs.cmx \
types/chars.cmx misc/custom.cmx types/ident.cmx parser/location.cmx \ types/chars.cmx types/ident.cmx parser/location.cmx misc/ns.cmx \
misc/ns.cmx types/patterns.cmx schema/schema_builtin.cmx \ types/patterns.cmx schema/schema_builtin.cmx schema/schema_types.cmx \
schema/schema_types.cmx schema/schema_validator.cmx types/sequence.cmx \ schema/schema_validator.cmx types/sequence.cmx misc/serialize.cmx \
misc/serialize.cmx misc/state.cmx misc/stats.cmx typing/typed.cmx \ misc/state.cmx misc/stats.cmx typing/typed.cmx types/types.cmx \
types/types.cmx typing/typer.cmi typing/typer.cmi
compile/lambda.cmo: misc/q_symbol.cmo types/ident.cmo types/patterns.cmi misc/serialize.cmi \ compile/lambda.cmo: misc/q_symbol.cmo types/ident.cmo types/patterns.cmi misc/serialize.cmi \
types/types.cmi types/types.cmi
compile/lambda.cmx: misc/q_symbol.cmo types/ident.cmx types/patterns.cmx misc/serialize.cmx \ compile/lambda.cmx: misc/q_symbol.cmo types/ident.cmx types/patterns.cmx misc/serialize.cmx \
...@@ -158,12 +158,12 @@ runtime/eval.cmx: misc/q_symbol.cmo types/builtin_defs.cmx types/ident.cmx compi ...@@ -158,12 +158,12 @@ runtime/eval.cmx: misc/q_symbol.cmo types/builtin_defs.cmx types/ident.cmx compi
types/patterns.cmx runtime/run_dispatch.cmx schema/schema_validator.cmx \ types/patterns.cmx runtime/run_dispatch.cmx schema/schema_validator.cmx \
schema/schema_xml.cmx types/sequence.cmx typing/typed.cmx \ schema/schema_xml.cmx types/sequence.cmx typing/typed.cmx \
typing/typer.cmx types/types.cmx runtime/value.cmx runtime/eval.cmi typing/typer.cmx types/types.cmx runtime/value.cmx runtime/eval.cmi
compile/compile.cmo: misc/q_symbol.cmo parser/ast.cmo types/builtin.cmi types/ident.cmo \ compile/compile.cmo: misc/q_symbol.cmo parser/ast.cmo types/ident.cmo compile/lambda.cmo \
compile/lambda.cmo parser/location.cmi types/patterns.cmi \ parser/location.cmi types/patterns.cmi typing/typed.cmo typing/typer.cmi \
typing/typed.cmo typing/typer.cmi types/types.cmi compile/compile.cmi types/types.cmi compile/compile.cmi
compile/compile.cmx: misc/q_symbol.cmo parser/ast.cmx types/builtin.cmx types/ident.cmx \ compile/compile.cmx: misc/q_symbol.cmo parser/ast.cmx types/ident.cmx compile/lambda.cmx \
compile/lambda.cmx parser/location.cmx types/patterns.cmx \ parser/location.cmx types/patterns.cmx typing/typed.cmx typing/typer.cmx \
typing/typed.cmx typing/typer.cmx types/types.cmx compile/compile.cmi types/types.cmx compile/compile.cmi
compile/operators.cmo: misc/q_symbol.cmo misc/custom.cmo runtime/eval.cmi compile/lambda.cmo \ compile/operators.cmo: misc/q_symbol.cmo misc/custom.cmo runtime/eval.cmi compile/lambda.cmo \
parser/location.cmi misc/pool.cmi typing/typer.cmi types/types.cmi \ parser/location.cmi misc/pool.cmi typing/typer.cmi types/types.cmi \
runtime/value.cmi compile/operators.cmi runtime/value.cmi compile/operators.cmi
...@@ -181,15 +181,17 @@ types/builtin.cmx: misc/q_symbol.cmo types/atoms.cmx types/builtin_defs.cmx type ...@@ -181,15 +181,17 @@ types/builtin.cmx: misc/q_symbol.cmo types/atoms.cmx types/builtin_defs.cmx type
runtime/print_xml.cmx types/sequence.cmx typing/typer.cmx types/types.cmx \ runtime/print_xml.cmx types/sequence.cmx typing/typer.cmx types/types.cmx \
runtime/value.cmx types/builtin.cmi runtime/value.cmx types/builtin.cmi
driver/cduce.cmo: misc/q_symbol.cmo parser/ast.cmo types/builtin.cmi compile/compile.cmi \ driver/cduce.cmo: misc/q_symbol.cmo parser/ast.cmo types/builtin.cmi compile/compile.cmi \
runtime/eval.cmi runtime/explain.cmi types/ident.cmo parser/location.cmi \ runtime/eval.cmi runtime/explain.cmi types/ident.cmo compile/lambda.cmo \
misc/ns.cmi parser/parser.cmi types/patterns.cmi types/sample.cmi \ parser/location.cmi misc/ns.cmi parser/parser.cmi types/patterns.cmi \
misc/state.cmi typing/typed.cmo typing/typer.cmi types/types.cmi \ types/sample.cmi types/sequence.cmi misc/serialize.cmi misc/state.cmi \
parser/ulexer.cmi runtime/value.cmi driver/cduce.cmi typing/typed.cmo typing/typer.cmi types/types.cmi parser/ulexer.cmi \
runtime/value.cmi driver/cduce.cmi
driver/cduce.cmx: misc/q_symbol.cmo parser/ast.cmx types/builtin.cmx compile/compile.cmx \ driver/cduce.cmx: misc/q_symbol.cmo parser/ast.cmx types/builtin.cmx compile/compile.cmx \
runtime/eval.cmx runtime/explain.cmx types/ident.cmx parser/location.cmx \ runtime/eval.cmx runtime/explain.cmx types/ident.cmx compile/lambda.cmx \
misc/ns.cmx parser/parser.cmx types/patterns.cmx types/sample.cmx \ parser/location.cmx misc/ns.cmx parser/parser.cmx types/patterns.cmx \
misc/state.cmx typing/typed.cmx typing/typer.cmx types/types.cmx \ types/sample.cmx types/sequence.cmx misc/serialize.cmx misc/state.cmx \
parser/ulexer.cmx runtime/value.cmx driver/cduce.cmi typing/typed.cmx typing/typer.cmx types/types.cmx parser/ulexer.cmx \
runtime/value.cmx driver/cduce.cmi
driver/run.cmo: misc/q_symbol.cmo driver/cduce.cmi types/ident.cmo runtime/load_xml.cmi \ driver/run.cmo: misc/q_symbol.cmo driver/cduce.cmi types/ident.cmo runtime/load_xml.cmi \
parser/location.cmi types/sequence.cmi misc/state.cmi misc/stats.cmi \ parser/location.cmi types/sequence.cmi misc/state.cmi misc/stats.cmi \
parser/ulexer.cmi runtime/value.cmi parser/ulexer.cmi runtime/value.cmi
......
...@@ -82,6 +82,10 @@ module Put = struct ...@@ -82,6 +82,10 @@ module Put = struct
let pair f1 f2 t (x,y) = f1 t x; f2 t y let pair f1 f2 t (x,y) = f1 t x; f2 t y
let env f1 f2 it t arg =
it (fun x y -> bool t true; f1 t x; f2 t y) arg;
bool t false
end end
...@@ -170,6 +174,14 @@ module Get = struct ...@@ -170,6 +174,14 @@ module Get = struct
let x = f1 t in let x = f1 t in
let y = f2 t in let y = f2 t in
(x,y) (x,y)
let rec env f1 f2 add init t =
if bool t then
let x = f1 t in
let y = f2 t in
env f1 f2 add (add x y init) t
else
init
end end
......
...@@ -9,6 +9,7 @@ module Put : sig ...@@ -9,6 +9,7 @@ module Put : sig
val substring: t -> string -> int -> int -> unit val substring: t -> string -> int -> int -> unit
val magic: t -> string -> unit val magic: t -> string -> unit
val bool: bool f val bool: bool f
val env: 'a f -> 'b f -> (('a -> 'b -> unit) -> 'c -> unit) -> 'c f
val list: 'a f -> 'a list f val list: 'a f -> 'a list f
val array: 'a f -> 'a array f val array: 'a f -> 'a array f
...@@ -35,6 +36,8 @@ module Get : sig ...@@ -35,6 +36,8 @@ module Get : sig
val array: 'a f -> 'a array f val array: 'a f -> 'a array f
val pair: 'a f -> 'b f -> ('a * 'b) f val pair: 'a f -> 'b f -> ('a * 'b) f
val magic: t -> string -> unit val magic: t -> string -> unit
val env: 'a f -> 'b f -> ('a -> 'b -> 'c -> 'c) -> 'c -> 'c f
type 'b property type 'b property
val mk_property: (t -> 'b) -> 'b property val mk_property: (t -> 'b) -> 'b property
......
#load "pa_extend.cmo";;
open Location open Location
open Ast open Ast
open Ident open Ident
......
...@@ -30,37 +30,22 @@ let equal _ _ = failwith "Typer.equal" ...@@ -30,37 +30,22 @@ let equal _ _ = failwith "Typer.equal"
let check _ = failwith "Typer.check" let check _ = failwith "Typer.check"
(* TODO: filter out builtin defs ? *) (* TODO: filter out builtin defs ? *)
let serialize_item s = function
| Type t -> Serialize.Put.bits 1 s 0; Types.serialize s t
| Val t -> Serialize.Put.bits 1 s 1; Types.serialize s t
let serialize s env = let serialize s env =
Env.iter Serialize.Put.env Id.serialize serialize_item Env.iter s env.ids;
(fun id item ->
match item with
| Type t ->
Serialize.Put.bits 2 s 0b01;
Id.serialize s id;
Types.serialize s t
| Val t ->
Serialize.Put.bits 2 s 0b10;
Id.serialize s id;
Types.serialize s t
) env.ids;
Serialize.Put.bits 2 s 0b00;
Ns.serialize_table s env.tenv_nspref Ns.serialize_table s env.tenv_nspref
let deserialize_item s = match Serialize.Get.bits 1 s with
| 0 -> Type (Types.deserialize s)
| 1 -> Val (Types.deserialize s)
| _ -> assert false
let deserialize s = let deserialize s =
let rec aux env = let ids =
match Serialize.Get.bits 2 s with Serialize.Get.env Id.deserialize deserialize_item Env.add Env.empty s in
| 0b00 -> env
| 0b01 ->
let id = Id.deserialize s in
let t = Types.deserialize s in
aux (Env.add id (Type t) env)
| 0b10 ->
let id = Id.deserialize s in
let t = Types.deserialize s in
aux (Env.add id (Val t) env)
| _ -> assert false
in
let ids = aux Env.empty in
let ns = Ns.deserialize_table s in let ns = Ns.deserialize_table s in
{ ids = ids; tenv_nspref = ns } { ids = ids; tenv_nspref = ns }
......
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