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