src/Pure/Isar/proof_context.ML
changeset 38238 43c13eb0d842
parent 38237 8b0383334031
child 38328 36afb56ec49e
equal deleted inserted replaced
38237:8b0383334031 38238:43c13eb0d842
   736 
   736 
   737 local
   737 local
   738 
   738 
   739 fun parse_sort ctxt text =
   739 fun parse_sort ctxt text =
   740   let
   740   let
   741     val (syms, pos) = Syntax.parse_token Markup.sort text;
   741     val (syms, pos) = Syntax.parse_token ctxt Markup.sort text;
   742     val S = Syntax.standard_parse_sort ctxt (syn_of ctxt) (syms, pos)
   742     val S = Syntax.standard_parse_sort ctxt (syn_of ctxt) (syms, pos)
   743       handle ERROR msg => cat_error msg ("Failed to parse sort" ^ Position.str_of pos)
   743       handle ERROR msg => cat_error msg ("Failed to parse sort" ^ Position.str_of pos)
   744   in Type.minimize_sort (tsig_of ctxt) S end;
   744   in Type.minimize_sort (tsig_of ctxt) S end;
   745 
   745 
   746 fun parse_typ ctxt text =
   746 fun parse_typ ctxt text =
   747   let
   747   let
   748     val (syms, pos) = Syntax.parse_token Markup.typ text;
   748     val (syms, pos) = Syntax.parse_token ctxt Markup.typ text;
   749     val T = Syntax.standard_parse_typ ctxt (syn_of ctxt) (get_sort ctxt) (syms, pos)
   749     val T = Syntax.standard_parse_typ ctxt (syn_of ctxt) (get_sort ctxt) (syms, pos)
   750       handle ERROR msg => cat_error msg ("Failed to parse type" ^ Position.str_of pos);
   750       handle ERROR msg => cat_error msg ("Failed to parse type" ^ Position.str_of pos);
   751   in T end;
   751   in T end;
   752 
   752 
   753 fun parse_term T ctxt text =
   753 fun parse_term T ctxt text =
   754   let
   754   let
   755     val {get_sort, map_const, map_free} = term_context ctxt;
   755     val {get_sort, map_const, map_free} = term_context ctxt;
   756 
   756 
   757     val (T', _) = Type_Infer.paramify_dummies T 0;
   757     val (T', _) = Type_Infer.paramify_dummies T 0;
   758     val (markup, kind) = if T' = propT then (Markup.prop, "proposition") else (Markup.term, "term");
   758     val (markup, kind) = if T' = propT then (Markup.prop, "proposition") else (Markup.term, "term");
   759     val (syms, pos) = Syntax.parse_token markup text;
   759     val (syms, pos) = Syntax.parse_token ctxt markup text;
   760 
   760 
   761     fun check t = (Syntax.check_term ctxt (Type_Infer.constrain T' t); NONE)
   761     fun check t = (Syntax.check_term ctxt (Type_Infer.constrain T' t); NONE)
   762       handle ERROR msg => SOME msg;
   762       handle ERROR msg => SOME msg;
   763     val t =
   763     val t =
   764       Syntax.standard_parse_term (Syntax.pp ctxt) check get_sort map_const map_free
   764       Syntax.standard_parse_term (Syntax.pp ctxt) check get_sort map_const map_free