src/Pure/Syntax/syn_ext.ML
author wenzelm
Wed Jun 29 15:13:40 2005 +0200 (2005-06-29)
changeset 16610 58bf09036a6d
parent 15973 5fd94d84470f
child 18566 20dd2f7dca4b
permissions -rw-r--r--
accomodate advanced trfuns;
wenzelm@240
     1
(*  Title:      Pure/Syntax/syn_ext.ML
wenzelm@240
     2
    ID:         $Id$
wenzelm@911
     3
    Author:     Markus Wenzel and Carsten Clasohm, TU Muenchen
wenzelm@240
     4
wenzelm@240
     5
Syntax extension (internal interface).
wenzelm@240
     6
*)
wenzelm@240
     7
wenzelm@240
     8
signature SYN_EXT0 =
wenzelm@4050
     9
sig
wenzelm@6760
    10
  val dddot_indexname: indexname
wenzelm@6760
    11
  val constrainC: string
wenzelm@240
    12
  val typeT: typ
wenzelm@5690
    13
  val max_pri: int
wenzelm@15754
    14
  val stamp_trfun: stamp -> string * 'a -> string * ('a * stamp)
wenzelm@15754
    15
  val mk_trfun: string * 'a -> string * ('a * stamp)
wenzelm@15754
    16
  val eq_trfun: ('a * stamp) * ('a * stamp) -> bool
wenzelm@15835
    17
  val tokentrans_mode: string -> (string * (string -> string * real)) list ->
wenzelm@15835
    18
    (string * string * (string -> string * real)) list
wenzelm@15835
    19
  val standard_token_classes: string list
wenzelm@4050
    20
end;
wenzelm@240
    21
wenzelm@240
    22
signature SYN_EXT =
wenzelm@4050
    23
sig
wenzelm@240
    24
  include SYN_EXT0
paulson@1510
    25
  val logic: string
paulson@1510
    26
  val args: string
paulson@1510
    27
  val cargs: string
paulson@1510
    28
  val any: string
paulson@1510
    29
  val sprop: string
paulson@1510
    30
  val typ_to_nonterm: typ -> string
paulson@1510
    31
  datatype xsymb =
paulson@1510
    32
    Delim of string |
paulson@1510
    33
    Argument of string * int |
paulson@1510
    34
    Space of string |
paulson@1510
    35
    Bg of int | Brk of int | En
paulson@1510
    36
  datatype xprod = XProd of string * xsymb list * string * int
paulson@1510
    37
  val chain_pri: int
wenzelm@4701
    38
  val delims_of: xprod list -> string list list
paulson@1510
    39
  datatype mfix = Mfix of string * typ * string * int list * int
paulson@1510
    40
  datatype syn_ext =
paulson@1510
    41
    SynExt of {
paulson@1510
    42
      xprods: xprod list,
paulson@1510
    43
      consts: string list,
wenzelm@2913
    44
      prmodes: string list,
wenzelm@16610
    45
      parse_ast_translation: (string * ((theory -> Ast.ast list -> Ast.ast) * stamp)) list,
paulson@1510
    46
      parse_rules: (Ast.ast * Ast.ast) list,
wenzelm@16610
    47
      parse_translation: (string * ((theory -> term list -> term) * stamp)) list,
wenzelm@16610
    48
      print_translation: (string * ((theory -> bool -> typ -> term list -> term) * stamp)) list,
paulson@1510
    49
      print_rules: (Ast.ast * Ast.ast) list,
wenzelm@16610
    50
      print_ast_translation: (string * ((theory -> Ast.ast list -> Ast.ast) * stamp)) list,
wenzelm@6322
    51
      token_translation: (string * string * (string -> string * real)) list}
wenzelm@4054
    52
  val mfix_args: string -> int
wenzelm@12865
    53
  val escape_mfix: string -> string
wenzelm@14903
    54
  val syn_ext': bool -> (string -> bool) -> mfix list ->
wenzelm@16610
    55
    string list -> (string * ((theory -> Ast.ast list -> Ast.ast) * stamp)) list *
wenzelm@16610
    56
    (string * ((theory -> term list -> term) * stamp)) list *
wenzelm@16610
    57
    (string * ((theory -> bool -> typ -> term list -> term) * stamp)) list *
wenzelm@16610
    58
    (string * ((theory -> Ast.ast list -> Ast.ast) * stamp)) list
wenzelm@6322
    59
    -> (string * string * (string -> string * real)) list
paulson@1510
    60
    -> (Ast.ast * Ast.ast) list * (Ast.ast * Ast.ast) list -> syn_ext
wenzelm@14903
    61
  val syn_ext: mfix list -> string list ->
wenzelm@16610
    62
    (string * ((theory -> Ast.ast list -> Ast.ast) * stamp)) list *
wenzelm@16610
    63
    (string * ((theory -> term list -> term) * stamp)) list *
wenzelm@16610
    64
    (string * ((theory -> bool -> typ -> term list -> term) * stamp)) list *
wenzelm@16610
    65
    (string * ((theory -> Ast.ast list -> Ast.ast) * stamp)) list
wenzelm@6322
    66
    -> (string * string * (string -> string * real)) list
paulson@1510
    67
    -> (Ast.ast * Ast.ast) list * (Ast.ast * Ast.ast) list -> syn_ext
wenzelm@14903
    68
  val syn_ext_const_names: string list -> syn_ext
wenzelm@14903
    69
  val syn_ext_rules: (Ast.ast * Ast.ast) list * (Ast.ast * Ast.ast) list -> syn_ext
wenzelm@14903
    70
  val syn_ext_trfuns:
wenzelm@15754
    71
    (string * ((Ast.ast list -> Ast.ast) * stamp)) list *
wenzelm@15754
    72
    (string * ((term list -> term) * stamp)) list *
wenzelm@15754
    73
    (string * ((bool -> typ -> term list -> term) * stamp)) list *
wenzelm@15754
    74
    (string * ((Ast.ast list -> Ast.ast) * stamp)) list -> syn_ext
wenzelm@16610
    75
  val syn_ext_advanced_trfuns:
wenzelm@16610
    76
    (string * ((theory -> Ast.ast list -> Ast.ast) * stamp)) list *
wenzelm@16610
    77
    (string * ((theory -> term list -> term) * stamp)) list *
wenzelm@16610
    78
    (string * ((theory -> bool -> typ -> term list -> term) * stamp)) list *
wenzelm@16610
    79
    (string * ((theory -> Ast.ast list -> Ast.ast) * stamp)) list -> syn_ext
wenzelm@14903
    80
  val syn_ext_tokentrfuns: (string * string * (string -> string * real)) list -> syn_ext
wenzelm@15835
    81
  val standard_token_markers: string list
paulson@1510
    82
  val pure_ext: syn_ext
wenzelm@4050
    83
end;
wenzelm@240
    84
wenzelm@15754
    85
structure SynExt: SYN_EXT =
wenzelm@240
    86
struct
wenzelm@240
    87
wenzelm@2694
    88
wenzelm@240
    89
(** misc definitions **)
wenzelm@240
    90
wenzelm@7472
    91
val dddot_indexname = ("dddot", 0);
wenzelm@6760
    92
val constrainC = "_constrain";
wenzelm@6760
    93
wenzelm@6760
    94
wenzelm@240
    95
(* syntactic categories *)
wenzelm@240
    96
wenzelm@240
    97
val logic = "logic";
wenzelm@240
    98
val logicT = Type (logic, []);
wenzelm@240
    99
wenzelm@240
   100
val args = "args";
clasohm@1178
   101
val cargs = "cargs";
wenzelm@240
   102
clasohm@330
   103
val typeT = Type ("type", []);
wenzelm@240
   104
clasohm@764
   105
val sprop = "#prop";
clasohm@764
   106
val spropT = Type (sprop, []);
wenzelm@240
   107
clasohm@764
   108
val any = "any";
clasohm@624
   109
val anyT = Type (any, []);
clasohm@624
   110
wenzelm@780
   111
wenzelm@240
   112
wenzelm@240
   113
(** datatype xprod **)
wenzelm@240
   114
wenzelm@240
   115
(*Delim s: delimiter s
wenzelm@240
   116
  Argument (s, p): nonterminal s requiring priority >= p, or valued token
wenzelm@240
   117
  Space s: some white space for printing
wenzelm@240
   118
  Bg, Brk, En: blocks and breaks for pretty printing*)
wenzelm@240
   119
wenzelm@240
   120
datatype xsymb =
wenzelm@240
   121
  Delim of string |
wenzelm@240
   122
  Argument of string * int |
wenzelm@240
   123
  Space of string |
wenzelm@240
   124
  Bg of int | Brk of int | En;
wenzelm@240
   125
wenzelm@12513
   126
fun is_delim (Delim _) = true
wenzelm@12513
   127
  | is_delim _ = false;
wenzelm@12513
   128
wenzelm@12513
   129
fun is_terminal (Delim _) = true
wenzelm@12513
   130
  | is_terminal (Argument (s, _)) = Lexicon.is_terminal s
wenzelm@12513
   131
  | is_terminal _ = false;
wenzelm@12513
   132
wenzelm@12513
   133
fun is_argument (Argument _) = true
wenzelm@12513
   134
  | is_argument _ = false;
wenzelm@12513
   135
wenzelm@12513
   136
fun is_index (Argument ("index", _)) = true
wenzelm@12513
   137
  | is_index _ = false;
wenzelm@12513
   138
wenzelm@12513
   139
val index = Argument ("index", 1000);
wenzelm@12513
   140
wenzelm@240
   141
wenzelm@240
   142
(*XProd (lhs, syms, c, p):
wenzelm@240
   143
    lhs: name of nonterminal on the lhs of the production
wenzelm@240
   144
    syms: list of symbols on the rhs of the production
wenzelm@240
   145
    c: head of parse tree
wenzelm@240
   146
    p: priority of this production*)
wenzelm@240
   147
wenzelm@240
   148
datatype xprod = XProd of string * xsymb list * string * int;
wenzelm@240
   149
wenzelm@240
   150
val max_pri = 1000;   (*maximum legal priority*)
wenzelm@240
   151
val chain_pri = ~1;   (*dummy for chain productions*)
wenzelm@240
   152
wenzelm@240
   153
wenzelm@240
   154
(* delims_of *)
wenzelm@240
   155
wenzelm@240
   156
fun delims_of xprods =
wenzelm@240
   157
  let
skalberg@15531
   158
    fun del_of (Delim s) = SOME s
skalberg@15531
   159
      | del_of _ = NONE;
wenzelm@240
   160
wenzelm@240
   161
    fun dels_of (XProd (_, xsymbs, _, _)) =
skalberg@15570
   162
      List.mapPartial del_of xsymbs;
wenzelm@240
   163
  in
skalberg@15570
   164
    map Symbol.explode (distinct (List.concat (map dels_of xprods)))
wenzelm@240
   165
  end;
wenzelm@240
   166
wenzelm@240
   167
wenzelm@240
   168
wenzelm@240
   169
(** datatype mfix **)
wenzelm@240
   170
wenzelm@240
   171
(*Mfix (sy, ty, c, ps, p):
wenzelm@240
   172
    sy: rhs of production as symbolic string
wenzelm@240
   173
    ty: type description of production
wenzelm@240
   174
    c: head of parse tree
wenzelm@240
   175
    ps: priorities of arguments in sy
wenzelm@240
   176
    p: priority of production*)
wenzelm@240
   177
wenzelm@240
   178
datatype mfix = Mfix of string * typ * string * int list * int;
wenzelm@240
   179
wenzelm@12513
   180
fun err_in_mfix msg (Mfix (sy, _, const, _, _)) =
wenzelm@12513
   181
  error ((if msg = "" then "" else msg ^ "\n") ^
wenzelm@12513
   182
    "in mixfix annotation " ^ quote sy ^ " for " ^ quote const);
wenzelm@12513
   183
wenzelm@240
   184
wenzelm@240
   185
(* typ_to_nonterm *)
wenzelm@240
   186
clasohm@865
   187
