src/Tools/isac/BridgeJEdit/preliminary.sml
author Walther Neuper <walther.neuper@jku.at>
Fri, 22 Jan 2021 11:27:47 +0100
changeset 60147 d3cb5af53d3d
parent 60146 aaef037414a1
child 60148 c421bae56b93
permissions -rw-r--r--
step 5.2: shift tests from Test_Parse_Isac.thy to test/../parseC.sml
     1 (*  Title:      Tools/isac/BridgeJEdit/preliminary.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 =
    10 sig
    11   val store_and_show: Formalise.T list -> theory -> theory;
    12   val load_formalisation: (Fdl_Lexer.T list -> ParseC.form_model_refs * 'a) ->
    13   (theory -> Token.file list * theory) * 'c -> theory -> theory
    14   
    15 (* ---- for tests only: shifted from below to remove the Warning "unused" at fun.def. --------- *)
    16 (*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
    17 ( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
    18 end
    19 
    20 structure Refs_Data = Theory_Data
    21 (
    22   type T = References.T
    23   val empty : T = References.empty
    24   val extend = I
    25   fun merge (_, refs) = refs
    26 );
    27 structure OMod_Data = Theory_Data
    28 (
    29   type T = O_Model.T
    30   val empty : T = []
    31   val extend = I
    32   fun merge (_, o_model) = o_model
    33 );
    34 structure Ctxt_Data = Theory_Data
    35 (
    36   type T = Proof.context
    37   val empty : T = ContextC.empty
    38   val extend = I
    39   fun merge (_, ctxt) = ctxt
    40 );
    41 
    42 (**)
    43 structure Preliminary(**): PRELIMINARY(**) =
    44 struct
    45 
    46 
    47 fun store_and_show formalise thy =
    48   let
    49 (**)val file_read_correct = case formalise of xxx as
    50       [(["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"],
    51         ("Biegelinie", ["Biegelinien"], ["IntegrierenUndKonstanteBestimmen2"]))] => hd xxx
    52       | _ => error "magic failed: handling file exp_Statics_Biegel_Timischl_7-70.str failed"
    53 (**)
    54     val formalise = hd formalise (*we expect only one Formalise.T in the list*)
    55     val (hdlPIDE, _, refs, o_model, var_type_ctxt) = Step_Specify.initialisePIDE formalise
    56   (*              ^^ TODO remove with cleanup in nxt_specify_init_calc *)
    57 (*
    58   TODO: present "Problem hdlPIDE" via PIDE
    59 *)
    60   in
    61     thy
    62       |> Refs_Data.put refs
    63       |> OMod_Data.put o_model
    64       |> Ctxt_Data.put var_type_ctxt
    65   end;
    66 
    67 (*
    68 fun load_formalisation parser (files, _) thy =
    69   let
    70     val ([{lines, pos, ...}: Token.file], thy') = files thy;
    71   in
    72     store_and_show
    73       (ParseC.read_out_formalise (fst (parser (fst (ParseC.tokenize_formalise pos (cat_lines lines))))))
    74         thy'
    75   end;
    76 *)
    77 fun load_formalisation parse (files, _) thy =
    78   let
    79     val ([{lines, pos, ...}: Token.file], thy') = files thy;
    80     val formalise = lines
    81       |> cat_lines 
    82       |> ParseC.tokenize_formalise pos
    83       |> fst
    84       |> parse
    85       |> fst
    86       |> ParseC.read_out_formalise
    87       |> store_and_show
    88 (** )val _ = @{print} {a = "### load_formalisation \<rightarrow>", formalise = formalise}( **)
    89   in
    90     formalise thy'
    91   end;
    92 
    93 
    94 end