src/Tools/isac/BridgeJEdit/preliminary-OLD.sml
author wneuper <Walther.Neuper@jku.at>
Sun, 29 May 2022 19:00:35 +0200
changeset 60434 d780a93d21b3
parent 60433 9d98791b4080
permissions -rw-r--r--
Calculation 1: minimal changes in code + application
     1 (*  Title:      Tools/isac/BridgeJEdit/preliminary-OLD..sml
     2     Author:     Walther Neuper, JKU Linz
     3     (c) due to copyright terms
     4 
     5 Preliminary code for start transition Libisabelle -- PIDE.
     6 Will be distributed to several structures, most of which do not yet exist.
     7 *)
     8 
     9 signature PRELIMINARY_OLD =
    10 sig
    11   (* for keyword ExampleSPARK *)
    12   val store_and_show: theory -> Formalise.T list -> theory -> theory;
    13   val load_formalisation: theory -> (Fdl_Lexer.T list -> ParseC_OLD.form_model_refs * 'a) ->
    14     (theory -> Token.file * theory) * string -> theory -> theory
    15   
    16   (* for keyword Problem*)
    17 (**)val init_specify: ParseC_OLD.problem_headline -> theory -> theory(**)
    18 (** )val init_specify: ParseC_OLD.problem -> theory -> theory( **)
    19 end
    20 
    21 (** code for keyword ExampleSPARK **)
    22 
    23 structure Refs_Data = Theory_Data
    24 (
    25   type T = References.T
    26   val empty : T = References.empty
    27   val extend = I
    28   fun merge (_, refs) = refs
    29 );
    30 structure OMod_Data = Theory_Data
    31 (
    32   type T = O_Model.T
    33   val empty : T = []
    34   val extend = I
    35   fun merge (_, o_model) = o_model
    36 );
    37 structure IMod_Data = Theory_Data
    38 (
    39   type T = I_Model.T
    40   val empty : T = []
    41   val extend = I
    42   fun merge (_, i_model) = i_model
    43 );
    44 structure Ctxt_Data = Theory_Data
    45 (
    46   type T = Proof.context
    47   val empty : T = ContextC.empty
    48   val extend = I
    49   fun merge (_, ctxt) = ctxt
    50 );
    51 
    52 (**)
    53 structure Preliminary_OLD(**): PRELIMINARY_OLD(**) =
    54 struct
    55 (**)
    56 
    57 fun store_and_show HACKthy formalise thy =
    58   let
    59 (**)val _(*file_read_correct*) = case formalise of xxx as
    60       [(["Traegerlaenge L", "Streckenlast q_0", "Biegelinie y", "Randbedingungen [y 0 = (0::real), y L = 0, M_b 0 = 0, M_b L = 0]", "FunktionsVariable x", "GleichungsVariablen [c, c_2, c_3, c_4]", "AbleitungBiegelinie dy"],
    61         ("Biegelinie", ["Biegelinien"], ["IntegrierenUndKonstanteBestimmen2"]))] => hd xxx
    62       | _ => error "magic failed: handling file exp_Statics_Biegel_Timischl_7-70.str failed"
    63 (**)
    64     val formalise = hd formalise (*we expect only one Formalise.T in the list*)
    65     val (_(*hdlPIDE*), _, refs, o_model, var_type_ctxt) = Step_Specify.initialisePIDEHACK HACKthy formalise
    66   (*              ^^ TODO remove with cleanup in nxt_specify_init_calc *)
    67 (*
    68   TODO: present "Problem hdlPIDE" via PIDE
    69 *)
    70   in
    71     thy
    72       |> Refs_Data.put refs
    73       |> OMod_Data.put o_model
    74       |> Ctxt_Data.put var_type_ctxt
    75   end;
    76 
    77 (*
    78 fun load_formalisation parser (files, _) thy =
    79   let
    80     val ([{lines, pos, ...}: Token.file], thy') = files thy;
    81   in
    82     store_and_show
    83       (ParseC_OLD.read_out_formalise (fst (parser (fst (ParseC_OLD.tokenize_formalise pos (cat_lines lines))))))
    84         thy'
    85   end;
    86 *)
    87 fun load_formalisation HACKthy parse (get_file: theory -> Token.file * theory, _: string) thy =
    88   let
    89     val (file, thy') = get_file thy;
    90     val formalise = #lines file
    91       |> cat_lines 
    92       |> ParseC_OLD.tokenize_formalise (#pos file)
    93       |> fst
    94       |> parse
    95       |> fst
    96       |> ParseC_OLD.read_out_formalise
    97       |> store_and_show HACKthy
    98 (**)val _ = @{print} {a = "### load_formalisation \<rightarrow>", formalise = formalise}(**)
    99   in
   100     formalise thy'
   101   end;
   102 
   103 (*** code for keyword Problem ***)
   104 
   105 (*
   106 val prefer_input: ThyC.id * Problem.id -> References.T -> O_Model.T -> References.T * O_Model.T
   107 *)
   108 fun prefer_input (inthy, inpbl : Problem.id) (thy, pbl, met_id) o_model =
   109   if inthy = thy andalso inpbl = pbl
   110   then ((thy, pbl, met_id) : References.T, o_model)
   111   else ((inthy, inpbl, MethodC.id_empty), [])
   112 
   113 fun init_specify problem thy =
   114   let
   115     val _ = @{print} {a = "//--- Spark_Commands.init_specify", headline = problem}
   116     val (thy_id, pbl_id) = ParseC_OLD.read_out_headline problem (*how handle Position?!?*)
   117     val refs' = Refs_Data.get thy
   118     val ((_, pbl_id, _), _(*o_model*)) =
   119       prefer_input (thy_id, pbl_id) refs' (OMod_Data.get thy)
   120     val i_model = I_Model.initPIDE pbl_id
   121 (* TODO: present Specification = i_model + refs via PIDE, if specify is done explicitly. *)
   122   in
   123     IMod_Data.put i_model thy (* the Model-items with Descriptor s only *)
   124   end;
   125 (**)
   126 (**)end(**)