Commit 44f207a5 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2004-03-10 10:45:29 by jdemouth] Empty log message

Original author: jdemouth
Date: 2004-03-10 10:45:29+00:00
parent b4ad0491
ifeq ($(NATIVE), true)
EXTENSION = cmx
EXTENSION_LIB = cmxa
LINK = ocamlopt
else
EXTENSION = cmo
EXTENSION_LIB = cma
LINK = ocamlc
endif
OBJECTS=src/types.cmo src/ocaml.cmo src/cduce.cmo src/checker.cmo \
src/generator.cmo src/main.cmo
BIN=../cduce2ocaml
INCLUDES=-I src -I ..
LIBS=oCaml_all.cma ../cDuce_all.cma
all: $(BIN)
$(BIN):$(OBJECTS:.cmo=.$(EXTENSION))
$(LINK) -o $@ $(LIBS:.cma=.$(EXTENSION_LIB)) $^
.SUFFIXES: .mli .ml .cmi .cmo .cmx
.mli.cmi:
ocamlc $(INCLUDES) -c $<
.ml.cmo:
ocamlc $(INCLUDES) -c $<
.ml.cmx:
ocamlopt $(INCLUDES) -c $<
clean:
rm -f src/*.cmi src/*.cmo src/*.cmx src/*.o $(BIN) src/*~
.depend depend:
rm -f .depend
ocamldep src/*.ml src/*.mli > .depend
include .depend
Imagine that you want to call the following CDuce function in an ocaml
program:
type ML_int = -1073741824 -- 1073741823
type Printer = ML_int -> []
let f ( Printer -> [ ML_int * ] -> [] ) g ->
fun ( list :[ Int * ]):[] =
transform list with
x & ML_int -> g x
| _ -> raise "Int overflow"
1) Save this in a file test.cd.
2) Write the ocaml interface file test.mli:
val f : ( int -> unit ) -> int list -> unit
2bis) Compile test.mli to get test.cmi
ocamlc -c test.mli
3) Compile test.cd to obtain test.cdo
cduce --compile test.cd
4) Generate test.cmo from test.cdo
cduce2ocaml test.cmi test.cdo
5) Now you can call f from a ocaml program say main.ml
let () = Test.f (Format.eprintf "print = %d@.") [1 ; 2 ; 3 ]
that can be compiled as usual
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