src/Pure/Isar/toplevel.ML
changeset 7602 2c0f407f80ce
parent 7501 76ed51454609
child 7612 ba11b5db431a
equal deleted inserted replaced
7601:c568799bf21b 7602:2c0f407f80ce
   439   (transition, (transition option,
   439   (transition, (transition option,
   440     (OuterLex.token, (OuterLex.token,
   440     (OuterLex.token, (OuterLex.token,
   441       Position.T * (Symbol.symbol, (string, unit) Source.source) Source.source)
   441       Position.T * (Symbol.symbol, (string, unit) Source.source) Source.source)
   442           Source.source) Source.source) Source.source) Source.source;
   442           Source.source) Source.source) Source.source) Source.source;
   443 
   443 
   444 fun transform_interrupt_isar f x =
       
   445   let val y = ref (None: (transition * isar) option option);
       
   446   in exhibit_interrupt (fn () => y := Some (f x)) (); the (! y) end;
       
   447 
       
   448 fun get_interruptible src =
       
   449   Some (transform_interrupt_isar Source.get_single src)
       
   450     handle Interrupt => None;
       
   451 
       
   452 
   444 
   453 (* apply transformers to global state *)
   445 (* apply transformers to global state *)
   454 
   446 
   455 nonfix >>;
   447 nonfix >>;
   456 
   448 
   460   | Some (state', exn_info) =>
   452   | Some (state', exn_info) =>
   461       (global_state := (state', exn_info);
   453       (global_state := (state', exn_info);
   462         check_stale state'; print_exn exn_info;
   454         check_stale state'; print_exn exn_info;
   463         true));
   455         true));
   464 
   456 
       
   457 (*Note: this is for Poly/ML only, we really do not intend to exhibit
       
   458   interrupts here*)
       
   459 fun get_interrupt src = Some (Source.get_single src) handle Interrupt => None;
       
   460 
   465 fun raw_loop src =
   461 fun raw_loop src =
   466   (case get_interruptible (Source.set_prompt (prompt_state (get_state ())) src) of
   462   (case get_interrupt (Source.set_prompt (prompt_state (get_state ())) src) of
   467     None => (writeln "\nInterrupt."; raw_loop src)
   463     None => (writeln "\nInterrupt."; raw_loop src)
   468   | Some None => ()
   464   | Some None => ()
   469   | Some (Some (tr, src')) => if >> tr then raw_loop src' else ());
   465   | Some (Some (tr, src')) => if >> tr then raw_loop src' else ());
   470 
   466 
   471 
   467