3 keywords "operation_setup" :: thy_decl % "ML"
10 fun operation_setup_cmd name source (flags as {auto, ...}) ctxt =
13 ML_Context.eval_in (SOME ctxt) ML_Compiler.flags (Input.pos_of source)
14 (ML_Lex.read ("Protocol.add_operation " ^ ML_Syntax.print_string name ^ "(") @
15 enclose (ML_Lex.read_source false source) @
17 ML_Lex.read (print_flags flags))
21 val ML_Types.Fun (arg, res) = ML_Types.ml_type_of ctxt (Input.source_content source)
22 val arg_codec = Classy.resolve @{ML.class codec} arg (Context.Proof ctxt)
23 val res_codec = Classy.resolve @{ML.class codec} res (Context.Proof ctxt)
25 ML_Lex.read "{from_lib=" @ ML_Lex.read arg_codec @ ML_Lex.read "," @
26 ML_Lex.read "to_lib=" @ ML_Lex.read res_codec @ ML_Lex.read "," @
27 ML_Lex.read "action=" @ toks @ ML_Lex.read "}"
35 (Parse.reserved "sequential" || Parse.reserved "bracket" || Parse.reserved "auto") >>
36 (fn flag => join_flags
37 {sequential = flag = "sequential",
38 bracket = flag = "bracket",
39 auto = flag = "auto"})
41 Parse.list parse_flag >> (fn fs => fold (curry op o) fs I)
43 Scan.optional (Args.parens parse_flags) I --
45 Parse.!!! (@{keyword "="} |-- Parse.ML_source)
47 Outer_Syntax.command @{command_keyword "operation_setup"} "define protocol operation in ML"
48 (parse_cmd >> (fn ((flags, name), txt) =>
49 Toplevel.keep (Toplevel.context_of #> operation_setup_cmd name txt (flags default_flags))))