fun typ_to_nt _ (Type (c, _)) = c
clasohm@865
   188
  | typ_to_nt default _ = default;
clasohm@865
   189
clasohm@764
   190
(*get nonterminal for rhs*)
clasohm@865
   191
val typ_to_nonterm = typ_to_nt any;
wenzelm@240
   192
clasohm@764
   193
(*get nonterminal for lhs*)
clasohm@865
   194
val typ_to_nonterm1 = typ_to_nt logic;
wenzelm@240
   195
wenzelm@240
   196
wenzelm@12513
   197
(* read_mixfix *)
wenzelm@4050
   198
wenzelm@4050
   199
local
wenzelm@12513
   200
  fun is_meta c = c mem ["(", ")", "/", "_", "\\<index>"];
wenzelm@4050
   201
wenzelm@4701
   202
  val scan_delim_char =
wenzelm@4701
   203
    $$ "'" |-- Scan.one ((not o Symbol.is_blank) andf Symbol.not_eof) ||
wenzelm@4701
   204
    Scan.one ((not o is_meta) andf (not o Symbol.is_blank) andf Symbol.not_eof);
wenzelm@4050
   205
wenzelm@14819
   206
  fun read_int ["0", "0"] = ~1
wenzelm@14819
   207
    | read_int cs = #1 (Library.read_int cs);
wenzelm@14819
   208
wenzelm@4050
   209
  val scan_sym =
wenzelm@4050
   210
    $$ "_" >> K (Argument ("", 0)) ||
wenzelm@12513
   211
    $$ "\\<index>" >> K index ||
wenzelm@14819
   212
    $$ "(" |-- Scan.any Symbol.is_digit >> (Bg o read_int) ||
wenzelm@4050
   213
    $$ ")" >> K En ||
wenzelm@4050
   214
    $$ "/" -- $$ "/" >> K (Brk ~1) ||
wenzelm@4701
   215
    $$ "/" |-- Scan.any Symbol.is_blank >> (Brk o length) ||
wenzelm@4701
   216
    Scan.any1 Symbol.is_blank >> (Space o implode) ||
wenzelm@4701
   217
    Scan.repeat1 scan_delim_char >> (Delim o implode);
wenzelm@4050
   218
wenzelm@4050
   219
  val scan_symb =
skalberg@15531
   220
    scan_sym >> SOME ||
skalberg@15531
   221
    $$ "'" -- Scan.one Symbol.is_blank >> K NONE;
wenzelm@4050
   222
wenzelm@4701
   223
  val scan_symbs = Scan.repeat scan_symb --| Scan.ahead (Scan.one (not_equal "'"));
wenzelm@15973
   224
  val read_symbs = List.mapPartial I o the o Scan.read Symbol.stopper scan_symbs;
wenzelm@12513
   225
wenzelm@12513
   226
  fun unique_index xsymbs =
skalberg@15570
   227
    if length (List.filter is_index xsymbs) <= 1 then xsymbs
wenzelm@12513
   228
    else error "Duplicate index arguments (\\<index>)";
wenzelm@4050
   229
in
wenzelm@12513
   230
  val read_mixfix = unique_index o read_symbs o Symbol.explode;
skalberg@15570
   231
  val mfix_args = length o List.filter is_argument o read_mixfix;
wenzelm@12865
   232
  val escape_mfix = implode o map (fn s => if is_meta s then "'" ^ s else s) o Symbol.explode;
wenzelm@4050
   233
end;
wenzelm@4050
   234
wenzelm@4050
   235
wenzelm@240
   236
(* mfix_to_xprod *)
wenzelm@240
   237
wenzelm@14903
   238
fun mfix_to_xprod convert is_logtype (mfix as Mfix (sy, typ, const, pris, pri)) =
wenzelm@240
   239
  let
wenzelm@240
   240
    fun check_pri p =
wenzelm@240
   241
      if p >= 0 andalso p <= max_pri then ()
wenzelm@12513
   242
      else err_in_mfix ("Precedence out of range: " ^ string_of_int p) mfix;
wenzelm@240
   243
wenzelm@240
   244
    fun blocks_ok [] 0 = true
wenzelm@240
   245
      | blocks_ok [] _ = false
wenzelm@240
   246
      | blocks_ok (Bg _ :: syms) n = blocks_ok syms (n + 1)
wenzelm@240
   247
      | blocks_ok (En :: _) 0 = false
wenzelm@240
   248
      | blocks_ok (En :: syms) n = blocks_ok syms (n - 1)
wenzelm@240
   249
      | blocks_ok (_ :: syms) n = blocks_ok syms n;
wenzelm@240
   250
wenzelm@240
   251
    fun check_blocks syms =
wenzelm@240
   252
      if blocks_ok syms 0 then ()
wenzelm@12513
   253
      else err_in_mfix "Unbalanced block parentheses" mfix;
wenzelm@240
   254
wenzelm@240
   255
wenzelm@240
   256
    val cons_fst = apfst o cons;
wenzelm@240
   257
wenzelm@240
   258
    fun add_args [] ty [] = ([], typ_to_nonterm1 ty)
wenzelm@12513
   259
      | add_args [] _ _ = err_in_mfix "Too many precedences" mfix
wenzelm@12513
   260
      | add_args ((arg as Argument ("index", _)) :: syms) ty ps =
wenzelm@12513
   261
          cons_fst arg (add_args syms ty ps)
wenzelm@240
   262
      | add_args (Argument _ :: syms) (Type ("fun", [ty, tys])) [] =
wenzelm@240
   263
          cons_fst (Argument (typ_to_nonterm ty, 0)) (add_args syms tys [])
wenzelm@240
   264
      | add_args (Argument _ :: syms) (Type ("fun", [ty, tys])) (p :: ps) =
wenzelm@240
   265
          cons_fst (Argument (typ_to_nonterm ty, p)) (add_args syms tys ps)
wenzelm@240
   266
      | add_args (Argument _ :: _) _ _ =
wenzelm@12513
   267
          err_in_mfix "More arguments than in corresponding type" mfix
wenzelm@240
   268
      | add_args (sym :: syms) ty ps = cons_fst sym (add_args syms ty ps);
wenzelm@240
   269
wenzelm@240
   270
    fun rem_pri (Argument (s, _)) = Argument (s, chain_pri)
wenzelm@240
   271
      | rem_pri sym = sym;
wenzelm@240
   272
wenzelm@4054
   273
    fun logify_types copy_prod (a as (Argument (s, p))) =
wenzelm@14903
   274
          if s <> "prop" andalso is_logtype s then Argument (logic, p) else a
wenzelm@4054
   275
      | logify_types _ a = a;
wenzelm@240
   276
wenzelm@2364
   277
wenzelm@12513
   278
    val raw_symbs = read_mixfix sy handle ERROR => err_in_mfix "" mfix;
skalberg@15570
   279
    val args = List.filter (fn Argument _ => true | _ => false) raw_symbs;
wenzelm@12513
   280
    val (const', typ', parse_rules) =
wenzelm@12513
   281
      if not (exists is_index args) then (const, typ, [])
wenzelm@12513
   282
      else
wenzelm@12513
   283
        let
wenzelm@14697
   284
          val indexed_const = if const <> "" then "_indexed_" ^ const
wenzelm@12513
   285
            else err_in_mfix "Missing constant name for indexed syntax" mfix;
wenzelm@14697
   286
          val rangeT = Term.range_type typ handle Match =>
wenzelm@12513
   287
            err_in_mfix "Missing structure argument for indexed syntax" mfix;
wenzelm@12513
   288
wenzelm@14697
   289
          val xs = map Ast.Variable (Term.invent_names [] "xa" (length args - 1));
wenzelm@14697
   290
          val (xs1, xs2) = Library.splitAt (Library.find_index is_index args, xs);
wenzelm@12513
   291
          val i = Ast.Variable "i";
wenzelm@14697
   292
          val lhs = Ast.mk_appl (Ast.Constant indexed_const)
wenzelm@14697
   293
            (xs1 @ [Ast.mk_appl (Ast.Constant "_index") [i]] @ xs2);
wenzelm@14697
   294
          val rhs = Ast.mk_appl (Ast.Constant const) (i :: xs);
