biblio.cd 1.94 KB
Newer Older
1
type Biblio  = <bibliography>[Heading Paper*];;
2
type Heading = <heading>[ PCDATA ];;
3
type Paper   = <paper>[Author+ Title Conference File];;
4
5
6
7
type Author  = <author>[ PCDATA ];;
type Title   = <title>[ PCDATA ];;
type Conference = <conference>[ PCDATA ];;
type File    = <file>[ PCDATA ];;
8
9

type Html  = <html>[Head? Body];;
10
type Head  = <head>[ <title>[ PCDATA ] ];;
11
12
type Body  = <body>[Mix*];;
type Mix   = <h1>[Mix*]
13
           | <a href=String>[Mix*]
14
15
16
17
18
19
20
           | <p>[Mix*]
           | <em>[Mix*]
           | <ul>[ <li>[Mix*] +]
           | Char;;

let fun do_authors ([Author+] -> [Mix*])
 | [ <author>a ] -> a
21
22
 | [ <author>a <author>b ] -> a " and, " b
 | [ <author>a; x] -> a ", " (do_authors x)
23
24
in
let fun do_paper (Paper -> <li>[Mix*])
25
  <paper>[ x::(_* ) <title>t <conference>c <file>f ] ->
26
27
(* Here, type inference says:  x : [Author+] ... *)
    let authors = do_authors x in
28
    <li>([ <a href=f>t ] authors "; in " [ <em>c ] "." )
29
30
31
32
33
34
35
36
37
in
let fun do_biblio (Biblio -> Html)
  <bibliography>[ <heading>h; p ] ->
      let body = match p with
      | [] -> "Empty bibliography"
      | l -> [ <h1>h <ul>(map l with x -> do_paper x) ]
      in    
      <html>[ <head>[ <title>h ] <body>body ]
in
38
let bib : Biblio = 
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
  <bibliography>[
    <heading>"Alain Frisch's bibliography"
    <paper>[
      <author>"Alain Frisch"
      <author>"Giuseppe Castagna"
      <author>"Vronique Benzaken"
      <title>"Semantic subtyping"
      <conference>"LICS 02"
      <file>"semsub.ps.gz"
    ]
    <paper>[
      <author>"Mariangiola Dezani-Ciancaglini"
      <author>"Alain Frisch"
      <author>"Elio Giovannetti"
      <author>"Yoko Motohama"
      <title>"The Relevance of Semantic Subtyping"
      <conference>"ITRS'02"
      <file>"itrs02.ps.gz"
    ]
    <paper>[
      <author>"Vronique Benzaken"
      <author>"Giuseppe Castagna"
      <author>"Alain Frisch"
      <title>"CDuce: a white-paper"
      <conference>"PLANX-02"
      <file>"planx.ps.gz"
    ]
 ]
in
do_biblio bib
;;