Miniml is finally able to correctly compile interp.ml to run the compiler
This commit is contained in:
parent
f892a07f23
commit
14ae294bef
@ -1,5 +1,18 @@
|
|||||||
|
OCAMLLEX=../../../ocaml/byterun/ocamlrun ../../../ocaml/boot/ocamllex
|
||||||
|
OCAMLYACC=../../../ocaml/boot/ocamlyacc
|
||||||
|
|
||||||
interp: interp.c main.c std.h
|
interp: interp.c main.c std.h
|
||||||
gcc -g -O2 -I ~/Projects/ocaml/byterun/ interp.c ~/Projects/ocaml/byterun/libcamlrun.a -o interp -lm -ldl
|
gcc -g -O2 -I ~/Projects/ocaml/byterun/ interp.c ~/Projects/ocaml/byterun/libcamlrun.a -o interp -lm -ldl
|
||||||
|
|
||||||
interp.c: out.ml
|
interp.c: out.ml
|
||||||
../compiler/miniml out.ml > interp.c
|
../compiler/miniml out.ml > interp.c
|
||||||
|
|
||||||
|
out.ml: buffer.ml lexing.ml parsing.ml misc.ml clflags.ml location.ml asttypes.mli warnings.ml syntaxerr.ml docstrings.ml longident.ml parsetree.mli ast_helper.ml parser.ml lexer.ml interp.ml
|
||||||
|
./genfile.sh
|
||||||
|
|
||||||
|
lexing.ml: lexing.mll
|
||||||
|
$(OCAMLLEX) $<
|
||||||
|
sed -i "s/lexbuf.Lexing.refill_buff/Lexing.refill_buff/" $@
|
||||||
|
|
||||||
|
parser.ml: parser.mly
|
||||||
|
$(OCAMLYACC) $<
|
@ -308,6 +308,11 @@ let env_extend exported env ev1 =
|
|||||||
env_fields = SMap.fold1 (fun exported key f fe -> SMap.add key (exported, f) fe) exported fe1 env.env_fields ;
|
env_fields = SMap.fold1 (fun exported key f fe -> SMap.add key (exported, f) fe) exported fe1 env.env_fields ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let rec longident_flatten li = match li with
|
||||||
|
| Longident.Lident s -> s
|
||||||
|
| Longident.Ldot (li, s) -> longident_flatten li ^ "." ^ s
|
||||||
|
| _ -> assert false
|
||||||
|
|
||||||
let make_module env =
|
let make_module env =
|
||||||
let ve = SMap.map snd (SMap.filter (fun _ bb -> fst bb) env.env_vars) in
|
let ve = SMap.map snd (SMap.filter (fun _ bb -> fst bb) env.env_vars) in
|
||||||
let me = SMap.map snd (SMap.filter (fun _ bb -> fst bb) env.env_modules) in
|
let me = SMap.map snd (SMap.filter (fun _ bb -> fst bb) env.env_modules) in
|
||||||
@ -821,7 +826,7 @@ and eval_expr_for env flag v1 v2 p e =
|
|||||||
if flag = Upto then
|
if flag = Upto then
|
||||||
eval_expr_for_up env v1 v2 p e
|
eval_expr_for_up env v1 v2 p e
|
||||||
else
|
else
|
||||||
eval_expr_for_down env v1 v2 p e
|
eval_expr_for_down env v2 v1 p e
|
||||||
|
|
||||||
and eval_expr env expr =
|
and eval_expr env expr =
|
||||||
match expr.pexp_desc with
|
match expr.pexp_desc with
|
||||||
@ -862,7 +867,7 @@ and eval_expr env expr =
|
|||||||
let args = List.map1 (fun env le -> let (lab, e) = le in (lab, eval_expr env e)) env l in
|
let args = List.map1 (fun env le -> let (lab, e) = le in (lab, eval_expr env e)) env l in
|
||||||
if trace then begin match f.pexp_desc with Pexp_ident lident ->
|
if trace then begin match f.pexp_desc with Pexp_ident lident ->
|
||||||
(* Format.eprintf "apply %s@." (String.concat "." (Longident.flatten lident.txt)); *)
|
(* Format.eprintf "apply %s@." (String.concat "." (Longident.flatten lident.txt)); *)
|
||||||
print_string (lident_name lident.txt);
|
print_string (longident_flatten lident.txt);
|
||||||
incr tracecur
|
incr tracecur
|
||||||
(*if !tracecur > tracearg_from then Format.eprintf " %a" (Format.pp_print_list ~pp_sep:(fun ff () -> Format.fprintf ff " ") (fun ff (_, v) -> Format.fprintf ff "%a" pp_print_value v)) args; *)
|
(*if !tracecur > tracearg_from then Format.eprintf " %a" (Format.pp_print_list ~pp_sep:(fun ff () -> Format.fprintf ff " ") (fun ff (_, v) -> Format.fprintf ff "%a" pp_print_value v)) args; *)
|
||||||
| _ -> ()
|
| _ -> ()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user