Commit a9b124b5 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2002-11-11 16:11:38 by cvscast] Empty log message

Original author: cvscast
Date: 2002-11-11 16:11:38+00:00
parent b2c95e10
...@@ -4,18 +4,18 @@ type MPerson = <person gender="M">[ Name Children];; ...@@ -4,18 +4,18 @@ type MPerson = <person gender="M">[ Name Children];;
type Children = <children>[Person*];; type Children = <children>[Person*];;
type Name = <name>[ PCDATA ];; type Name = <name>[ PCDATA ];;
type Man = <man>[ Name Sons Daughters ];; type Man = <man name=String>[ Sons Daughters ];;
type Woman = <woman>[ Name Sons Daughters ];; type Woman = <woman name=String>[ Sons Daughters ];;
type Sons = <sons>[ Man* ];; type Sons = <sons>[ Man* ];;
type Daughters = <daughters>[ Woman* ];; type Daughters = <daughters>[ Woman* ];;
let fun sort (MPerson -> Man ; FPerson -> Woman) let fun sort (MPerson -> Man ; FPerson -> Woman)
<person gender=g>[ n <children>[(mc::MPerson | fc::FPerson)*] ] -> <person gender=g>[ <name>n <children>[(mc::MPerson | fc::FPerson)*] ] ->
let tag = match g with "F" -> `woman | "M" -> `man in let tag = match g with "F" -> `woman | "M" -> `man in
let s = map mc with x -> sort x in let s = map mc with x -> sort x in
let d = map fc with x -> sort x in let d = map fc with x -> sort x in
<(tag)>[ n <sons>s <daughters>d ] <(tag) name=n>[ <sons>s <daughters>d ]
in ;;
let base : Person = let base : Person =
<person gender="F">[ <person gender="F">[
<name>"Veronique" <name>"Veronique"
...@@ -26,4 +26,15 @@ let base : Person = ...@@ -26,4 +26,15 @@ let base : Person =
] ]
] ]
] ]
in sort base;; ;;
sort base;;
(* compilation efficace avec _ a la place de person *)
let fun name (Person | Man | Woman -> String)
<person>[ <name>n ; _ ]
| <_ name=n>_ -> n;;
name base;;
name (sort base);;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment