Commit 03511dba authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2002-10-30 01:39:41 by cvscast] Empty log message

Original author: cvscast
Date: 2002-10-30 01:39:41+00:00
parent e0623726
DEBUG = -g
PACKAGES = pxp-engine,pxp-lex-iso88591,camlp4,num
OCAMLC = ocamlfind ocamlcp -package $(PACKAGES)
OCAMLOPT = ocamlfind ocamlopt -package $(PACKAGES)
# Source directories
DIRS = parser typing types runtime driver
# Objects to build
PARSER = parser/lexer.cmo parser/location.cmo parser/ast.cmo parser/parser.cmo
......@@ -19,30 +20,37 @@ RUNTIME = runtime/value.cmo
DRIVER = driver/cduce.cmo
DIRS = parser typing types runtime driver
OBJECTS = $(TYPES) $(PARSER) $(TYPING) $(RUNTIME)
XOBJECTS = $(OBJECTS:.cmo=.cmx)
XDRIVER = $(DRIVER:.cmo=.cmx)
DEPEND = parser/*.ml parser/*.mli typing/*.ml typing/*.mli types/*.ml types/*.mli runtime/*.mli runtime/*.ml driver/*.mli driver/*.ml
INCLUDES = -I +camlp4 -I parser -I types -I runtime -I typing
#SYNTAX_PARSER = -pp 'camlp4o pa_extend.cmo'
PREPRO = camlp4o pa_extend.cmo pr_o.cmo
DEBUG = -g
PACKAGES = pxp-engine,pxp-lex-iso88591,camlp4,num
OCAMLCP = ocamlc
OCAMLC = ocamlfind $(OCAMLCP) -package $(PACKAGES)
OCAMLOPT = ocamlfind ocamlopt -package $(PACKAGES)
DEPEND = $(DIRS:=/*.ml) $(DIRS:=/*.mli)
INCLUDES = $(DIRS:%=-I %)
SYNTAX = camlp4o pa_extend.cmo
SYNTAX_PARSER = -pp '$(SYNTAX)'
PREPRO = $(SYNTAX) pr_o.cmo
all.cma: $(OBJECTS)
$(OCAMLC) $(DEBUG) -o all.cma -linkpkg gramlib.cma -a $(OBJECTS)
$(OCAMLC) $(DEBUG) -o $@ -linkpkg gramlib.cma -a $(OBJECTS)
all.cmxa: $(XOBJECTS)
$(OCAMLOPT) -a -o all.cmxa $(XOBJECTS)
$(OCAMLOPT) -a -o $@ $(XOBJECTS)
cduce: $(OBJECTS) $(DRIVER)
$(OCAMLC) $(DEBUG) -linkpkg -o cduce gramlib.cma $(OBJECTS) $(DRIVER)
$(OCAMLC) $(DEBUG) -linkpkg -o $@ gramlib.cma $(OBJECTS) $(DRIVER)
cduce.opt: all.cmxa $(XDRIVER)
$(OCAMLOPT) -linkpkg -o cduce.opt gramlib.cmxa $(XOBJECTS) $(XDRIVER)
$(OCAMLOPT) -linkpkg -o $@ gramlib.cmxa $(XOBJECTS) $(XDRIVER)
compute_depend:
@echo "Computing dependencies ..."
......@@ -57,24 +65,41 @@ clean:
done
rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~
rm -f cduce cduce.opt
rm -Rf prepro
.SUFFIXES: .ml .mli .cmo .cmi .cmx
profile:
rm -Rf prepro
mkdir prepro
for i in $(DIRS); do \
mkdir prepro/$$i; \
for j in $$i/*.ml $$i/*.mli; do \
if [ -f "$$j" ]; then \
echo $$j; \
$(PREPRO) $$j -o prepro/$$j; \
fi; \
done; \
done
cp Makefile depend prepro/
(cd prepro; make cduce OCAMLCP="ocamlcp -p a" SYNTAX_PARSER=)
.ml.cmo:
$(PREPRO) $< > $@pp
$(OCAMLC) $(DEBUG) -c $(SYNTAX_PARSER) $(INCLUDES) -impl $<pp
$(OCAMLC) $(DEBUG) -c $(SYNTAX_PARSER) $(INCLUDES) $<
.ml.cmx:
$(OCAMLOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
.mli.cmi:
$(OCAMLC) $(DEBUG) -c $(INCLUDES) $<
$(OCAMLC) $(DEBUG) -c $(SYNTAX_PARSER) $(INCLUDES) $<
# FORTPATH = /users/formel8/frisch/solaris/fort/fort
FORTPATH = /home/frisch/fort
FORTBIN = $(FORTPATH)/fort
FORTLIB = $(FORTPATH)
#FORTPATH = /home/frisch/fort
#FORTBIN = $(FORTPATH)/fort
#FORTLIB = $(FORTPATH)
test: all.cma
$(FORTBIN) -I $(FORTLIB) all.cma test_fort.ml
fort all.cma $(INCLUDES) tests/test_fort.ml
include depend
......@@ -8,7 +8,6 @@ parser/parser.cmo: parser/ast.cmo types/atoms.cmi types/chars.cmi \
parser/parser.cmx: parser/ast.cmx types/atoms.cmx types/chars.cmx \
types/intervals.cmx parser/lexer.cmx parser/location.cmx \
types/sequence.cmx types/types.cmx parser/parser.cmi
parser/parser.cmi: parser/ast.cmo
typing/typed.cmo: parser/location.cmi types/patterns.cmi types/sortedMap.cmi \
types/types.cmi
typing/typed.cmx: parser/location.cmx types/patterns.cmx types/sortedMap.cmx \
......@@ -19,7 +18,6 @@ typing/typer.cmo: parser/ast.cmo types/intervals.cmi parser/location.cmi \
typing/typer.cmx: parser/ast.cmx types/intervals.cmx parser/location.cmx \
types/patterns.cmx types/sequence.cmx types/sortedList.cmx \
typing/typed.cmx types/types.cmx typing/typer.cmi
typing/typer.cmi: parser/ast.cmo typing/typed.cmo types/types.cmi
types/atoms.cmo: types/sortedList.cmi types/atoms.cmi
types/atoms.cmx: types/sortedList.cmx types/atoms.cmi
types/boolean.cmo: types/recursive.cmi types/sortedList.cmi types/boolean.cmi
......@@ -54,19 +52,6 @@ types/types.cmo: types/atoms.cmi types/boolean.cmi types/chars.cmi \
types/types.cmx: types/atoms.cmx types/boolean.cmx types/chars.cmx \
types/intervals.cmx types/recursive.cmx types/sortedList.cmx \
types/sortedMap.cmx types/types.cmi
types/boolean.cmi: types/sortedList.cmi
types/patterns.cmi: types/sortedList.cmi types/sortedMap.cmi types/types.cmi
types/sequence.cmi: types/types.cmi
types/sortedMap.cmi: types/sortedList.cmi
types/syntax.cmi: types/patterns.cmi types/types.cmi
types/types.cmi: types/atoms.cmi types/chars.cmi types/intervals.cmi \
types/sortedMap.cmi
runtime/value.cmi: types/chars.cmi types/patterns.cmi types/sortedMap.cmi \
typing/typed.cmo types/types.cmi
runtime/load_xml.cmo: types/chars.cmi types/sequence.cmi types/sortedMap.cmi \
types/types.cmi runtime/value.cmi
runtime/load_xml.cmx: types/chars.cmx types/sequence.cmx types/sortedMap.cmx \
types/types.cmx runtime/value.cmx
runtime/value.cmo: types/chars.cmi types/patterns.cmi types/sequence.cmi \
types/sortedMap.cmi typing/typed.cmo types/types.cmi runtime/value.cmi
runtime/value.cmx: types/chars.cmx types/patterns.cmx types/sequence.cmx \
......@@ -77,3 +62,13 @@ driver/cduce.cmo: parser/ast.cmo types/builtin.cmo parser/location.cmi \
driver/cduce.cmx: parser/ast.cmx types/builtin.cmx parser/location.cmx \
parser/parser.cmx types/patterns.cmx typing/typer.cmx types/types.cmx \
runtime/value.cmx
parser/parser.cmi: parser/ast.cmo
typing/typer.cmi: parser/ast.cmo typing/typed.cmo types/types.cmi
types/boolean.cmi: types/sortedList.cmi
types/patterns.cmi: types/sortedList.cmi types/sortedMap.cmi types/types.cmi
types/sequence.cmi: types/types.cmi
types/sortedMap.cmi: types/sortedList.cmi
types/syntax.cmi: types/patterns.cmi types/types.cmi
types/types.cmi: types/atoms.cmi types/chars.cmi types/intervals.cmi \
types/sortedMap.cmi
runtime/value.cmi: types/patterns.cmi typing/typed.cmo
......@@ -275,12 +275,17 @@ EXTEND
];
END
let pat' = Grammar.Entry.create gram "type/pattern expression"
EXTEND GLOBAL: pat pat';
pat': [ [ p = pat; EOI -> p ] ];
END
let pat = Grammar.Entry.parse pat
let expr = Grammar.Entry.parse expr
let prog = Grammar.Entry.parse prog
module From_string = struct
let pat s = pat (Stream.of_string s)
let pat s = Grammar.Entry.parse pat' (Stream.of_string s)
let expr s = expr (Stream.of_string s)
end
......@@ -174,6 +174,13 @@ let const = function
| Types.Atom a -> Atom a
| Types.Char c -> Char c
(*
module Array = struct
include Array
let get a i = assert (i < length a); assert (i >= 0); get a i
end
*)
let make_result_prod v1 r1 v2 r2 v (code,r) =
let ret = Array.map
(function
......@@ -194,7 +201,7 @@ let make_result_record fields v bindings (code,r) =
| `Catch -> v
| `Const c -> const c
| `Field (l,i) ->
if (l < 0) then List.assoc l fields
if (i < 0) then List.assoc l fields
else (List.assoc l bindings).(i)
| _ -> assert false
) r in
......
open Types;;
open Fort;;
open Parser.From_string
let (=?) a b = expect_equal a b;;
let (??) a = expect_true a;;
let parse_typ s = Types.descr (Typer.typ (pat s));;
expect_pass "Parsing types"
(fun () ->
let t1 = parse_typ "[1 -- 10 *]" in
let t2 = parse_typ "[20 -- 30 +]" in
()
);;
let recurs f =
let t = make () in
define t (f t);
......@@ -21,13 +38,20 @@ let cons' d =
define t d;
t
let list t = recurs (fun s -> cup (times t s) (atom 0));;
let square i j k l = times (cons (interval i j)) (cons (interval k l))
let list = Sequence.star
let interv i j =
Types.interval
(Intervals.bounded (Big_int.big_int_of_int i) (Big_int.big_int_of_int j))
let square i j k l = times (cons (interv i j)) (cons (interv k l))
(*
let int_list i j = descr (list (cons (interval i j)))
let int i = interval i i
let (---) = diff;;
let (=?) a b = expect_equal a b;;
let (??) a = expect_true a;;
exception NoException
let exn a x e =
......@@ -41,7 +65,6 @@ let exn a x e =
(Printexc.to_string e)
)
let (??) a = expect_true a;;
expect_pass "Unique representation"
(fun () ->
......@@ -83,3 +106,5 @@ expect_pass "Regular string expressions"
is_empty t =? false;
Sample.get t =? Sample.String "aa";
);;
*)
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