src/Pure/Isar/toplevel.ML
changeset 7198 680d43e41b0d
parent 7105 dcd7ac72f1e7
child 7308 e01aab03a2a1
equal deleted inserted replaced
7197:3ddf4a55d765 7198:680d43e41b0d
    43   val theory: (theory -> theory) -> transition -> transition
    43   val theory: (theory -> theory) -> transition -> transition
    44   val theory_to_proof: (bool -> theory -> ProofHistory.T) -> transition -> transition
    44   val theory_to_proof: (bool -> theory -> ProofHistory.T) -> transition -> transition
    45   val proof: (ProofHistory.T -> ProofHistory.T) -> transition -> transition
    45   val proof: (ProofHistory.T -> ProofHistory.T) -> transition -> transition
    46   val proof': (bool -> ProofHistory.T -> ProofHistory.T) -> transition -> transition
    46   val proof': (bool -> ProofHistory.T -> ProofHistory.T) -> transition -> transition
    47   val proof_to_theory: (ProofHistory.T -> theory) -> transition -> transition
    47   val proof_to_theory: (ProofHistory.T -> theory) -> transition -> transition
       
    48   val quiet: bool ref
    48   val trace: bool ref
    49   val trace: bool ref
    49   val exn_message: exn -> string
    50   val exn_message: exn -> string
    50   val apply: bool -> transition -> state -> (state * (exn * string) option) option
    51   val apply: bool -> transition -> state -> (state * (exn * string) option) option
    51   val excursion: transition list -> unit
    52   val excursion: transition list -> unit
    52   val excursion_error: transition list -> unit
    53   val excursion_error: transition list -> unit
    74   | str_of_node (Proof _) = "in proof mode";
    75   | str_of_node (Proof _) = "in proof mode";
    75 
    76 
    76 fun print_node (Theory thy) = Pretty.writeln (Pretty.block
    77 fun print_node (Theory thy) = Pretty.writeln (Pretty.block
    77       [Pretty.str "Theory:", Pretty.brk 1, Pretty.str (PureThy.get_name thy),
    78       [Pretty.str "Theory:", Pretty.brk 1, Pretty.str (PureThy.get_name thy),
    78         Pretty.str " =", Pretty.brk 1, Display.pretty_theory thy])
    79         Pretty.str " =", Pretty.brk 1, Display.pretty_theory thy])
    79   | print_node (Proof prf) =
    80   | print_node (Proof prf) = Proof.print_state (ProofHistory.position prf) (ProofHistory.current prf);
    80       (writeln ("Proof: step #" ^ string_of_int (ProofHistory.position prf));
       
    81         Proof.print_state (ProofHistory.current prf));
       
    82 
    81 
    83 
    82 
    84 (* datatype state *)
    83 (* datatype state *)
    85 
    84 
    86 datatype state = State of (node History.T * ((node -> unit) * (node -> unit))) list;
    85 datatype state = State of (node History.T * ((node -> unit) * (node -> unit))) list;
   323 
   322 
   324 
   323 
   325 
   324 
   326 (** toplevel transactions **)
   325 (** toplevel transactions **)
   327 
   326 
       
   327 val quiet = ref false;
   328 val trace = ref false;
   328 val trace = ref false;
   329 
   329 
   330 
   330 
   331 (* print exceptions *)
   331 (* print exceptions *)
   332 
   332 
   368     val _ =
   368     val _ =
   369       if int orelse not int_only then ()
   369       if int orelse not int_only then ()
   370       else warning (command_msg "Executing interactive-only " tr);
   370       else warning (command_msg "Executing interactive-only " tr);
   371     val (result, opt_exn) =
   371     val (result, opt_exn) =
   372       (if ! trace then (writeln (command_msg "" tr); timeap) else I) (apply_trans int trans) state;
   372       (if ! trace then (writeln (command_msg "" tr); timeap) else I) (apply_trans int trans) state;
   373     val _ = if int andalso print then print_state result else ();
   373     val _ = if int andalso print andalso not (! quiet) then print_state result else ();
   374   in (result, apsome (fn UNDEF => type_error tr state | exn => exn) opt_exn) end;
   374   in (result, apsome (fn UNDEF => type_error tr state | exn => exn) opt_exn) end;
   375 
   375 
   376 in
   376 in
   377 
   377 
   378 fun apply int tr st =
   378 fun apply int tr st =