X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fmatita%2FmatitaScript.ml;h=7768e2287f27d5626262c3b6a7f583d2a272e3dc;hb=05ebdd213d5968b9f0eeaa01e4f9aac33ef86c7c;hp=65d7be828f0e0ebeb4199fd3f4dbb46e8d25180c;hpb=75de1f4c87166f120d8bb42d98926adaf407c98c;p=helm.git diff --git a/helm/software/matita/matitaScript.ml b/helm/software/matita/matitaScript.ml index 65d7be828..7768e2287 100644 --- a/helm/software/matita/matitaScript.ml +++ b/helm/software/matita/matitaScript.ml @@ -76,7 +76,6 @@ let eval_with_engine include_paths guistuff lexicon_status grafite_status user_g = let module TAPp = GrafiteAstPp in let module DTE = DisambiguateTypes.Environment in - let module DP = DisambiguatePp in let parsed_text_length = String.length skipped_txt + String.length nonskipped_txt in @@ -94,8 +93,8 @@ let eval_with_engine include_paths guistuff lexicon_status grafite_status user_g (fun (acc, to_prepend) (status,alias) -> match alias with | None -> (status,to_prepend ^ nonskipped_txt)::acc,"" - | Some (k,((v,_) as value)) -> - let newtxt = DP.pp_environment (DTE.add k value DTE.empty) in + | Some (k,value) -> + let newtxt = LexiconAstPp.pp_alias value in (status,to_prepend ^ newtxt ^ "\n")::acc, "") ([],skipped_txt) enriched_history_fragment in @@ -582,7 +581,7 @@ lexicon_status grafite_status user_goal unparsed_text skipped_txt nonskipped_txt script ex loc = let module TAPp = GrafiteAstPp in - let module MD = GrafiteDisambiguator in + let module MD = MultiPassDisambiguator in let module ML = MatitaMisc in try ignore (buffer#move_mark (`NAME "beginning_of_statement") @@ -642,9 +641,9 @@ and eval_statement include_paths (buffer : GText.buffer) guistuff lexicon_status HExtlib.Localized (floc, exn) -> HExtlib.raise_localized_exception ~offset:(MatitaGtkMisc.utf8_string_length parsed_text) floc exn - | GrafiteDisambiguator.DisambiguationError (offset,errorll) -> + | MultiPassDisambiguator.DisambiguationError (offset,errorll) -> raise - (GrafiteDisambiguator.DisambiguationError + (MultiPassDisambiguator.DisambiguationError (offset+parsed_text_length, errorll)) in assert (text=""); (* no macros inside comments, please! *) @@ -849,9 +848,43 @@ object (self) | exc -> self#notify; raise exc method private getFuture = - buffer#get_text ~start:(buffer#get_iter_at_mark (`MARK locked_mark)) - ~stop:buffer#end_iter () + let lock = buffer#get_iter_at_mark (`MARK locked_mark) in + let text = buffer#get_text ~start:lock ~stop:buffer#end_iter () in + text + method expandAllVirtuals = + let lock = buffer#get_iter_at_mark (`MARK locked_mark) in + let text = buffer#get_text ~start:lock ~stop:buffer#end_iter () in + buffer#delete ~start:lock ~stop:buffer#end_iter; + let text = Pcre.replace ~pat:":=" ~templ:"\\def" text in + let text = Pcre.replace ~pat:"->" ~templ:"\\to" text in + let text = Pcre.replace ~pat:"=>" ~templ:"\\Rightarrow" text in + let text = + Pcre.substitute_substrings + ~subst:(fun str -> + let pristine = Pcre.get_substring str 0 in + let input = + if pristine.[0] = ' ' then + String.sub pristine 1 (String.length pristine -1) + else pristine + in + let input = + if input.[String.length input-1] = ' ' then + String.sub input 0 (String.length input -1) + else input + in + let before, after = + if input = "\\forall" || + input = "\\lambda" || + input = "\\exists" then "","" else " ", " " + in + try + before ^ Glib.Utf8.from_unichar + (snd (Virtuals.symbol_of_virtual input)) ^ after + with Virtuals.Not_a_virtual -> pristine) + ~pat:" ?\\\\[a-zA-Z]+ ?" text + in + buffer#insert ~iter:lock text (** @param rel_offset relative offset from current position of locked_mark *) method private moveMark rel_offset =