src/Pure/Thy/thy_read.ML
changeset 412 216624270b80
parent 397 48cb3fa4bc59
child 424 f9d7e4fe141a
equal deleted inserted replaced
411:4860901706db 412:216624270b80
     1 (*  Title:      Pure/Thy/thy_read.ML
     1 (*  Title:      Pure/Thy/thy_read.ML
     2     ID:         $Id$
     2     ID:         $Id$
     3     Author:     Sonia Mahjoub / Tobias Nipkow / L C Paulson
     3     Author:     Sonia Mahjoub / Tobias Nipkow / L C Paulson / Carsten Clasohm
     4     Copyright   1993  TU Muenchen
     4     Copyright   1993  TU Muenchen
     5 
     5 
     6 Reading and writing the theory definition files.
     6 Reading and writing the theory definition files.
     7 
     7 
     8 For theory XXX, the  input file is called XXX.thy
     8 For theory XXX, the  input file is called XXX.thy
    13 datatype thy_info = ThyInfo of {name: string, path: string,
    13 datatype thy_info = ThyInfo of {name: string, path: string,
    14                                 children: string list,
    14                                 children: string list,
    15                                 thy_info: string option, ml_info: string option,
    15                                 thy_info: string option, ml_info: string option,
    16                                 theory: Thm.theory option};
    16                                 theory: Thm.theory option};
    17 
    17 
    18 signature THY_READ =
    18 signature READTHY =
    19 sig
    19 sig
    20   datatype basetype = Thy  of string
    20   datatype basetype = Thy  of string
    21                     | File of string
    21                     | File of string
    22 
    22 
    23   val loaded_thys    : thy_info list ref
    23   val loaded_thys    : thy_info list ref
    31   val base_on        : basetype list -> string -> Thm.theory
    31   val base_on        : basetype list -> string -> Thm.theory
    32   val store_theory   : string -> Thm.theory -> unit
    32   val store_theory   : string -> Thm.theory -> unit
    33 end;
    33 end;
    34 
    34 
    35 
    35 
    36 functor ThyReadFun(structure ThyParse: THY_PARSE): THY_READ =
    36 functor ReadthyFUN(structure ThySyn: THY_SYN): READTHY =
    37 struct
    37 struct
    38 
    38 
    39 datatype basetype = Thy  of string
    39 datatype basetype = Thy  of string
    40                   | File of string;
    40                   | File of string;
    41 
    41 
    51 fun out_name thy = "." ^ thy ^ ".thy.ML";
    51 fun out_name thy = "." ^ thy ^ ".thy.ML";
    52 
    52 
    53 (*Read a file specified by thy_file containing theory thy *)
    53 (*Read a file specified by thy_file containing theory thy *)
    54 fun read_thy thy thy_file =
    54 fun read_thy thy thy_file =
    55   let 
    55   let 
    56     open ThyParse;
       
    57     val instream  = open_in thy_file;
    56     val instream  = open_in thy_file;
    58     val outstream = open_out (out_name thy);
    57     val outstream = open_out (out_name thy);
    59   in  
    58   in  
    60     output (outstream, parse_thy pure_syntax (input (instream, 999999)));
    59     output (outstream, ThySyn.parse (input (instream, 999999)));
    61     close_out outstream;
    60     close_out outstream;
    62     close_in instream
    61     close_in instream
    63   end;
    62   end;
    64 
    63 
    65 fun file_exists file =
    64 fun file_exists file =