src/Tools/Code/code_printer.ML
changeset 55148 7e1b7cb54114
parent 55147 bce3dbc11f95
child 55150 0940309ed8f1
equal deleted inserted replaced
55147:bce3dbc11f95 55148:7e1b7cb54114
   283 (* generic syntax *)
   283 (* generic syntax *)
   284 
   284 
   285 type simple_const_syntax = int * ((fixity -> iterm -> Pretty.T)
   285 type simple_const_syntax = int * ((fixity -> iterm -> Pretty.T)
   286   -> fixity -> (iterm * itype) list -> Pretty.T);
   286   -> fixity -> (iterm * itype) list -> Pretty.T);
   287 
   287 
   288 type complex_const_syntax = int * (string list * (literals -> string list
   288 type complex_const_syntax = int * (literals
   289   -> (var_ctxt -> fixity -> iterm -> Pretty.T)
   289   -> (var_ctxt -> fixity -> iterm -> Pretty.T)
   290     -> thm option -> var_ctxt -> fixity -> (iterm * itype) list -> Pretty.T));
   290     -> thm option -> var_ctxt -> fixity -> (iterm * itype) list -> Pretty.T);
   291 
   291 
   292 datatype const_syntax = plain_const_syntax of string
   292 datatype const_syntax = plain_const_syntax of string
   293   | complex_const_syntax of complex_const_syntax;
   293   | complex_const_syntax of complex_const_syntax;
   294 
   294 
   295 fun requires_args (plain_const_syntax _) = 0
   295 fun requires_args (plain_const_syntax _) = 0
   296   | requires_args (complex_const_syntax (k, _)) = k;
   296   | requires_args (complex_const_syntax (k, _)) = k;
   297 
   297 
   298 fun simple_const_syntax syn =
   298 fun simple_const_syntax syn =
   299   complex_const_syntax
   299   complex_const_syntax
   300     (apsnd (fn f => ([], (fn _ => fn _ => fn print => fn _ => fn vars => f (print vars)))) syn);
   300     (apsnd (fn f => fn _ => fn print => fn _ => fn vars => f (print vars)) syn);
   301 
   301 
   302 type activated_complex_const_syntax = int * ((var_ctxt -> fixity -> iterm -> Pretty.T)
   302 type activated_complex_const_syntax = int * ((var_ctxt -> fixity -> iterm -> Pretty.T)
   303   -> thm option -> var_ctxt -> fixity -> (iterm * itype) list -> Pretty.T)
   303   -> thm option -> var_ctxt -> fixity -> (iterm * itype) list -> Pretty.T)
   304 
   304 
   305 datatype activated_const_syntax = Plain_const_syntax of int * string
   305 datatype activated_const_syntax = Plain_const_syntax of int * string
   306   | Complex_const_syntax of activated_complex_const_syntax;
   306   | Complex_const_syntax of activated_complex_const_syntax;
   307 
   307 
   308 fun activate_const_syntax thy literals c (plain_const_syntax s) =
   308 fun activate_const_syntax thy literals c (plain_const_syntax s) =
   309       Plain_const_syntax (Code.args_number thy c, s)
   309       Plain_const_syntax (Code.args_number thy c, s)
   310   | activate_const_syntax thy literals c (complex_const_syntax (n, (cs, f)))=
   310   | activate_const_syntax thy literals c (complex_const_syntax (n, f))=
   311       Complex_const_syntax (n, f literals cs);
   311       Complex_const_syntax (n, f literals);
   312 
   312 
   313 fun gen_print_app print_app_expr print_term const_syntax some_thm vars fxy
   313 fun gen_print_app print_app_expr print_term const_syntax some_thm vars fxy
   314     (app as ({ sym, dom, ... }, ts)) =
   314     (app as ({ sym, dom, ... }, ts)) =
   315   case sym of
   315   case sym of
   316     Code_Symbol.Constant const => (case const_syntax const of
   316     Code_Symbol.Constant const => (case const_syntax const of