Commit 9de84643 authored by Julien Lopez's avatar Julien Lopez

Move the files from the root tests directory to tests/misc.

Tests in tests/misc are now part of the suites.
parent 0a887f79
let x : `A | `B = `A;;
let y : `A | `B = `B;;
let z : (`A,`A)|(`B,`B) = (x,y);;
(* let a : { x = `A; y = `A } | { x = `B; y = `B } = { x = x; y = y };;
(* let a : { x = `A; y = `A } | { x = `B; y = `B } = { x = x; y = y };;
*)
let examples = [ "functions","
(* Simple functions can be defined this way: *)
let fun f1 (x : Int) : Int = x + 3;;
f1 5;;
(* With several arguments: *)
let fun f2 (x : Int, y : Int) : Int = x + y;;
f2 (10,20);;
(* You may directly deconstruct the arguments: *)
type A = <a href=String>String;;
let fun f3 (<a href=url>txt : A) : String = url @ \"=>\" @ txt;;
f3 <a href=\"http://www.cduce.org\">\"CDuce homepage\";;
(* In general, if you want to specify several arrow types, or
use several pattern matching branches, you have the general
form: *)
let fun f4 (A -> String; ['0'--'9'+] -> Int)
| x & A -> f3 x
| x -> int_of x;;
f4 \"123\";;
";"mutrec","
(* All the types submitted at once are mutually recursive *)
type T = <t>S;;
type S = [ (Char | T)* ];;
let x : S = [ 'abc' <t>['def'] 'ghi' ];;
(* Consecutive function definitions (without any other toplevel phrase
in the middle) are grouped together *)
let fun f (x : Int) : Int = g x;;
let fun g (x : Int) : Int = 3;;
let a = 2;;
let fun h (x : Int) : Int = f x;;
(* f and g are mutually recursive, but they cannot use h *)
";"seq","
(* Sequence are just defined with pairs and the atom `nil;
the following notation are equivalent: *)
let l1 = (1,2,3,`nil);;
let l2 = (1,(2,(3,`nil)));;
let l3 = [ 1 2 3 ];;
(* The [...] notation allow to specify a tail after a semi-colon : *)
let l4 = (10,20,l1);;
let l5 = [ 10 20 ; l1 ];;
(* Concatenation @ *)
let l6 = [ 1 2 3 ] @ [ 4 5 6 ];;
(* Inside [...], it is possible to escape a subsequence with a ! *)
let l7 = [ 1 2 !l6 !l1 5 ];;
";"seqtypes","
(* Sequence types are defined with regular expression over types *)
type IntList = [ Int* ];;
type IntStringList = [ (Int String)* ];;
type IntNonEmptyList = [ Int+ ];;
let l : IntList = [ 1 2 3 ];;
";"integers","
(* Yes, CDuce can handle large integers! *)
let fun facto (Int -> Int)
| 0 | 1 -> 1
| n -> n * (facto (n - 1))
in
facto 300;;
(* The tail-recursive way *)
let fun facto ((Int,Int) -> Int)
| (x, 0 | 1) -> x
| (x, n) -> facto (x * n, n - 1)
in
facto (1,10000);;
";"sumtype","
type Expr =
(`add, Expr, Expr)
| (`mul, Expr, Expr)
| (`sub, Expr, Expr)
| (`div, Expr, Expr)
| Int;;
let fun eval ( Expr -> Int )
| (`add,x,y) -> eval x + eval y
| (`mul,x,y) -> eval x * eval y
| (`sub,x,y) -> eval x - eval y
| (`div,x,y) -> (eval x) div (eval y)
| n -> n
in
eval (`add, 10, (`mul, 20, 5));;
";"ovfun","
type Person = FPerson | MPerson;;
type FPerson = <person gender = \"F\" >[ Name Children (Tel | Email)?];;
type MPerson = <person gender=\"M\">[ Name Children (Tel | Email)?];;
type Children = <children>[Person*];;
type Name = <name>[ PCDATA ];;
type Tel = <tel kind=?\"home\"|\"work\">['0'--'9'+ '-' '0'--'9'+];;
type Email = <email>[PCDATA '@' PCDATA];;
type Man = <man name=String>[ Sons Daughters ];;
type Woman = <woman name=String>[ Sons Daughters ];;
type Sons = <sons>[ Man* ];;
type Daughters = <daughters>[ Woman* ];;
let fun sort (MPerson -> Man ; FPerson -> Woman)
<person gender=g>[ <name>n <children>[(mc::MPerson | fc::FPerson)*]; _] ->
let tag = match g with \"F\" -> `woman | \"M\" -> `man in
let s = map mc with x -> sort x in
let d = map fc with x -> sort x in
<(tag) name=n>[ <sons>s <daughters>d ]
;;
let base : Person =
<person gender=\"F\">[
<name>\"Themis\"
<children>[
<person gender=\"M\">[
<name>\"Prometheus\"
<children>[
<person gender=\"M\">[
<name>\"Deucalion\"
<children>[]
]
]
<email>\"focifero@olympus.com\"
]
<person gender=\"M\">[
<name>\"Epimetheus\"
<children>[]
<tel> \"314-1592654\"
]
]
<tel kind=\"home\"> \"271-828182\"
]
;;
sort base;;
";"note","
type Doc = <doc>Text;;
type Text = [ (Char | (Letter+ ' '* Note))* ];;
type Letter = 'a'--'z' | 'A'--'Z';;
type Note = <note>[ PCDATA ];;
type Flow = [ (Char | <ref no=Int>[ PCDATA ])* ];;
type Notes = [ <note no=Int>[ PCDATA ]* ];;
type Result = <doc>[ <body>Flow <notes>Notes ];;
let fun format (<doc>s : Doc) : Result =
let (body,notes) = text (s,1) in
<doc>[ <body>body <notes>notes ];;
let fun text ( (Text,Int) -> (Flow,Notes) )
| ([ pre::Char*? (word::Letter+ ' '* <note>n); rem ], count) ->
let (body,notes) = text (rem, count + 1) in
(pre @ [<ref no=count>word] @ body,
[<note no=count>n] @ notes)
| (body,_) -> (body, []);;
let src : Doc = <doc>[ 'CDuce ' <note>\"Frisch, Castagna, Benzaken\"
' is an XML ' <note>\"a W3C standard\"
'-friendly programming language.' ];;
format src;;
";"biblio","
type Biblio = <bibliography>[Heading Paper*];;
type Heading = <heading>[ PCDATA ];;
type Paper = <paper>[ Author+ Title Conference File ];;
type Author = <author>[ PCDATA ];;
type Title = <title>[ PCDATA ];;
type Conference = <conference>[ PCDATA ];;
type File = <file>[ PCDATA ];;
(* Simplified HTML *)
type Html = <html>[ <head>[ <title>[ PCDATA ] ] <body>Mix ];;
type Mix = [ ( <h1>Mix | <a href=String>Mix | <p>Mix | <em>Mix
| <ul>[ <li>Mix +] | Char )* ];;
let fun do_authors ([Author+] -> Mix)
| [ <author>a ] -> a
| [ <author>a <author>b ] -> a @ \" and, \" @ b
| [ <author>a; x] -> a @ \", \" @ (do_authors x);;
let fun do_paper (Paper -> <li>Mix)
<paper>[ x::_* <title>t <conference>c <file>f ] ->
<li>[ <a href=f>t !(do_authors x) '; in ' <em>c '.' ];;
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 ];;
let bib : Biblio =
<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\"
]
];;
do_biblio bib;;
";"projection","
(* The projection e/t is translated to:
transform e with [ (x::t|_)* ] -> x *)
type Biblio = <bibliography>[Heading Paper*];;
type Heading = <heading>[ PCDATA ];;
type Paper = <paper>[ Author+ Title Conference File ];;
type Author = <author>[ PCDATA ];;
type Title = <title>[ PCDATA ];;
type Conference = <conference>[ PCDATA ];;
type File = <file>[ PCDATA ];;
let bib : Biblio =
<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\"
]
];;
let titles = [bib]/<paper>_/<title>_;;
let authors = [bib]/<paper>_/<author>_;;
let titles_concat = [bib]/<paper>_/<title>_/Char;;
"; ];;
let present = "<ul><li><a href=\"/cgi-bin/cduce?example=functions\">Functions.</a>
Several syntaxes to define functions.
</li><li><a href=\"/cgi-bin/cduce?example=mutrec\">Mutual recursion.</a>
Mutual toplevel definition for types and functions.
</li><li><a href=\"/cgi-bin/cduce?example=seq\">Sequence literals.</a>
How to write sequences.
</li><li><a href=\"/cgi-bin/cduce?example=seqtypes\">Sequence types.</a>
Types for sequences.
</li><li><a href=\"/cgi-bin/cduce?example=integers\">The factorial function.</a>
What about computing 10000! ?
</li><li><a href=\"/cgi-bin/cduce?example=sumtype\">Sum types.</a>
How to simulate ML sum types.
</li><li><a href=\"/cgi-bin/cduce?example=ovfun\">Overloaded functions.</a>
This examples demonstrates the use of overloaded functions.
</li><li><a href=\"/cgi-bin/cduce?example=note\">Footnotes.</a>
This example shows how to bind an XML element with surrounding text.
</li><li><a href=\"/cgi-bin/cduce?example=biblio\">Bibliography.</a>
The good old XML bibliography example.
</li><li><a href=\"/cgi-bin/cduce?example=projection\">Projection.</a>
Syntactic sugar for projection.
</li></ul>";;
\ No newline at end of file
==============addrbook.cd===============
==============biblio.cd===============
==============fixml4.3v20020920.cd===============
==============funs.cd===============
==============html2latex.cd===============
File "../misc/xhtml-trans.cd", line 3, characters 8-10:
Parsing error: [attrib_spec] expected (in [type/pattern expression])
==============IFX130.cd===============
==============integers.cd===============
==============lazy.cd===============
==============mc.cd===============
==============memento.cd===============
File "../misc/memento.cd", line 11, characters 5-9:
Warning: This definition yields an empty type for Misc
File "../misc/memento.cd", line 76, characters 8-157:
Warning: The following variables always match the empty sequence: s
File "../misc/memento.cd", line 78, characters 28-48:
Warning: This branch is not used
File "../misc/memento.cd", line 76, characters 29-105:
Warning: This branch is not used
File "../misc/memento.cd", line 64, characters 3-116:
Warning: This branch is not used
File "../misc/memento.cd", line 86, characters 49-53:
This expression should have type:
{ }
Field no is not allowed here.
==============notes.cd===============
==============ns.cd===============
==============overloading.cd===============
==============overloading2.cd===============
==============patterns.cd===============
==============security.cd===============
==============str.cd===============
==============stress_opt_arg.cd===============
==============stress_opt_seq.cd===============
==============vouill.cd===============
==============web.cd===============
File "../misc/web.cd", line 41, characters 5-10:
Warning: This definition yields an empty type for Table
File "../misc/web.cd", line 11, characters 5-9:
Warning: This definition yields an empty type for Misc
File "../misc/web.cd", line 74, characters 0-193:
Warning: This operator may fail
==============wp.cd===============
==============xhtml.cd===============
File "../misc/xhtml.cd", line 3, characters 8-10:
Parsing error: [attrib_spec] expected (in [type/pattern expression])
==============xhtml-trans.cd===============
File "../misc/xhtml-trans.cd", line 3, characters 8-10:
Parsing error: [attrib_spec] expected (in [type/pattern expression])
==============xtrans.cd===============
==============bugs_prod.cd===============
File "../misc/bugs_prod.cd", line 3, characters 26-31:
This expression should have type:
(`B,`B) | (`A,`A)
but the first component has type `A | `B
==============eval_concat.cd===============
File "../misc/eval_concat.cd", line 6, characters 1-7:
This expression should have type:
Arrow
but it is a pair
==============ref.cd===============
Stack overflow
......@@ -47,10 +47,10 @@ type Table = <table border=?String; bgcolor=String; width=String>
type Page = <page filename=String>[ <title>String; Content ];;
type Content = [ (Box | Section)* ];;
type Content' = [ (Box | Section')* ];;
type Box = <box>Text;;
type Section = <section>[ <title>String ; Text ];;
type Section' = <section no=Int>[ <title>String ; Text ];;
type Text = [ (Char | <duce>String | <ul>[<li>Text +]
| <a href=String>String | <br>[])* ];;
......@@ -59,7 +59,7 @@ let fun box(c : [Flow*]) : [Block*] =
[ <table bgcolor="white"; width="100%"; border="1">[ <tr>[ <td>c ] ]
<p>[] ];;
let fun format (Box | Section' | Content' -> [Block*]; Text -> [Flow*])
let fun format (Box | Section | Content -> [Block*]; Text -> [Flow*])
| <box>s -> box (format s)
| <section no=i>[ <title>t ; s ] ->
box [ <h2>[!(string_of i) '. ' !t] <a name=string_of i>[];
......@@ -68,19 +68,20 @@ let fun format (Box | Section' | Content' -> [Block*]; Text -> [Flow*])
| <duce>c -> <b>[<tt>c]
| <ul>l -> <ul>(map l with <li>c -> <li>(format c) )
| c -> c)
| c & Content' -> (transform c with x -> format x);;
| c & Content -> (transform c with x -> format x)
| _ -> `nil;;
let fun summary (Content' -> [Block*])
let fun summary (Content -> [Block*])
c ->
let s = transform c with <section no=i>[<title>t; _] ->
[<li>[<a href="#" @ string_of i>t]] in
[<li>[<a href=("#" @ string_of i)>t]] in
match s with [] -> [] | lis -> box [<ul>lis];;
let (fname, title, content) =
match load_xml "tests/memento.xml" with
match load_xml "memento.xml" with
| <page filename=f>[ <title>t ; c ] & Page ->
let fun aux ((Int,Content) -> Content')
let fun aux ((Int,Content) -> Content)
| (_,[]) -> []
| (i,(<section>s,rem)) -> [ <section no=i>s !(aux (i+1,rem)) ]
| (i,(x,rem)) -> [ x !(aux (i,rem)) ]
......
let doc = load_xml ['tests/ns.xml'];;
let doc = load_xml ['ns.xml'];;
print (print_xml doc);;
......
......@@ -25,14 +25,14 @@ let my_company : Company =
] in
let q1 =
let _ =
let <company> x = my_company in
map x with <worker>[x y z ] -> <worker>[x y] in
map x with <worker>[x y _ ] -> <worker>[x y] in
let q2 =
let <company>[(x::<worker>[ _ _ <salary>[ 1800 ] ] | _)*] = my_company in
map x with <worker>[x y z ] -> <worker>[x y] in
map x with <worker>[x y _ ] -> <worker>[x y] in
q2;;
......
......@@ -50,7 +50,7 @@ type Example = <example code=String>[
];;
let examples =
match load_xml "tests/examples.xml" with
match load_xml "examples.xml" with
| Examples & <_>e -> e
| _ -> raise "Invalid input document";;
......@@ -59,7 +59,7 @@ let fun script (code : String) : String =
"/cgi-bin/cduce?example=" @ code;;
let fun do_example (<_ code=c>[<title>t <abstract>a; _] : Example) : Li =
<li>[ <a href = script c >[ !t '.' ] ' ' !a ];;
<li>[ <a href = (script c) >[ !t '.' ] ' ' !a ];;
......@@ -71,7 +71,7 @@ let fun to_ml (e : [Example*]) : String =
<_ code=c>[_ _ <code>cd] -> [ '"' !c '","' !(protect_quote cd) '";'];;
dump_to_file "driver/examples.ml"
dump_to_file "examples.ml"
[ '
let examples = [ ' !(to_ml examples) ' ];;
let present = "'
......@@ -104,6 +104,6 @@ let doc : Html =
<address>[ 'This page has been generated by a ' !cduce ' program.' ]
]
];;
dump_to_file "tests/examples.html" (print_xml doc);;
dump_to_file "examples.html" (print_xml doc);;
*)
......@@ -7,7 +7,7 @@ type Author = <author>[ PCDATA ];;
let bib0 =
match (load_xml "tests/bib.xml") with
match (load_xml "bib.xml") with
| (x & Bib) -> x
| _ -> raise "Wrong type !" in
bib0;;
......@@ -38,13 +38,14 @@ let fun intern (Bib -> [Intern*])
<book>[ <title>t <year>y a::Author+ ] ->
{
title = t;
year = int_of y;
year = (int_of y);
authors = map a with <author>x -> x
};;
let fun authors(Intern -> [String+]; Book -> [Author+])
| { authors = a }
| <book>[ <title>_ <year>_; a] -> a;;
| <book>[ <title>_ <year>_; a] -> a
| _ -> [[]];;
let fun extract ([ (String|Author)+ ] -> [ String+ ])
l -> map l with
......
type T = <a>[ <b>[ <c1>[] ] ]
type S = <a>[ <b>[ <d1>[] ] ]
let f (x : [ T ]) : [ S ] = xtransform x with <c1>_ -> [<d1>[]]
This diff is collapsed.
<!--
DTD for XML Schemas: Part 2: Datatypes
$Id: datatypes.dtd,v 1.23 2001/03/16 17:36:30 ht Exp $
Note this DTD is NOT normative, or even definitive. - - the
prose copy in the datatypes REC is the definitive version
(which shouldn't differ from this one except for this comment
and entity expansions, but just in case)
-->
<!--
This DTD cannot be used on its own, it is intended
only for incorporation in XMLSchema.dtd, q.v.
-->
<!-- Define all the element names, with optional prefix -->
<!ENTITY % simpleType "%p;simpleType">
<!ENTITY % restriction "%p;restriction">
<!ENTITY % list "%p;list">
<!ENTITY % union "%p;union">
<!ENTITY % maxExclusive "%p;maxExclusive">
<!ENTITY % minExclusive "%p;minExclusive">
<!ENTITY % maxInclusive "%p;maxInclusive">
<!ENTITY % minInclusive "%p;minInclusive">
<!ENTITY % totalDigits "%p;totalDigits">
<!ENTITY % fractionDigits "%p;fractionDigits">
<!ENTITY % length "%p;length">
<!ENTITY % minLength "%p;minLength">
<!ENTITY % maxLength "%p;maxLength">
<!ENTITY % enumeration "%p;enumeration">
<!ENTITY % whiteSpace "%p;whiteSpace">
<!ENTITY % pattern "%p;pattern">
<!--
Customisation entities for the ATTLIST of each element
type. Define one of these if your schema takes advantage
of the anyAttribute='##other' in the schema for schemas
-->
<!ENTITY % simpleTypeAttrs "">
<!ENTITY % restrictionAttrs "">
<!ENTITY % listAttrs "">
<!ENTITY % unionAttrs "">
<!ENTITY % maxExclusiveAttrs "">
<!ENTITY % minExclusiveAttrs "">
<!ENTITY % maxInclusiveAttrs "">
<!ENTITY % minInclusiveAttrs "">
<!ENTITY % totalDigitsAttrs "">
<!ENTITY % fractionDigitsAttrs "">
<!ENTITY % lengthAttrs "">
<!ENTITY % minLengthAttrs "">
<!ENTITY % maxLengthAttrs "">
<!ENTITY % enumerationAttrs "">
<!ENTITY % whiteSpaceAttrs "">
<!ENTITY % patternAttrs "">
<!-- Define some entities for informative use as attribute
types -->
<!ENTITY % URIref "CDATA">
<!ENTITY % XPathExpr "CDATA">
<!ENTITY % QName "NMTOKEN">
<!ENTITY % QNames "NMTOKENS">
<!ENTITY % NCName "NMTOKEN">
<!ENTITY % nonNegativeInteger "NMTOKEN">
<!ENTITY % boolean "(true|false)">
<!ENTITY % simpleDerivationSet "CDATA">
<!--
#all or space-separated list drawn from derivationChoice
-->
<!--