src/Tools/Code/code_printer.ML
changeset 37449 034ebe92f090
parent 37242 97097e589715
child 37638 82f9ce5a8274
equal deleted inserted replaced
37448:3bd4b3809bee 37449:034ebe92f090
   254 
   254 
   255 fun activate_const_syntax thy literals (n, (cs, f)) naming =
   255 fun activate_const_syntax thy literals (n, (cs, f)) naming =
   256   fold_map (Code_Thingol.ensure_declared_const thy) cs naming
   256   fold_map (Code_Thingol.ensure_declared_const thy) cs naming
   257   |-> (fn cs' => pair (n, f literals cs'));
   257   |-> (fn cs' => pair (n, f literals cs'));
   258 
   258 
   259 fun gen_print_app print_app_expr print_term syntax_const thm vars fxy (app as ((c, (_, tys)), ts)) =
   259 fun gen_print_app print_app_expr print_term syntax_const thm vars fxy (app as ((c, (_, function_typs)), ts)) =
   260   case syntax_const c
   260   case syntax_const c
   261    of NONE => brackify fxy (print_app_expr thm vars app)
   261    of NONE => brackify fxy (print_app_expr thm vars app)
   262     | SOME (k, print) =>
   262     | SOME (k, print) =>
   263         let
   263         let
   264           fun print' fxy ts = print (print_term thm) thm vars fxy (ts ~~ take k tys);
   264           fun print' fxy ts = print (print_term thm) thm vars fxy (ts ~~ take k function_typs);
   265         in if k = length ts
   265         in if k = length ts
   266           then print' fxy ts
   266           then print' fxy ts
   267         else if k < length ts
   267         else if k < length ts
   268           then case chop k ts of (ts1, ts2) =>
   268           then case chop k ts of (ts1, ts2) =>
   269             brackify fxy (print' APP ts1 :: map (print_term thm vars BR) ts2)
   269             brackify fxy (print' APP ts1 :: map (print_term thm vars BR) ts2)