wenzelm@14697
   295
        in (indexed_const, rangeT, [(lhs, rhs)]) end;
wenzelm@12513
   296
wenzelm@12513
   297
    val (symbs, lhs) = add_args raw_symbs typ' pris;
wenzelm@12513
   298
wenzelm@2364
   299
    val copy_prod =
wenzelm@2364
   300
      lhs mem ["prop", "logic"]
wenzelm@2364
   301
        andalso const <> ""
wenzelm@2364
   302
        andalso not (null symbs)
wenzelm@2364
   303
        andalso not (exists is_delim symbs);
wenzelm@2364
   304
    val lhs' =
wenzelm@2364
   305
      if convert andalso not copy_prod then
wenzelm@14903
   306
       (if lhs = "prop" then sprop else if is_logtype lhs then logic else lhs)
wenzelm@2364
   307
      else lhs;
wenzelm@4054
   308
    val symbs' = map (logify_types copy_prod) symbs;
wenzelm@12513
   309
    val xprod = XProd (lhs', symbs', const', pri);
wenzelm@240
   310
skalberg@15570
   311
    val _ = (List.app check_pri pris; check_pri pri; check_blocks symbs');
wenzelm@12513
   312
    val xprod' =
wenzelm@12513
   313
      if Lexicon.is_terminal lhs' then err_in_mfix ("Illegal lhs: " ^ lhs') mfix
wenzelm@12513
   314
      else if const <> "" then xprod
skalberg@15570
   315
      else if length (List.filter is_argument symbs') <> 1 then
wenzelm@12513
   316
        err_in_mfix "Copy production must have exactly one argument" mfix
wenzelm@12513
   317
      else if exists is_terminal symbs' then xprod
wenzelm@12513
   318
      else XProd (lhs', map rem_pri symbs', "", chain_pri);
wenzelm@12513
   319
wenzelm@12513
   320
  in (xprod', parse_rules) end;
wenzelm@12513
   321
wenzelm@240
   322
wenzelm@240
   323
wenzelm@240
   324
(** datatype syn_ext **)
wenzelm@240
   325
wenzelm@240
   326
datatype syn_ext =
wenzelm@240
   327
  SynExt of {
wenzelm@240
   328
    xprods: xprod list,
wenzelm@240
   329
    consts: string list,
wenzelm@2913
   330
    prmodes: string list,
wenzelm@16610
   331
    parse_ast_translation: (string * ((theory -> Ast.ast list -> Ast.ast) * stamp)) list,
paulson@1510
   332
    parse_rules: (Ast.ast * Ast.ast) list,
wenzelm@16610
   333
    parse_translation: (string * ((theory -> term list -> term) * stamp)) list,
wenzelm@16610
   334
    print_translation: (string * ((theory -> bool -> typ -> term list -> term) * stamp)) list,
paulson@1510
   335
    print_rules: (Ast.ast * Ast.ast) list,
wenzelm@16610
   336
    print_ast_translation: (string * ((theory -> Ast.ast list -> Ast.ast) * stamp)) list,
wenzelm@15754
   337
    token_translation: (string * string * (string -> string * real)) list};
wenzelm@240
   338
wenzelm@240
   339
wenzelm@240
   340
(* syn_ext *)
wenzelm@240
   341
wenzelm@14903
   342
fun syn_ext' convert is_logtype mfixes consts trfuns tokentrfuns (parse_rules, print_rules) =
wenzelm@240
   343
  let
wenzelm@240
   344
    val (parse_ast_translation, parse_translation, print_translation,
wenzelm@240
   345
      print_ast_translation) = trfuns;
wenzelm@240
   346
wenzelm@14903
   347
    val (xprods, parse_rules') = map (mfix_to_xprod convert is_logtype) mfixes
skalberg@15570
   348
      |> split_list |> apsnd (rev o List.concat);
wenzelm@12513
   349
    val mfix_consts = distinct (map (fn Mfix x => #3 x) mfixes @ map (fn XProd x => #3 x) xprods);
wenzelm@240
   350
  in
wenzelm@240
   351
    SynExt {
clasohm@624
   352
      xprods = xprods,
wenzelm@11546
   353
      consts = consts union_string mfix_consts,
wenzelm@2913
   354
      prmodes = distinct (map (fn (m, _, _) => m) tokentrfuns),
wenzelm@240
   355
      parse_ast_translation = parse_ast_translation,
wenzelm@12513
   356
      parse_rules = parse_rules' @ parse_rules,
wenzelm@240
   357
      parse_translation = parse_translation,
wenzelm@240
   358
      print_translation = print_translation,
wenzelm@12513
   359
      print_rules = map swap parse_rules' @ print_rules,
wenzelm@2694
   360
      print_ast_translation = print_ast_translation,
wenzelm@2694
   361
      token_translation = tokentrfuns}
wenzelm@240
   362
  end;
wenzelm@240
   363
wenzelm@2382
   364
wenzelm@14903
   365
val syn_ext = syn_ext' true (K false);
wenzelm@555
   366
wenzelm@14903
   367
fun syn_ext_const_names cs = syn_ext [] cs ([], [], [], []) [] ([], []);
wenzelm@14903
   368
fun syn_ext_rules rules = syn_ext [] [] ([], [], [], []) [] rules;
wenzelm@16610
   369
fun syn_ext_advanced_trfuns trfuns = syn_ext [] [] trfuns [] ([], []);
wenzelm@14903
   370
fun syn_ext_tokentrfuns trfuns = syn_ext [] [] ([], [], [], []) trfuns ([], []);
wenzelm@2382
   371
wenzelm@16610
   372
fun syn_ext_trfuns (atrs, trs, tr's, atr's) =
wenzelm@16610
   373
  let fun simple (name, (f, s)) = (name, (K f, s)) in
wenzelm@16610
   374
    syn_ext_advanced_trfuns (map simple atrs, map simple trs, map simple tr's, map simple atr's)
wenzelm@16610
   375
  end;
wenzelm@16610
   376
wenzelm@15754
   377
fun stamp_trfun s (c, f) = (c, (f, s));
wenzelm@15754
   378
fun mk_trfun tr = stamp_trfun (stamp ()) tr;
wenzelm@15754
   379
fun eq_trfun ((_, s1:stamp), (_, s2)) = s1 = s2;
wenzelm@15754
   380
wenzelm@240
   381
wenzelm@15835
   382
(* token translations *)
wenzelm@15835
   383
wenzelm@15835
   384
fun tokentrans_mode m trs = map (fn (s, f) => (m, s, f)) trs;
wenzelm@15835
   385
wenzelm@15835
   386
val standard_token_classes =
wenzelm@15835
   387
  ["class", "tfree", "tvar", "free", "bound", "var", "num", "xnum", "xstr"];
wenzelm@15835
   388
wenzelm@15835
   389
val standard_token_markers = map (fn s => "_" ^ s) standard_token_classes;
wenzelm@15835
   390
wenzelm@15835
   391
clasohm@764
   392
(* pure_ext *)
wenzelm@240
   393
wenzelm@14903
   394
val pure_ext = syn_ext' false (K false)
clasohm@764
   395
  [Mfix ("_", spropT --> propT, "", [0], 0),
clasohm@764
   396
   Mfix ("_", logicT --> anyT, "", [0], 0),
clasohm@764
   397
   Mfix ("_", spropT --> anyT, "", [0], 0),
clasohm@764
   398
   Mfix ("'(_')", logicT --> logicT, "", [0], max_pri),
clasohm@764
   399
   Mfix ("'(_')", spropT --> spropT, "", [0], max_pri),
clasohm@764
   400
   Mfix ("_::_",  [logicT, typeT] ---> logicT, "_constrain", [4, 0], 3),
clasohm@764
   401
   Mfix ("_::_",  [spropT, typeT] ---> spropT, "_constrain", [4, 0], 3)]
clasohm@764
   402
  []
clasohm@764
   403
  ([], [], [], [])
wenzelm@2694
   404
  []
clasohm@764
   405
  ([], []);
wenzelm@240
   406
wenzelm@240
   407
end;