* http://helm.cs.unibo.it/
*)
+(* $Id$ *)
+
open Printf
open GrafiteTypes
+exception AttemptToInsertAnAlias
+
let pp_ast_statement =
GrafiteAstPp.pp_statement ~term_pp:CicNotationPp.pp_term
~lazy_term_pp:CicNotationPp.pp_term ~obj_pp:CicNotationPp.pp_obj
HLog.debug ("Executing: ``" ^ stm ^ "''"))
in
try
- let lexicon_status'', grafite_status'' =
- eval_function lexicon_status' grafite_status' is cb
+ let grafite_status'', lexicon_status'' =
+ match eval_function lexicon_status' grafite_status' is cb with
+ [] -> assert false
+ | (s,None)::_ -> s
+ | (s,Some _)::_ -> raise AttemptToInsertAnAlias
in
lexicon_status := Some lexicon_status'';
grafite_status := Some grafite_status''
let str = Ulexing.from_utf8_channel stdin in
try
run_script str
- (MatitaEngine.eval_from_stream ~prompt:true
+ (MatitaEngine.eval_from_stream ~first_statement_only:false ~prompt:true
~include_paths:(Helm_registry.get_list Helm_registry.string
"matita.includes"))
with
| GrafiteEngine.Drop -> pp_ocaml_mode ()
+ | GrafiteEngine.Macro (floc,_) ->
+ let x, y = HExtlib.loc_of_floc floc in
+ HLog.error
+ (sprintf "A macro has been found in a script at %d-%d" x y);
+ interactive_loop ()
| Sys.Break -> HLog.error "user break!"; interactive_loop ()
| GrafiteTypes.Command_error _ -> interactive_loop ()
| End_of_file ->
print_newline ();
clean_exit (Some 0)
| HExtlib.Localized (floc,CicNotationParser.Parse_error err) ->
- let (x, y) = HExtlib.loc_of_floc floc in
- HLog.error (sprintf "Parse error at %d-%d: %s" x y err);
- interactive_loop ()
+ let x, y = HExtlib.loc_of_floc floc in
+ HLog.error (sprintf "Parse error at %d-%d: %s" x y err);
+ interactive_loop ()
| exn -> HLog.error (Printexc.to_string exn); interactive_loop ()
let go () =
Helm_registry.get_list Helm_registry.string "matita.includes" in
(try
run_script is
- (MatitaEngine.eval_from_stream ~include_paths
+ (MatitaEngine.eval_from_stream ~first_statement_only:false ~include_paths
~clean_baseuri:(not (Helm_registry.get_bool "matita.preserve")))
with End_of_file -> ());
let elapsed = Unix.time () -. time in
clean_exit (Some 1)
else
pp_ocaml_mode ()
+ | GrafiteEngine.Macro (floc,_) ->
+ let x, y = HExtlib.loc_of_floc floc in
+ HLog.error
+ (sprintf "A macro has been found in a script at %d-%d" x y);
+ if mode = `COMPILER then
+ clean_exit (Some 1)
+ else
+ pp_ocaml_mode ()
| HExtlib.Localized (floc,CicNotationParser.Parse_error err) ->
let (x, y) = HExtlib.loc_of_floc floc in
HLog.error (sprintf "Parse error at %d-%d: %s" x y err);