exception TryingToAdd of string
exception EnrichedWithStatus of exn * GrafiteTypes.status
-let eval_from_stream ~include_paths ?do_heavy_checks
- ?(enforce_no_new_aliases=true) status str cb
-=
+let eval_from_stream ~include_paths ?do_heavy_checks status str cb =
let matita_debug = Helm_registry.get_bool "matita.debug" in
- let rec loop status statuses =
- let stop,g,s =
+ let rec loop status =
+ let stop,status =
try
let cont =
try Some (GrafiteParser.parse_statement status str)
with End_of_file -> None in
match cont with
- | None -> true, status, statuses
+ | None -> true, status
| Some ast ->
cb status ast;
let new_statuses =
eval_ast ~include_paths ?do_heavy_checks status ("",0,ast) in
- if enforce_no_new_aliases then
- List.iter
- (fun (_,alias) ->
- match alias with
- None -> ()
- | Some (k,value) ->
- let newtxt = GrafiteAstPp.pp_alias value in
- raise (TryingToAdd newtxt)) new_statuses;
let status =
match new_statuses with
- [] -> assert false
- | (s,_)::_ -> s
+ [s,None] -> s
+ | _::(_,Some (_,value))::_ ->
+ raise (TryingToAdd (GrafiteAstPp.pp_alias value))
+ | _ -> assert false
in
- false, status, (new_statuses @ statuses)
+ false, status
with exn when not matita_debug ->
raise (EnrichedWithStatus (exn, status))
in
- if stop then s else loop g s
+ if stop then status else loop status
in
- loop status []
+ loop status
;;
(* should be used only by the compiler since it looses the
* disambiguation_context (text,prefix_len,_) *)
val eval_from_stream :
- include_paths:string list ->
- ?do_heavy_checks:bool ->
- ?enforce_no_new_aliases:bool -> (* default true *)
- GrafiteTypes.status ->
- Ulexing.lexbuf ->
- (GrafiteTypes.status -> GrafiteAst.statement -> unit) ->
- (GrafiteTypes.status *
- (DisambiguateTypes.domain_item * GrafiteAst.alias_spec) option) list
+ include_paths:string list -> ?do_heavy_checks:bool -> GrafiteTypes.status ->
+ Ulexing.lexbuf -> (GrafiteTypes.status -> GrafiteAst.statement -> unit) ->
+ GrafiteTypes.status
open GrafiteTypes
-exception AttemptToInsertAnAlias of GrafiteDisambiguate.status
-
let slash_n_RE = Pcre.regexp "\\n" ;;
let pp_ast_statement grafite_status stm =
else pp_ast_statement
in
let grafite_status =
- let rec aux_for_dump x grafite_status =
- match
- MatitaEngine.eval_from_stream ~include_paths grafite_status buf x
- with
- | [] -> grafite_status
- | (g,None)::_ -> g
- | (g,Some _)::_ ->
- raise (AttemptToInsertAnAlias (g :> GrafiteDisambiguate.status))
- in
- aux_for_dump print_cb grafite_status
+ MatitaEngine.eval_from_stream ~include_paths grafite_status buf print_cb
in
let elapsed = Unix.time () -. time in
(if Helm_registry.get_bool "matita.moo" then begin
true)
with
(* all exceptions should be wrapped to allow lexicon-undo (LS.time_travel) *)
- | AttemptToInsertAnAlias lexicon_status ->
- pp_times fname false big_bang big_bang_u big_bang_s;
-(*
- LexiconSync.time_travel
- ~present:lexicon_status ~past:initial_lexicon_status;
-*)
- clean_exit baseuri false
| MatitaEngine.EnrichedWithStatus (exn, _grafite) as exn' ->
(match exn with
| Sys.Break -> HLog.error "user break!"