Commit a81955f8 authored by Pietro Abate's avatar Pietro Abate

[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
findlib
http://www.ocaml-programming.de/packages
ulex
http://www.cduce.org/download/ulex-0.2.tar.gz
http://www.cduce.org/download
pcre-ocaml
http://www.ai.univie.ac.at/~markus/home/ocaml_sources.html
ocamlnet
......@@ -26,26 +26,22 @@ ocamlnet
pxp => 1.9.93
http://www.ocaml-programming.de/packages/documentation/pxp/index_dev.html
Important notes:
- Ocaml: cduce uses recursive modules so versions of ocaml before 3.07
will not work. Also the standard distributions has two bugs that make
cduce compilation fail. Patch ocaml source by
- OCaml: cduce uses recursive modules so versions of OCaml before 3.07
will not work. Also the standard distribution has two bugs that make
CDuce compilation fail. Patch OCaml source by
http://caml.inria.fr/bin/caml-bugs/fixed?id=1863;page=77;user=guest
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
hit enter key when asked for password
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
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]
>= 5.03 recommended but previous versions may work
......@@ -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
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
Makefile.conf)
......@@ -117,21 +115,18 @@ You can also modify Makefile.conf to set values for these choices.
Support for the expat parser
------------------------------------------------------------------------------
This release includes an experimental support for the expat XML
parser, using the OCaml wrapper written by Maas-Maarten Zeeman, and
included in the expat/ subdirectory for convenience (see
expat/README).
CDuce can uses two XML parsers: PXP and expat. PXP is needed
to build CDuce, and expat support can be additionnaly added.
Here is how to do so.
If you have the expat C library installed, you can build
the OCaml wrapper:
You need to install the expat C library and the OCaml wrapper.
The wrapper can be found at:
cd expat
make all (* may need to modify Makefile.conf *)
make install (* may require root privileges *)
cd ..
http://home.wanadoo.nl/maas/ocaml/
Then set EXPAT=true in Makefile.conf, and rebuild CDuce
(make clean && make all).
Once the wrapper and be installed, you can build CDuce with
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.
You can still use PXP by providing the --pxp switch on the command
......@@ -140,5 +135,3 @@ line.
Note: the current wrapper for expat does not support inclusion
of external entities. Moreover, the error messages in case of
ill-formed XML are less informative than PXP's.
......@@ -8,7 +8,7 @@ else
PACKAGES += pxp-lex-utf8
endif
SYNTAX = -I misc/ pa_extend.cmo q_symbol.cmo \
SYNTAX = -I misc/ q_symbol.cmo \
-symbol cduce_version=\"$(VERSION)\" \
-symbol build_date=\"$(shell date +%Y-%m-%d)\" \
-symbol session_dir=\"$(SESSION_DIR)\"
......
......@@ -8,6 +8,19 @@ type env = {
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 =
try Env.find x env.vars
with Not_found ->
......
......@@ -28,8 +28,8 @@ types/ident.cmo: misc/q_symbol.cmo misc/encodings.cmi misc/ns.cmi misc/pool.cmi
types/sortedList.cmi
types/ident.cmx: misc/q_symbol.cmo misc/encodings.cmx misc/ns.cmx misc/pool.cmx \
types/sortedList.cmx
types/intervals.cmo: misc/q_symbol.cmo misc/custom.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.cmo: misc/q_symbol.cmo misc/serialize.cmi 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.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 \
......@@ -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 \
types/types.cmx
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 \
misc/ns.cmi types/patterns.cmi schema/schema_builtin.cmi \
schema/schema_types.cmi schema/schema_validator.cmi types/sequence.cmi \
misc/serialize.cmi misc/state.cmi misc/stats.cmi typing/typed.cmo \
types/types.cmi typing/typer.cmi
types/chars.cmi types/ident.cmo parser/location.cmi misc/ns.cmi \
types/patterns.cmi schema/schema_builtin.cmi schema/schema_types.cmi \
schema/schema_validator.cmi types/sequence.cmi misc/serialize.cmi \
misc/state.cmi misc/stats.cmi typing/typed.cmo types/types.cmi \
typing/typer.cmi
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 \
misc/ns.cmx types/patterns.cmx schema/schema_builtin.cmx \
schema/schema_types.cmx schema/schema_validator.cmx types/sequence.cmx \
misc/serialize.cmx misc/state.cmx misc/stats.cmx typing/typed.cmx \
types/types.cmx typing/typer.cmi
types/chars.cmx types/ident.cmx parser/location.cmx misc/ns.cmx \
types/patterns.cmx schema/schema_builtin.cmx schema/schema_types.cmx \
schema/schema_validator.cmx types/sequence.cmx misc/serialize.cmx \
misc/state.cmx misc/stats.cmx typing/typed.cmx types/types.cmx \
typing/typer.cmi
compile/lambda.cmo: misc/q_symbol.cmo types/ident.cmo types/patterns.cmi misc/serialize.cmi \
types/types.cmi
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
types/patterns.cmx runtime/run_dispatch.cmx schema/schema_validator.cmx \
schema/schema_xml.cmx types/sequence.cmx typing/typed.cmx \
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/lambda.cmo parser/location.cmi types/patterns.cmi \
typing/typed.cmo typing/typer.cmi types/types.cmi compile/compile.cmi
compile/compile.cmx: misc/q_symbol.cmo parser/ast.cmx types/builtin.cmx types/ident.cmx \
compile/lambda.cmx parser/location.cmx types/patterns.cmx \
typing/typed.cmx typing/typer.cmx types/types.cmx compile/compile.cmi
compile/compile.cmo: misc/q_symbol.cmo parser/ast.cmo types/ident.cmo compile/lambda.cmo \
parser/location.cmi types/patterns.cmi typing/typed.cmo typing/typer.cmi \
types/types.cmi compile/compile.cmi
compile/compile.cmx: misc/q_symbol.cmo parser/ast.cmx types/ident.cmx compile/lambda.cmx \
parser/location.cmx types/patterns.cmx typing/typed.cmx typing/typer.cmx \
types/types.cmx compile/compile.cmi
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 \
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
runtime/print_xml.cmx types/sequence.cmx typing/typer.cmx types/types.cmx \
runtime/value.cmx types/builtin.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 \
misc/ns.cmi parser/parser.cmi types/patterns.cmi types/sample.cmi \
misc/state.cmi typing/typed.cmo typing/typer.cmi types/types.cmi \
parser/ulexer.cmi runtime/value.cmi driver/cduce.cmi
runtime/eval.cmi runtime/explain.cmi types/ident.cmo compile/lambda.cmo \
parser/location.cmi misc/ns.cmi parser/parser.cmi types/patterns.cmi \
types/sample.cmi types/sequence.cmi misc/serialize.cmi misc/state.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 \
runtime/eval.cmx runtime/explain.cmx types/ident.cmx parser/location.cmx \
misc/ns.cmx parser/parser.cmx types/patterns.cmx types/sample.cmx \
misc/state.cmx typing/typed.cmx typing/typer.cmx types/types.cmx \
parser/ulexer.cmx runtime/value.cmx driver/cduce.cmi
runtime/eval.cmx runtime/explain.cmx types/ident.cmx compile/lambda.cmx \
parser/location.cmx misc/ns.cmx parser/parser.cmx types/patterns.cmx \
types/sample.cmx types/sequence.cmx misc/serialize.cmx misc/state.cmx \
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 \
parser/location.cmi types/sequence.cmi misc/state.cmi misc/stats.cmi \
parser/ulexer.cmi runtime/value.cmi
......
......@@ -82,6 +82,10 @@ module Put = struct
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
......@@ -170,6 +174,14 @@ module Get = struct
let x = f1 t in
let y = f2 t in
(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
......
......@@ -9,6 +9,7 @@ module Put : sig
val substring: t -> string -> int -> int -> unit
val magic: t -> string -> unit
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 array: 'a f -> 'a array f
......@@ -35,6 +36,8 @@ module Get : sig
val array: 'a f -> 'a array f
val pair: 'a f -> 'b f -> ('a * 'b) f
val magic: t -> string -> unit
val env: 'a f -> 'b f -> ('a -> 'b -> 'c -> 'c) -> 'c -> 'c f
type 'b property
val mk_property: (t -> 'b) -> 'b property
......
#load "pa_extend.cmo";;
open Location
open Ast
open Ident
......
......@@ -30,37 +30,22 @@ let equal _ _ = failwith "Typer.equal"
let check _ = failwith "Typer.check"
(* 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 =
Env.iter
(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;
Serialize.Put.env Id.serialize serialize_item Env.iter s env.ids;
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 rec aux env =
match Serialize.Get.bits 2 s with
| 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 ids =
Serialize.Get.env Id.deserialize deserialize_item Env.add Env.empty s in
let ns = Ns.deserialize_table s in
{ 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