src/Pure/Thy/thy_output.ML
changeset 56204 f70e69208a8c
parent 56201 dd2df97b379b
child 56275 600f432ab556
equal deleted inserted replaced
56203:76c72f4d0667 56204:f70e69208a8c
   435 (** setup default output **)
   435 (** setup default output **)
   436 
   436 
   437 (* options *)
   437 (* options *)
   438 
   438 
   439 val _ = Theory.setup
   439 val _ = Theory.setup
   440  (add_option (Binding.name "show_types") (Config.put show_types o boolean) #>
   440  (add_option @{binding show_types} (Config.put show_types o boolean) #>
   441   add_option (Binding.name "show_sorts") (Config.put show_sorts o boolean) #>
   441   add_option @{binding show_sorts} (Config.put show_sorts o boolean) #>
   442   add_option (Binding.name "show_structs") (Config.put show_structs o boolean) #>
   442   add_option @{binding show_structs} (Config.put show_structs o boolean) #>
   443   add_option (Binding.name "show_question_marks") (Config.put show_question_marks o boolean) #>
   443   add_option @{binding show_question_marks} (Config.put show_question_marks o boolean) #>
   444   add_option (Binding.name "show_abbrevs") (Config.put show_abbrevs o boolean) #>
   444   add_option @{binding show_abbrevs} (Config.put show_abbrevs o boolean) #>
   445   add_option (Binding.name "names_long") (Config.put Name_Space.names_long o boolean) #>
   445   add_option @{binding names_long} (Config.put Name_Space.names_long o boolean) #>
   446   add_option (Binding.name "names_short") (Config.put Name_Space.names_short o boolean) #>
   446   add_option @{binding names_short} (Config.put Name_Space.names_short o boolean) #>
   447   add_option (Binding.name "names_unique") (Config.put Name_Space.names_unique o boolean) #>
   447   add_option @{binding names_unique} (Config.put Name_Space.names_unique o boolean) #>
   448   add_option (Binding.name "eta_contract") (Config.put Syntax_Trans.eta_contract o boolean) #>
   448   add_option @{binding eta_contract} (Config.put Syntax_Trans.eta_contract o boolean) #>
   449   add_option (Binding.name "display") (Config.put display o boolean) #>
   449   add_option @{binding display} (Config.put display o boolean) #>
   450   add_option (Binding.name "break") (Config.put break o boolean) #>
   450   add_option @{binding break} (Config.put break o boolean) #>
   451   add_option (Binding.name "quotes") (Config.put quotes o boolean) #>
   451   add_option @{binding quotes} (Config.put quotes o boolean) #>
   452   add_option (Binding.name "mode") (add_wrapper o Print_Mode.with_modes o single) #>
   452   add_option @{binding mode} (add_wrapper o Print_Mode.with_modes o single) #>
   453   add_option (Binding.name "margin") (add_wrapper o setmp_CRITICAL Pretty.margin_default o integer) #>
   453   add_option @{binding margin} (add_wrapper o setmp_CRITICAL Pretty.margin_default o integer) #>
   454   add_option (Binding.name "indent") (Config.put indent o integer) #>
   454   add_option @{binding indent} (Config.put indent o integer) #>
   455   add_option (Binding.name "source") (Config.put source o boolean) #>
   455   add_option @{binding source} (Config.put source o boolean) #>
   456   add_option (Binding.name "goals_limit") (Config.put Goal_Display.goals_limit o integer));
   456   add_option @{binding goals_limit} (Config.put Goal_Display.goals_limit o integer));
   457 
   457 
   458 
   458 
   459 (* basic pretty printing *)
   459 (* basic pretty printing *)
   460 
   460 
   461 fun tweak_line ctxt s =
   461 fun tweak_line ctxt s =
   563 fun basic_entity name scan = basic_entities name (scan >> single);
   563 fun basic_entity name scan = basic_entities name (scan >> single);
   564 
   564 
   565 in
   565 in
   566 
   566 
   567 val _ = Theory.setup
   567 val _ = Theory.setup
   568  (basic_entities_style (Binding.name "thm") (Term_Style.parse -- Attrib.thms) pretty_thm_style #>
   568  (basic_entities_style @{binding thm} (Term_Style.parse -- Attrib.thms) pretty_thm_style #>
   569   basic_entity (Binding.name "prop") (Term_Style.parse -- Args.prop) pretty_term_style #>
   569   basic_entity @{binding prop} (Term_Style.parse -- Args.prop) pretty_term_style #>
   570   basic_entity (Binding.name "term") (Term_Style.parse -- Args.term) pretty_term_style #>
   570   basic_entity @{binding term} (Term_Style.parse -- Args.term) pretty_term_style #>
   571   basic_entity (Binding.name "term_type") (Term_Style.parse -- Args.term) pretty_term_typ #>
   571   basic_entity @{binding term_type} (Term_Style.parse -- Args.term) pretty_term_typ #>
   572   basic_entity (Binding.name "typeof") (Term_Style.parse -- Args.term) pretty_term_typeof #>
   572   basic_entity @{binding typeof} (Term_Style.parse -- Args.term) pretty_term_typeof #>
   573   basic_entity (Binding.name "const") (Args.const {proper = true, strict = false}) pretty_const #>
   573   basic_entity @{binding const} (Args.const {proper = true, strict = false}) pretty_const #>
   574   basic_entity (Binding.name "abbrev") (Scan.lift Args.name_inner_syntax) pretty_abbrev #>
   574   basic_entity @{binding abbrev} (Scan.lift Args.name_inner_syntax) pretty_abbrev #>
   575   basic_entity (Binding.name "typ") Args.typ_abbrev Syntax.pretty_typ #>
   575   basic_entity @{binding typ} Args.typ_abbrev Syntax.pretty_typ #>
   576   basic_entity (Binding.name "class") (Scan.lift Args.name_inner_syntax) pretty_class #>
   576   basic_entity @{binding class} (Scan.lift Args.name_inner_syntax) pretty_class #>
   577   basic_entity (Binding.name "type") (Scan.lift Args.name) pretty_type #>
   577   basic_entity @{binding type} (Scan.lift Args.name) pretty_type #>
   578   basic_entity (Binding.name "text") (Scan.lift Args.name_source_position) pretty_text_report #>
   578   basic_entity @{binding text} (Scan.lift Args.name_source_position) pretty_text_report #>
   579   basic_entities (Binding.name "prf") Attrib.thms (pretty_prf false) #>
   579   basic_entities @{binding prf} Attrib.thms (pretty_prf false) #>
   580   basic_entities (Binding.name "full_prf") Attrib.thms (pretty_prf true) #>
   580   basic_entities @{binding full_prf} Attrib.thms (pretty_prf true) #>
   581   basic_entity (Binding.name "theory") (Scan.lift (Parse.position Args.name)) pretty_theory);
   581   basic_entity @{binding theory} (Scan.lift (Parse.position Args.name)) pretty_theory);
   582 
   582 
   583 end;
   583 end;
   584 
   584 
   585 
   585 
   586 (* goal state *)
   586 (* goal state *)
   598       (Config.put Goal_Display.show_main_goal main ctxt) (proof_state state)]);
   598       (Config.put Goal_Display.show_main_goal main ctxt) (proof_state state)]);
   599 
   599 
   600 in
   600 in
   601 
   601 
   602 val _ = Theory.setup
   602 val _ = Theory.setup
   603  (goal_state (Binding.name "goals") true #>
   603  (goal_state @{binding goals} true #>
   604   goal_state (Binding.name "subgoals") false);
   604   goal_state @{binding subgoals} false);
   605 
   605 
   606 end;
   606 end;
   607 
   607 
   608 
   608 
   609 (* embedded lemma *)
   609 (* embedded lemma *)
   610 
   610 
   611 val _ = Keyword.define ("by", NONE);  (*overlap with command category*)
   611 val _ = Keyword.define ("by", NONE);  (*overlap with command category*)
   612 
   612 
   613 val _ = Theory.setup
   613 val _ = Theory.setup
   614   (antiquotation (Binding.name "lemma")
   614   (antiquotation @{binding lemma}
   615     (Scan.lift (Scan.ahead Parse.not_eof) -- Args.prop --
   615     (Scan.lift (Scan.ahead Parse.not_eof) -- Args.prop --
   616       Scan.lift (Parse.position (Args.$$$ "by") -- Method.parse -- Scan.option Method.parse))
   616       Scan.lift (Parse.position (Args.$$$ "by") -- Method.parse -- Scan.option Method.parse))
   617     (fn {source, context = ctxt, ...} => fn ((prop_token, prop), (((_, by_pos), m1), m2)) =>
   617     (fn {source, context = ctxt, ...} => fn ((prop_token, prop), (((_, by_pos), m1), m2)) =>
   618       let
   618       let
   619         val prop_src = Args.src (Args.name_of_src source) [prop_token];
   619         val prop_src = Args.src (Args.name_of_src source) [prop_token];
   652   ML_Lex.read Position.none en;
   652   ML_Lex.read Position.none en;
   653 
   653 
   654 in
   654 in
   655 
   655 
   656 val _ = Theory.setup
   656 val _ = Theory.setup
   657  (ml_text (Binding.name "ML") (ml_enclose "fn _ => (" ");") #>
   657  (ml_text @{binding ML} (ml_enclose "fn _ => (" ");") #>
   658   ml_text (Binding.name "ML_op") (ml_enclose "fn _ => (op " ");") #>
   658   ml_text @{binding ML_op} (ml_enclose "fn _ => (op " ");") #>
   659   ml_text (Binding.name "ML_type") (ml_enclose "val _ = NONE : (" ") option;") #>
   659   ml_text @{binding ML_type} (ml_enclose "val _ = NONE : (" ") option;") #>
   660   ml_text (Binding.name "ML_structure")
   660   ml_text @{binding ML_structure}
   661     (ml_enclose "functor XXX() = struct structure XX = " " end;") #>
   661     (ml_enclose "functor XXX() = struct structure XX = " " end;") #>
   662 
   662 
   663   ml_text (Binding.name "ML_functor")   (* FIXME formal treatment of functor name (!?) *)
   663   ml_text @{binding ML_functor}   (* FIXME formal treatment of functor name (!?) *)
   664     (fn source =>
   664     (fn source =>
   665       ML_Lex.read Position.none ("ML_Env.check_functor " ^
   665       ML_Lex.read Position.none ("ML_Env.check_functor " ^
   666         ML_Syntax.print_string (#1 (Symbol_Pos.source_content source)))) #>
   666         ML_Syntax.print_string (#1 (Symbol_Pos.source_content source)))) #>
   667 
   667 
   668   ml_text (Binding.name "ML_text") (K []));
   668   ml_text @{binding ML_text} (K []));
   669 
   669 
   670 end;
   670 end;
   671 
   671 
   672 
   672 
   673 (* URLs *)
   673 (* URLs *)
   674 
   674 
   675 val _ = Theory.setup
   675 val _ = Theory.setup
   676   (antiquotation (Binding.name "url") (Scan.lift (Parse.position Parse.name))
   676   (antiquotation @{binding url} (Scan.lift (Parse.position Parse.name))
   677     (fn {context = ctxt, ...} => fn (name, pos) =>
   677     (fn {context = ctxt, ...} => fn (name, pos) =>
   678       (Context_Position.reports ctxt [(pos, Markup.language_path), (pos, Markup.url name)];
   678       (Context_Position.reports ctxt [(pos, Markup.language_path), (pos, Markup.url name)];
   679        enclose "\\url{" "}" name)));
   679        enclose "\\url{" "}" name)));
   680 
   680 
   681 end;
   681 end;