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

[r2002-12-05 21:32:23 by cvscast] Empty log message

Original author: cvscast
Date: 2002-12-05 21:32:23+00:00
parent 286b3b8b
let examples = [ "functions","
(* Simple functions can be defined this way: *)
let fun f1 (x : Int) : Int = x + 3;;
f1 5;;
......@@ -24,6 +25,7 @@ let fun f4 (A -> String; ['0'--'9'+] -> Int)
f4 \"123\";;
";"mutrec","
(* All the types submitted at once are mutually recursive *)
type T = <t>S;;
type S = [ (Char | T)* ];;
......@@ -40,6 +42,7 @@ let fun h (x : Int) : Int = f x;;
";"seq","
(* Sequence are just defined with pairs and the atom `nil;
the following notation are equivalent: *)
let l1 = (1,2,3,`nil);;
......@@ -57,6 +60,7 @@ let l6 = [ 1 2 3 ] @ [ 4 5 6 ];;
let l7 = [ 1 2 !l6 !l1 5 ];;
";"seqtypes","
(* Sequence types are defined with regular expression over types *)
type IntList = [ Int* ];;
type IntStringList = [ (Int String)* ];;
......@@ -65,6 +69,7 @@ type IntNonEmptyList = [ Int+ ];;
let l : IntList = [ 1 2 3 ];;
";"integers","
(* Yes, CDuce can handle large integers! *)
let fun facto (Int -> Int)
| 0 | 1 -> 1
......@@ -80,6 +85,7 @@ in
facto (1,10000);;
";"sumtype","
type Expr =
(`add, Expr, Expr)
| (`mul, Expr, Expr)
......@@ -97,6 +103,7 @@ 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)?];;
......@@ -118,27 +125,34 @@ let fun sort (MPerson -> Man ; FPerson -> Woman)
;;
let base : Person =
<person gender=\"M\">[
<name>\"Claude\"
<person gender=\"F\">[
<name>\"Themis\"
<children>[
<person gender=\"F\">[
<name>\"Vronique\"
<person gender=\"M\">[
<name>\"Prometheus\"
<children>[
<person gender=\"F\">[
<name>\"Ilaria\"
<children>[]
]
]
<tel> \"314-1592654\"
<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';;
......@@ -166,6 +180,7 @@ let src : Doc = <doc>[ 'CDuce ' <note>\"Frisch, Castagna, Benzaken\"
format src;;
";"biblio","
type Biblio = <bibliography>[Heading Paper*];;
type Heading = <heading>[ PCDATA ];;
type Paper = <paper>[ Author+ Title Conference File ];;
......@@ -229,6 +244,7 @@ let bib : Biblio =
do_biblio bib;;
";"projection","
(* The projection e/t is translated to:
transform e with [ (x::t|_)* ] -> x *)
......@@ -280,52 +296,62 @@ let present = "<ul
><li
><a href=\"/cgi-bin/cduce?example=functions\"
>Functions.</a
> Several syntaxes to define functions.
>
Several syntaxes to define functions.
</li
><li
><a href=\"/cgi-bin/cduce?example=mutrec\"
>Mutual recursion.</a
> Mutual toplevel definition for types and functions.
>
Mutual toplevel definition for types and functions.
</li
><li
><a href=\"/cgi-bin/cduce?example=seq\"
>Sequence literals.</a
> How to write sequences.
>
How to write sequences.
</li
><li
><a href=\"/cgi-bin/cduce?example=seqtypes\"
>Sequence types.</a
> Types for sequences.
>
Types for sequences.
</li
><li
><a href=\"/cgi-bin/cduce?example=integers\"
>The factorial function.</a
> What about computing 10000! ?
>
What about computing 10000! ?
</li
><li
><a href=\"/cgi-bin/cduce?example=sumtype\"
>Sum types.</a
> How to simulate ML sum types.
>
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.
>
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.
>
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.
>
The good old XML bibliography example.
</li
><li
><a href=\"/cgi-bin/cduce?example=projection\"
>Projection.</a
> Syntactic sugar for projection.
>
Syntactic sugar for projection.
</li
></ul
>";;
\ No newline at end of file
......@@ -183,24 +183,30 @@ let fun sort (MPerson -> Man ; FPerson -> Woman)
;;
let base : Person =
<person gender="M">[
<name>"Claude"
<person gender="F">[
<name>"Themis"
<children>[
<person gender="F">[
<name>"Vronique"
<person gender="M">[
<name>"Prometheus"
<children>[
<person gender="F">[
<name>"Ilaria"
<children>[]
]
]
<tel> "314-1592654"
<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;;
]]>
</code>
......
......@@ -85,7 +85,8 @@ of the language.
</box>
<p/><a NAME="papers"></a>
<box title="Papers" subtitle="Language description">
<box title="Papers" subtitle="">
<font color="blue" size="+1"> Language Description</font>
<ul>
<li>
<b>CDuce: a white paper</b>.
......@@ -112,7 +113,7 @@ schemas.
</small>
</li></ul>
<b>Theoretical foundations for the type system</b>
<font color="blue" size="+1">Theoretical foundations</font>
<ul>
<li>
......
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