60 Pretty.block [Pretty.quote (Syntax.pretty_term ctxt' t'), Pretty.fbrk, |
60 Pretty.block [Pretty.quote (Syntax.pretty_term ctxt' t'), Pretty.fbrk, |
61 Pretty.str "::", Pretty.brk 1, Pretty.quote (Syntax.pretty_typ ctxt' ty')]) (); |
61 Pretty.str "::", Pretty.brk 1, Pretty.quote (Syntax.pretty_typ ctxt' ty')]) (); |
62 in Pretty.writeln p end; |
62 in Pretty.writeln p end; |
63 |
63 |
64 val opt_modes = |
64 val opt_modes = |
65 Scan.optional (@{keyword "("} |-- Parse.!!! (Scan.repeat1 Parse.name --| @{keyword ")"})) []; |
65 Scan.optional (\<^keyword>\<open>(\<close> |-- Parse.!!! (Scan.repeat1 Parse.name --| \<^keyword>\<open>)\<close>)) []; |
66 |
66 |
67 val opt_evaluator = |
67 val opt_evaluator = |
68 Scan.option (@{keyword "["} |-- Parse.name --| @{keyword "]"}) |
68 Scan.option (\<^keyword>\<open>[\<close> |-- Parse.name --| \<^keyword>\<open>]\<close>) |
69 |
69 |
70 val _ = |
70 val _ = |
71 Outer_Syntax.command @{command_keyword value} "evaluate and print term" |
71 Outer_Syntax.command \<^command_keyword>\<open>value\<close> "evaluate and print term" |
72 (opt_evaluator -- opt_modes -- Parse.term |
72 (opt_evaluator -- opt_modes -- Parse.term |
73 >> (fn ((some_name, modes), t) => Toplevel.keep (value_cmd some_name modes t))); |
73 >> (fn ((some_name, modes), t) => Toplevel.keep (value_cmd some_name modes t))); |
74 |
74 |
75 val _ = Theory.setup |
75 val _ = Theory.setup |
76 (Thy_Output.antiquotation @{binding value} |
76 (Thy_Output.antiquotation \<^binding>\<open>value\<close> |
77 (Scan.lift opt_evaluator -- Term_Style.parse -- Args.term) |
77 (Scan.lift opt_evaluator -- Term_Style.parse -- Args.term) |
78 (fn {source, context, ...} => fn ((some_name, style), t) => Thy_Output.output context |
78 (fn {source, context, ...} => fn ((some_name, style), t) => Thy_Output.output context |
79 (Thy_Output.maybe_pretty_source Thy_Output.pretty_term context source |
79 (Thy_Output.maybe_pretty_source Thy_Output.pretty_term context source |
80 [style (value_maybe_select some_name context t)])) |
80 [style (value_maybe_select some_name context t)])) |
81 #> add_evaluator ("simp", Code_Simp.dynamic_value) |
81 #> add_evaluator ("simp", Code_Simp.dynamic_value) |