src/Tools/Code/code_printer.ML
changeset 35228 ac2cab4583f4
parent 34944 970e1466028d
child 36745 403585a89772
equal deleted inserted replaced
35227:d67857e3a8c0 35228:ac2cab4583f4
     9   type itype = Code_Thingol.itype
     9   type itype = Code_Thingol.itype
    10   type iterm = Code_Thingol.iterm
    10   type iterm = Code_Thingol.iterm
    11   type const = Code_Thingol.const
    11   type const = Code_Thingol.const
    12   type dict = Code_Thingol.dict
    12   type dict = Code_Thingol.dict
    13 
    13 
    14   val eqn_error: thm -> string -> 'a
    14   val eqn_error: thm option -> string -> 'a
    15 
    15 
    16   val @@ : 'a * 'a -> 'a list
    16   val @@ : 'a * 'a -> 'a list
    17   val @| : 'a list * 'a -> 'a list
    17   val @| : 'a list * 'a -> 'a list
    18   val str: string -> Pretty.T
    18   val str: string -> Pretty.T
    19   val concat: Pretty.T list -> Pretty.T
    19   val concat: Pretty.T list -> Pretty.T
    76     -> (int * ((fixity -> 'b -> Pretty.T)
    76     -> (int * ((fixity -> 'b -> Pretty.T)
    77     -> fixity -> 'a list -> Pretty.T)) option * OuterParse.token list
    77     -> fixity -> 'a list -> Pretty.T)) option * OuterParse.token list
    78   val simple_const_syntax: simple_const_syntax -> proto_const_syntax
    78   val simple_const_syntax: simple_const_syntax -> proto_const_syntax
    79   val activate_const_syntax: theory -> literals
    79   val activate_const_syntax: theory -> literals
    80     -> proto_const_syntax -> Code_Thingol.naming -> const_syntax * Code_Thingol.naming
    80     -> proto_const_syntax -> Code_Thingol.naming -> const_syntax * Code_Thingol.naming
    81   val gen_print_app: (thm -> var_ctxt -> const * iterm list -> Pretty.T list)
    81   val gen_print_app: (thm option -> var_ctxt -> const * iterm list -> Pretty.T list)
    82     -> (thm -> var_ctxt -> fixity -> iterm -> Pretty.T)
    82     -> (thm option -> var_ctxt -> fixity -> iterm -> Pretty.T)
    83     -> (string -> const_syntax option)
    83     -> (string -> const_syntax option)
    84     -> thm -> var_ctxt -> fixity -> const * iterm list -> Pretty.T
    84     -> thm option -> var_ctxt -> fixity -> const * iterm list -> Pretty.T
    85   val gen_print_bind: (thm -> var_ctxt -> fixity -> iterm -> Pretty.T)
    85   val gen_print_bind: (thm option -> var_ctxt -> fixity -> iterm -> Pretty.T)
    86     -> thm -> fixity
    86     -> thm option -> fixity
    87     -> iterm -> var_ctxt -> Pretty.T * var_ctxt
    87     -> iterm -> var_ctxt -> Pretty.T * var_ctxt
    88 
    88 
    89   val mk_name_module: Name.context -> string option -> (string -> string option)
    89   val mk_name_module: Name.context -> string option -> (string -> string option)
    90     -> 'a Graph.T -> string -> string
    90     -> 'a Graph.T -> string -> string
    91   val dest_name: string -> string * string
    91   val dest_name: string -> string * string
    94 structure Code_Printer : CODE_PRINTER =
    94 structure Code_Printer : CODE_PRINTER =
    95 struct
    95 struct
    96 
    96 
    97 open Code_Thingol;
    97 open Code_Thingol;
    98 
    98 
    99 fun eqn_error thm s = error (s ^ ",\nin equation " ^ Display.string_of_thm_without_context thm);
    99 fun eqn_error (SOME thm) s = error (s ^ ",\nin equation " ^ Display.string_of_thm_without_context thm)
       
   100   | eqn_error NONE s = error s;
   100 
   101 
   101 (** assembling and printing text pieces **)
   102 (** assembling and printing text pieces **)
   102 
   103 
   103 infixr 5 @@;
   104 infixr 5 @@;
   104 infixr 5 @|;
   105 infixr 5 @|;
   241 
   242 
   242 type simple_const_syntax = int * ((fixity -> iterm -> Pretty.T)
   243 type simple_const_syntax = int * ((fixity -> iterm -> Pretty.T)
   243   -> fixity -> (iterm * itype) list -> Pretty.T);
   244   -> fixity -> (iterm * itype) list -> Pretty.T);
   244 type proto_const_syntax = int * (string list * (literals -> string list
   245 type proto_const_syntax = int * (string list * (literals -> string list
   245   -> (var_ctxt -> fixity -> iterm -> Pretty.T)
   246   -> (var_ctxt -> fixity -> iterm -> Pretty.T)
   246     -> thm -> var_ctxt -> fixity -> (iterm * itype) list -> Pretty.T));
   247     -> thm option -> var_ctxt -> fixity -> (iterm * itype) list -> Pretty.T));
   247 type const_syntax = int * ((var_ctxt -> fixity -> iterm -> Pretty.T)
   248 type const_syntax = int * ((var_ctxt -> fixity -> iterm -> Pretty.T)
   248   -> thm -> var_ctxt -> fixity -> (iterm * itype) list -> Pretty.T);
   249   -> thm option -> var_ctxt -> fixity -> (iterm * itype) list -> Pretty.T);
   249 
   250 
   250 fun simple_const_syntax syn =
   251 fun simple_const_syntax syn =
   251   apsnd (fn f => ([], (fn _ => fn _ => fn print => fn _ => fn vars => f (print vars)))) syn;
   252   apsnd (fn f => ([], (fn _ => fn _ => fn print => fn _ => fn vars => f (print vars)))) syn;
   252 
   253 
   253 fun activate_const_syntax thy literals (n, (cs, f)) naming =
   254 fun activate_const_syntax thy literals (n, (cs, f)) naming =