src/Pure/ML/ml_antiquotations.ML
changeset 56251 73e2e1912571
parent 56205 ceb8a93460b7
child 56399 386e4cb7ad68
equal deleted inserted replaced
56250:2c9f841f36b8 56251:73e2e1912571
   119       if is_some (Syntax.lookup_const (Proof_Context.syn_of ctxt) c)
   119       if is_some (Syntax.lookup_const (Proof_Context.syn_of ctxt) c)
   120       then ML_Syntax.print_string c
   120       then ML_Syntax.print_string c
   121       else error ("Unknown syntax const: " ^ quote c ^ Position.here pos))) #>
   121       else error ("Unknown syntax const: " ^ quote c ^ Position.here pos))) #>
   122 
   122 
   123   ML_Antiquotation.inline @{binding const}
   123   ML_Antiquotation.inline @{binding const}
   124     (Args.context -- Scan.lift Args.name_inner_syntax -- Scan.optional
   124     (Args.context -- Scan.lift (Parse.position Args.name_inner_syntax) -- Scan.optional
   125         (Scan.lift (Args.$$$ "(") |-- Parse.enum1' "," Args.typ --| Scan.lift (Args.$$$ ")")) []
   125         (Scan.lift (Args.$$$ "(") |-- Parse.enum1' "," Args.typ --| Scan.lift (Args.$$$ ")")) []
   126       >> (fn ((ctxt, raw_c), Ts) =>
   126       >> (fn ((ctxt, (raw_c, pos)), Ts) =>
   127         let
   127         let
   128           val Const (c, _) =
   128           val Const (c, _) =
   129             Proof_Context.read_const {proper = true, strict = true} ctxt raw_c;
   129             Proof_Context.read_const {proper = true, strict = true} ctxt raw_c;
   130           val consts = Proof_Context.consts_of ctxt;
   130           val consts = Proof_Context.consts_of ctxt;
   131           val n = length (Consts.typargs consts (c, Consts.type_scheme consts c));
   131           val n = length (Consts.typargs consts (c, Consts.type_scheme consts c));
   132           val _ = length Ts <> n andalso
   132           val _ = length Ts <> n andalso
   133             error ("Constant requires " ^ string_of_int n ^ " type argument(s): " ^
   133             error ("Constant requires " ^ string_of_int n ^ " type argument(s): " ^
   134               quote c ^ enclose "(" ")" (commas (replicate n "_")));
   134               quote c ^ enclose "(" ")" (commas (replicate n "_")) ^ Position.here pos);
   135           val const = Const (c, Consts.instance consts (c, Ts));
   135           val const = Const (c, Consts.instance consts (c, Ts));
   136         in ML_Syntax.atomic (ML_Syntax.print_term const) end)));
   136         in ML_Syntax.atomic (ML_Syntax.print_term const) end)));
   137 
   137 
   138 
   138 
   139 (* outer syntax *)
   139 (* outer syntax *)