src/Pure/Isar/toplevel.ML
changeset 7308 e01aab03a2a1
parent 7198 680d43e41b0d
child 7501 76ed51454609
equal deleted inserted replaced
7307:c065073cdb34 7308:e01aab03a2a1
    10   datatype node = Theory of theory | Proof of ProofHistory.T
    10   datatype node = Theory of theory | Proof of ProofHistory.T
    11   type state
    11   type state
    12   val toplevel: state
    12   val toplevel: state
    13   val prompt_state_default: state -> string
    13   val prompt_state_default: state -> string
    14   val prompt_state_fn: (state -> string) ref
    14   val prompt_state_fn: (state -> string) ref
       
    15   val print_state_context: state -> unit
    15   val print_state_default: state -> unit
    16   val print_state_default: state -> unit
    16   val print_state_fn: (state -> unit) ref
    17   val print_state_fn: (state -> unit) ref
    17   val print_state: state -> unit
    18   val print_state: state -> unit
    18   exception UNDEF
    19   exception UNDEF
    19   val node_history_of: state -> node History.T
    20   val node_history_of: state -> node History.T
    72   Proof of ProofHistory.T;
    73   Proof of ProofHistory.T;
    73 
    74 
    74 fun str_of_node (Theory _) = "in theory mode"
    75 fun str_of_node (Theory _) = "in theory mode"
    75   | str_of_node (Proof _) = "in proof mode";
    76   | str_of_node (Proof _) = "in proof mode";
    76 
    77 
    77 fun print_node (Theory thy) = Pretty.writeln (Pretty.block
    78 fun print_ctxt thy = Pretty.writeln (Pretty.block
    78       [Pretty.str "Theory:", Pretty.brk 1, Pretty.str (PureThy.get_name thy),
    79   [Pretty.str "Theory:", Pretty.brk 1, Pretty.str (PureThy.get_name thy),
    79         Pretty.str " =", Pretty.brk 1, Display.pretty_theory thy])
    80     Pretty.str " =", Pretty.brk 1, Display.pretty_theory thy]);
    80   | print_node (Proof prf) = Proof.print_state (ProofHistory.position prf) (ProofHistory.current prf);
    81 
       
    82 fun print_node_ctxt (Theory thy) = print_ctxt thy
       
    83   | print_node_ctxt (Proof prf) = print_ctxt (Proof.theory_of (ProofHistory.current prf));
       
    84 
       
    85 fun print_node (Theory thy) = print_ctxt thy
       
    86   | print_node (Proof prf) = Proof.print_state (ProofHistory.position prf)
       
    87       (ProofHistory.current prf);
    81 
    88 
    82 
    89 
    83 (* datatype state *)
    90 (* datatype state *)
    84 
    91 
    85 datatype state = State of (node History.T * ((node -> unit) * (node -> unit))) list;
    92 datatype state = State of (node History.T * ((node -> unit) * (node -> unit))) list;
    98 
   105 
    99 val prompt_state_fn = ref prompt_state_default;
   106 val prompt_state_fn = ref prompt_state_default;
   100 fun prompt_state state = ! prompt_state_fn state;
   107 fun prompt_state state = ! prompt_state_fn state;
   101 
   108 
   102 
   109 
   103 (* print_state hook *)
   110 (* print state *)
   104 
   111 
   105 fun print_topnode (State []) = ()
   112 fun print_topnode _ (State []) = ()
   106   | print_topnode (State ((node, _) :: _)) = print_node (History.current node);
   113   | print_topnode prt (State ((node, _) :: _)) = prt (History.current node);
       
   114 
       
   115 val print_state_context = print_topnode print_node_ctxt;
   107 
   116 
   108 fun print_state_default state =
   117 fun print_state_default state =
   109   let val ref (begin_state, end_state, _) = Goals.current_goals_markers in
   118   let val ref (begin_state, end_state, _) = Goals.current_goals_markers in
   110     if begin_state = "" then () else writeln begin_state;
   119     if begin_state = "" then () else writeln begin_state;
   111     print_topnode state;
   120     print_topnode print_node state;
   112     if end_state = "" then () else writeln end_state
   121     if end_state = "" then () else writeln end_state
   113   end;
   122   end;
   114 
   123 
   115 val print_state_fn = ref print_state_default;
   124 val print_state_fn = ref print_state_default;
   116 fun print_state state = ! print_state_fn state;
   125 fun print_state state = ! print_state_fn state;