src/Pure/term_xml.ML
author wenzelm
Sun, 10 Jul 2011 16:34:17 +0200
changeset 43729 07d3c6afa865
child 43730 a0ed7bc688b5
permissions -rw-r--r--
XML data representation of lambda terms;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43729
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/term_xml.ML
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
     3
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
     4
XML data representation of lambda terms.
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
     5
*)
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
     6
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
     7
signature TERM_XML_OPS =
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
     8
sig
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
     9
  type 'a T
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    10
  val indexname: indexname T
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    11
  val class: class T
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    12
  val sort: sort T
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    13
  val typ: typ T
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    14
  val term: term T
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    15
end
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    16
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    17
signature TERM_XML =
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    18
sig
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    19
  structure Make: TERM_XML_OPS where type 'a T = 'a XML_Data.Make.T
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    20
  structure Dest: TERM_XML_OPS where type 'a T = 'a XML_Data.Dest.T
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    21
end;
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    22
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    23
structure Term_XML: TERM_XML =
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    24
struct
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    25
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    26
(* make *)
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    27
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    28
structure Make =
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    29
struct
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    30
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    31
open XML_Data.Make;
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    32
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    33
val indexname = pair string int;
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    34
val class = string;
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    35
val sort = list class;
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    36
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    37
fun typ T = T |> variant
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    38
 [fn Type x => pair string (list typ) x,
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    39
  fn TFree x => pair string sort x,
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    40
  fn TVar x => pair indexname sort x];
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    41
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    42
fun term t = t |> variant
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    43
 [fn Const x => pair string typ x,
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    44
  fn Free x => pair string typ x,
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    45
  fn Var x => pair indexname typ x,
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    46
  fn Bound x => int x,
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    47
  fn Abs x => triple string typ term x,
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    48
  fn op $ x => pair term term x];
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    49
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    50
end;
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    51
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    52
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    53
(* dest *)
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    54
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    55
structure Dest =
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    56
struct
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    57
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    58
open XML_Data.Dest;
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    59
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    60
val indexname = pair string int;
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    61
val class = string;
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    62
val sort = list class;
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    63
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    64
fun typ T = T |> variant
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    65
 [Type o pair string (list typ),
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    66
  TFree o pair string sort,
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    67
  TVar o pair indexname sort];
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    68
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    69
fun term t = t |> variant
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    70
 [Const o pair string typ,
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    71
  Free o pair string typ,
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    72
  Var o pair indexname typ,
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    73
  Bound o int,
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    74
  Abs o triple string typ term,
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    75
  op $ o pair term term];
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    76
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    77
end;
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    78
07d3c6afa865 XML data representation of lambda terms;
wenzelm
parents:
diff changeset
    79
end;