Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
ff08e6ce
Commit
ff08e6ce
authored
Jul 10, 2007
by
Pietro Abate
Browse files
[r2004-03-09 20:13:34 by jdemouth] Add ocaml interface to cduce compiler.
Original author: jdemouth Date: 2004-03-09 20:14:57+00:00
parent
8c1f05c6
Changes
3
Hide whitespace changes
Inline
Side-by-side
INSTALL
View file @
ff08e6ce
...
@@ -57,6 +57,10 @@ Important notes:
...
@@ -57,6 +57,10 @@ Important notes:
<hit enter key when asked for password>
<hit enter key when asked for password>
cvs -z3 -d":pserver:anoncvs@camlcvs.inria.fr:/caml" co ocaml
cvs -z3 -d":pserver:anoncvs@camlcvs.inria.fr:/caml" co ocaml
- cduce can be interfaced with OCaml language to be called from it. In order
to be able to use this feature, you will have to patch OCaml Makefile and
build a special library. Everything is explained bellow.
- 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/ (use version >=4.4)
from http://www.pcre.org/ (use version >=4.4)
[red-hat users: pcre (rawhide) packages may not work with the
[red-hat users: pcre (rawhide) packages may not work with the
...
@@ -92,6 +96,14 @@ Efficiency issues:
...
@@ -92,6 +96,14 @@ Efficiency issues:
Compilation
Compilation
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Build OCaml compiler lib (needed to interface CDuce with OCaml):
- Copy ocaml_cdo2cmo_patch (located in cdo2cmo directory of your cduce
archive) in the directory where you extracted OCaml sources.
- Patch OCaml's Makefile with:
patch -Nj0 < ocaml_cdo2cmo_patch
- Build OCaml's special library:
make oCaml_all.cma
THE FAST WAY:
THE FAST WAY:
- check local settings in Makefile.conf or do "make help" [optional]
- check local settings in Makefile.conf or do "make help" [optional]
...
@@ -147,6 +159,9 @@ NATIVE=true : use the OCaml native code compiler (ocamlopt) to build CDuce
...
@@ -147,6 +159,9 @@ NATIVE=true : use the OCaml native code compiler (ocamlopt) to build CDuce
NATIVE=false : use the OCaml bytecode compiler (ocamlc)
NATIVE=false : use the OCaml bytecode compiler (ocamlc)
default: true (the native code version is much faster)
default: true (the native code version is much faster)
ML_INTERFACE=true : build CDuce with OCaml interface support
default: false
PXP_WLEX=true : use wlex for parsing UTF-8 XML files
PXP_WLEX=true : use wlex for parsing UTF-8 XML files
need pxp built with wlex support
need pxp built with wlex support
PXP_WLEX=false: use ocamllex for parsing UTF-8 XML files
PXP_WLEX=false: use ocamllex for parsing UTF-8 XML files
...
...
driver/cduce.ml
View file @
ff08e6ce
open
Location
open
Location
open
Ident
open
Ident
ifdef
ML_INTERFACE
then
module
ML
=
Ml_ocaml
;;
exception
InvalidInputFilename
of
string
exception
InvalidInputFilename
of
string
exception
InvalidObjectFilename
of
string
exception
InvalidObjectFilename
of
string
...
@@ -276,6 +278,24 @@ let run rule ppf ppf_err input =
...
@@ -276,6 +278,24 @@ let run rule ppf ppf_err input =
let
script
=
run
Parser
.
prog
let
script
=
run
Parser
.
prog
let
topinput
=
run
Parser
.
top_phrases
let
topinput
=
run
Parser
.
top_phrases
ifdef
ML_INTERFACE
then
let
check_ml
cu
id
out_dir
out
=
try
(* Load Caml .cmi file. *)
let
ml_cu
=
ML
.
CompUnit
.
from_bytecode
(
cu
^
".cmi"
)
and
cd_cu
=
Ml_cduce
.
CompUnit
.
from_types_cu
cu
id
in
(* Check file interfaces. *)
Ml_checker
.
run
ml_cu
cd_cu
;
(* Generate interface file. *)
let
out
=
open_out
(
Filename
.
concat
out_dir
(
cu
^
".ml"
)
)
in
let
fmt
=
Format
.
formatter_of_out_channel
out
in
Ml_generator
.
ML
.
generate
fmt
ml_cu
cd_cu
;
close_out
out
;
with
_
->
Format
.
eprintf
"Warning: no valid Caml interface found.@."
else
let
check_ml
cu
id
out_dir
out
=
()
;;
let
compile
src
out_dir
=
let
compile
src
out_dir
=
try
try
if
not
(
Filename
.
check_suffix
src
".cd"
)
if
not
(
Filename
.
check_suffix
src
".cd"
)
...
@@ -289,6 +309,7 @@ let compile src out_dir =
...
@@ -289,6 +309,7 @@ let compile src out_dir =
let
id
=
Types
.
CompUnit
.
mk
(
U
.
mk_latin1
cu
)
in
let
id
=
Types
.
CompUnit
.
mk
(
U
.
mk_latin1
cu
)
in
Librarian
.
compile
!
verbose
id
src
;
Librarian
.
compile
!
verbose
id
src
;
Librarian
.
save
id
out
;
Librarian
.
save
id
out
;
check_ml
cu
id
out_dir
out
;
exit
0
exit
0
with
exn
->
catch_exn
Format
.
err_formatter
exn
;
exit
1
with
exn
->
catch_exn
Format
.
err_formatter
exn
;
exit
1
...
...
driver/run.ml
View file @
ff08e6ce
...
@@ -12,10 +12,16 @@ let args = ref []
...
@@ -12,10 +12,16 @@ let args = ref []
let
compile
=
ref
false
let
compile
=
ref
false
let
run
=
ref
false
let
run
=
ref
false
ifdef
ML_INTERFACE
then
let
ocaml_support
=
true
else
let
ocaml_support
=
false
;;
let
version
()
=
let
version
()
=
Printf
.
eprintf
"CDuce, version %s
\n
"
<:
symbol
<
cduce_version
>>;
Printf
.
eprintf
"CDuce, version %s
\n
"
<:
symbol
<
cduce_version
>>;
Printf
.
eprintf
"built on %s
\n
"
<:
symbol
<
build_date
>>;
Printf
.
eprintf
"built on %s
\n
"
<:
symbol
<
build_date
>>;
Printf
.
eprintf
"using OCaml %s compiler
\n
"
<:
symbol
<
ocaml_compiler
>>;
Printf
.
eprintf
"using OCaml %s compiler
\n
"
<:
symbol
<
ocaml_compiler
>>;
Printf
.
eprintf
"support for ocaml interfacing: %b
\n
"
ocaml_support
;
Printf
.
eprintf
"support for expat: %b
\n
"
(
Load_xml
.
expat_support
);
Printf
.
eprintf
"support for expat: %b
\n
"
(
Load_xml
.
expat_support
);
Printf
.
eprintf
"support for curl: %b
\n
"
(
Load_xml
.
curl_support
);
Printf
.
eprintf
"support for curl: %b
\n
"
(
Load_xml
.
curl_support
);
exit
0
exit
0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment