src/Pure/ML/ml_context.ML
changeset 25142 57c717b9dd59
parent 24695 2892482a4e62
child 25204 36cf92f63a44
equal deleted inserted replaced
25141:8072027dc4bb 25142:57c717b9dd59
   196 fun use path = eval_wrapper (Path.implode path) true (File.read path);
   196 fun use path = eval_wrapper (Path.implode path) true (File.read path);
   197 
   197 
   198 
   198 
   199 (* basic antiquotations *)
   199 (* basic antiquotations *)
   200 
   200 
       
   201 local
       
   202 
       
   203 fun context x = (Scan.state >> Context.proof_of) x;
       
   204 
   201 val _ = value_antiq "context" (Scan.succeed ("context", "ML_Context.the_local_context ()"));
   205 val _ = value_antiq "context" (Scan.succeed ("context", "ML_Context.the_local_context ()"));
       
   206 
       
   207 val _ = inline_antiq "sort" (context -- Scan.lift Args.name >> (fn (ctxt, s) =>
       
   208   ML_Syntax.atomic (ML_Syntax.print_sort (Syntax.read_sort ctxt s))));
   202 
   209 
   203 val _ = inline_antiq "typ" (Args.typ >> (ML_Syntax.atomic o ML_Syntax.print_typ));
   210 val _ = inline_antiq "typ" (Args.typ >> (ML_Syntax.atomic o ML_Syntax.print_typ));
   204 val _ = inline_antiq "term" (Args.term >> (ML_Syntax.atomic o ML_Syntax.print_term));
   211 val _ = inline_antiq "term" (Args.term >> (ML_Syntax.atomic o ML_Syntax.print_term));
   205 val _ = inline_antiq "prop" (Args.prop >> (ML_Syntax.atomic o ML_Syntax.print_term));
   212 val _ = inline_antiq "prop" (Args.prop >> (ML_Syntax.atomic o ML_Syntax.print_term));
   206 
   213 
   214 
   221 
   215 val _ = value_antiq "cprop" (Args.prop >> (fn t =>
   222 val _ = value_antiq "cprop" (Args.prop >> (fn t =>
   216   ("cprop",
   223   ("cprop",
   217     "Thm.cterm_of (ML_Context.the_context ()) " ^ ML_Syntax.atomic (ML_Syntax.print_term t))));
   224     "Thm.cterm_of (ML_Context.the_context ()) " ^ ML_Syntax.atomic (ML_Syntax.print_term t))));
   218 
   225 
   219 val _ = inline_antiq "type_name"
   226 fun type_ syn = (context -- Scan.lift Args.name >> (fn (ctxt, c) =>
   220   ((Scan.state >> Context.proof_of) -- Scan.lift Args.name >> (fn (ctxt, c) =>
       
   221     #1 (Term.dest_Type (ProofContext.read_tyname ctxt c))
   227     #1 (Term.dest_Type (ProofContext.read_tyname ctxt c))
       
   228     |> syn ? Sign.base_name
   222     |> ML_Syntax.print_string));
   229     |> ML_Syntax.print_string));
       
   230 
       
   231 val _ = inline_antiq "type_name" (type_ false);
       
   232 val _ = inline_antiq "type_syntax" (type_ true);
   223 
   233 
   224 fun const syn = (Scan.state >> Context.proof_of) -- Scan.lift Args.name >> (fn (ctxt, c) =>
   234 fun const syn = (Scan.state >> Context.proof_of) -- Scan.lift Args.name >> (fn (ctxt, c) =>
   225   #1 (Term.dest_Const (Consts.read_const (ProofContext.consts_of ctxt) c))
   235   #1 (Term.dest_Const (Consts.read_const (ProofContext.consts_of ctxt) c))
   226   |> syn ? ProofContext.const_syntax_name ctxt
   236   |> syn ? ProofContext.const_syntax_name ctxt
   227   |> ML_Syntax.print_string);
   237   |> ML_Syntax.print_string);
   228 
   238 
   229 val _ = inline_antiq "const_name" (const false);
   239 val _ = inline_antiq "const_name" (const false);
   230 val _ = inline_antiq "const_syntax" (const true);
   240 val _ = inline_antiq "const_syntax" (const true);
   231 
   241 
       
   242 in val _ = () end;
   232 
   243 
   233 
   244 
   234 (** fact references **)
   245 (** fact references **)
   235 
   246 
   236 fun thm name = ProofContext.get_thm (the_local_context ()) (Name name);
   247 fun thm name = ProofContext.get_thm (the_local_context ()) (Name name);