Commit 0a23a2bd authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-03-16 18:43:57 by cvscast] Empty log message

Original author: cvscast
Date: 2003-03-16 18:43:58+00:00
parent 111149b6
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<page>
<title>CDuce memento</title>
<banner> CDuce memento </banner>
<!-- ********* Left panel ********* -->
<navig>
<toc/>
<box>
<p>
This page briefly presents the syntax of the CDuce language.
</p>
<ul>
<li><a href="/cgi-bin/cduce">Online demo</a></li>
<li><a href="/">Home page</a></li>
</ul>
</box>
</navig>
<!-- ********* Main panel ********* -->
<main>
<box title="Identifiers" link="id">
<ul>
<li> Type and Pattern identifiers: words formed by of unicode letters and and
the underscore "_" character, starting by a capitalized letter. </li>
<li> value identifiers: words formed by of unicode letters and the underscore "
_" character, starting by a capitalized letter or underscore.</li>
</ul>
</box>
<box title="Scalars" link="scalars">
<ul>
<li>Large integers:
<ul>
<li>Values: <duce>0,1,2,3,...</duce> </li>
<li>Types: intervals <duce>-*--10, 20--30, 50--*, ...</duce>,
singletons <duce>0,1,2,3,...</duce> </li>
<li>Operators: <duce>+,-,/,*,div,mod, int_of</duce> </li>
</ul>
</li>
<li>Unicode characters:
<ul>
<li>Values: <duce>'a','b','c'...</duce> </li>
<li>Types: intervals <duce>'a'--'z', '0'--'9'</duce>,
singletons <duce>'a','b','c',...</duce> </li>
</ul>
</li>
<li>Symbolic atoms:
<ul>
<li>Values: <duce>`A, `B, `a, `b, `true, `false, ...</duce> </li>
<li>Types: singletons <duce>`A, `B, ...</duce> </li>
</ul>
</li>
</ul>
</box>
<box title="Operators" link="op">
<ul>
<li>Infix:
<br/> <duce>@</duce> : String,String -> String
<br/> <duce>+,*,-,div,mod</duce> : Integer,Integer -> Integer
<br/> <duce>=, &lt;&lt;, &lt;=, &gt;&gt;, &gt;= </duce> :
Integer,Integer -> Bool = <duce>`true | `false</duce>
</li>
<li>Prefix:
<br/><duce>load_xml,load_html, dump_to_file</duce> : String -> Any
<br/><duce>print_xml</duce> : Any -> String
<br/><duce>print</duce> : String -> []
<br/><duce>int_of</duce> : [('0'--'9')+] -> Integer
<br/><duce>string_of</duce> : Integer -> String
</li>
<li>Postfix:
<br/><duce>?,*,+,??,*?,+?</duce> : for regexp
</li>
</ul>
</box>
<box title="Pairs" link="pair">
<ul>
<li>Expressions: <duce>(e1,e2)</duce> </li>
<li>Types and patterns: <duce>(t1,t2)</duce> </li>
<li>Note: tuples are right-associative pairs; e.g.:
<duce>(1,2,3)=(1,(2,3))</duce> </li>
<li>When a capture variable appears on both side of a pair pattern,
the two captured values are paired
together (e.g. <duce>match (1,2,3) with (x,(_,x)) -> x ==>
(1,3)</duce>). </li>
</ul>
</box>
<box title="Sequences" link="seq">
<ul>
<li>Expressions: <duce>[ 1 2 3 ]</duce>,
which is syntactic sugar for <duce>(1,(2,(3,`nil)))</duce> </li>
<li>A sub-sequence can be escaped by !: <duce>[ 1 2 ![ 3 4 ] 5
]</duce> is then equal to <duce>[ 1 2 3 4 5 ]</duce> . </li>
<li>Types and patterns : <duce>[ R ]</duce> where <duce>R</duce> is
a regular expression built on types and patterns:
<ul>
<li>A type or a pattern is a regexp by itself, matching a single
element of the sequence </li>
<li>Postfix repetition operators: <duce>*,+,?</duce>
and the ungreedy variants (for patterns) <duce>*?, +?
,??</duce></li>
<li>Concatenation of regexps</li>
<li>For patterns, sequence capture variable <duce>x::R</duce> </li>
</ul>
</li>
<li>It is possible to specify a tail, for expressions, types, and patterns;
e.g.: <duce>[ x::Int*; q ]</duce> </li>
<li>Map: <duce>map e with p1 -> e1 | ... | pn -> en</duce>.
Each element of e must be matched. </li>
<li>Transform: <duce>transform e with p1 -> e1 | ... | pn -> en</duce>.
Unmatched elements are discarded; each branch returns a sequence
and all the resulting sequences are concatenated together. </li>
<li>Operators: concatenation <duce>e1 @ e2 = [ !e1 !e2 ]</duce>,
flattening <duce>flatten e = transform e with x -> x</duce>.
</li>
</ul>
</box>
<box title="Record" link="record">
<ul>
<li>Records litteral <duce>{ l1 = e1; ...; ln = en }</duce></li>
<li>Types: <duce>{| l1 = t1; ...; ln = tn |}</duce> (closed, no more
fields allowed), <duce>>{ l1 = t1; ...; ln = tn }</duce> (open,
any other field allowed). Optional fields: <duce>li =? ti</duce>
instead of <duce>li = ti</duce>.</li>
<li>Record concatenation: <duce>e1 + e2</duce>
(priority to the fields from the right argument) </li>
<li>Field removal: <duce>e1 \ l</duce> (does nothing if the
field <duce>l</duce> is not present)</li>
<li>Field access: <duce>e1 . l</duce></li>
<li>Record: <duce>{ l1 = p1; ...; ln = pn }</duce></li>
</ul>
</box>
<box title="Strings" link="string">
<ul>
<li>Strings are actually sequences of characters.</li>
<li>Expressions: <duce>"abc", [ 'abc' ], [ 'a' 'b' 'c' ]</duce>. </li>
<li>Operators: <duce>string_of, print, dump_to_file</duce></li>
<li><duce>PCDATA</duce> means <duce>Char*</duce> inside regular expressions</li>
</ul>
</box>
<box title="XML elements" link="xml">
<ul>
<li>Expressions: <duce> &lt;(tag) (attr)>content</duce> </li>
<li>If the tag is an atom <duce>`X</duce>, it can be written
<duce>X</duce> (without the <duce>(..)</duce>).
Similarly, parenthesis and curly braces may be omitted
when attr is a record <duce>l1=e1;...;ln=en</duce>.
E.g: <duce>&lt;a href="abc">[ 'abc' ]</duce>.</li>
<li>Types and patterns: same notations.</li>
<li>Operators: <duce>load_xml : String -> Any; print_xml : Any -> String</duce>
</li>
</ul>
</box>
<box title="Functions" link="fun">
<ul>
<li>Expressions:
<ul>
<li>General form: <duce>fun f (t1->s1;...;tn->sn)
p1 -> e1 | ... | pn -> en</duce> (<duce>f</duce> is optional) </li>
<li>Simple function: <duce>fun f (p : t) : s = e</duce>,
equivalent to <duce>fun f (t -> s) p -> e</duce> </li>
<li>Multiple arguments: <duce>fun f (p1 : t1, p2 : t2,...) : s =
e</duce>, equivalent to <duce>fun f ((p1,p2,...):(t1,t2,...)) : s
= e</duce> </li>
</ul>
</li>
<li>Types: <duce>t -> s</duce> </li>
</ul>
</box>
<box title="Pattern matching, exceptions, ..." link="match">
<ul>
<li>Type restriction: <duce>(e : t)</duce> (forgets any more precise
type for <duce>e</duce>) </li>
<li>Pattern matching: <duce>match e with p1 -> e1 | ... | pn ->
en</duce></li>
<li>Local binding: <duce>let p = e1 in e2</duce>, equivalent to
<duce>match e1 with p -> e2</duce>;
<duce>let p : t = e1 in e2</duce> equivalent to
<duce>let p = (e1 : t) in e2</duce> </li>
<li>If-then-else: <duce>if e1 then e2 else e3</duce>, equivalent to
<duce>match e1 with `true -> e2 | `false -> e3</duce></li>
<li>Exceptions: <ul>
<li>Raise exception: <duce>raise e</duce></li>
<li>Handle exception: <duce>try e with p1 -> e1 | ... | pn ->
en</duce></li>
</ul> </li>
</ul>
</box>
<box title="More about types and patterns" link="type">
<ul>
<li>Boolean connectives: <duce>&amp;,|,\</duce> (<duce>|</duce> is
first-match). </li>
<li>Empty and universal types: <duce>Empty,Any</duce> or
<duce>_</duce>.</li>
<li>Recursive types and patterns: <duce>t where T1 = t2 and ... and
Tn = tn</duce>.</li>
<li>Capture variable: <duce>x</duce>. </li>
<li>Default values: <duce>(x := c)</duce>. </li>
</ul>
</box>
<meta>
<p>
This page has been generated by a CDuce program.
</p>
<p>
<b>Todo</b>: toplevel phrases.
</p>
<p><a href="/">Home page</a> - <a href="mailto:Alain.Frisch@ens.fr">Webmaster</a>
</p>
</meta>
</main>
</page>
......@@ -35,8 +35,9 @@ type Content =
type InlineText =
Char
| <(`b|`i) {||}>[InlineText*]
| <duce>[InlineText*]
| Xa
| Ximg
| Ximg | Xbr
;;
type Box = <box title=String; subtitle=?String; link=String>Content
......@@ -48,6 +49,13 @@ let fun authors ([Author+] -> String)
| [ <author>a1 <author>a2 ] -> a1 @ ", and " @ a2
| [ <author>a; rem ] -> a @ ", " @ authors rem;;
let fun text (t : [InlineText*]) : Inlines =
map t with
<duce>x -> <b>[ <tt>(text x) ]
| <b>x -> <b>(text x)
| <i>x -> <i>(text x)
| z -> z;;
let fun content (t : Content) : Flow =
transform t with
| <section title=title>c -> [ <h4>title !(content c) ]
......@@ -58,15 +66,17 @@ let fun content (t : Content) : Flow =
| _ -> <b>tit
) '. '
!(authors aut) '. '
!com
!(text com)
<div class="abstract">[ 'Abstract:' !(content ab) ]
]
| <slides file=f>[ <title>tit aut::Author* <comment>com ] ->
[ <a href=f>tit '. ' !(authors aut) '. ' !com ]
[ <a href=f>tit '. ' !(authors aut) '. ' !(text com) ]
| <link url=url; title=title>com ->
[ <a href=url>title '. ' !com ]
[ <a href=url>title '. ' !(text com) ]
| <ul>lis -> [ <ul>(map lis with <li>x -> <li>(content x)) ]
| x -> [ x ];;
| <p>x -> [ <p>(text x) ]
| <ul>x -> [ <ul>(text x) ]
| x -> text [ x ];;
let fun main2html (Box -> Flow)
<box (r)>c ->
......@@ -94,7 +104,7 @@ let fun page2html (Page -> Xhtml)
<link rel="stylesheet"; href="cduce.css"; type="text/css"> []
]
<body>[
<div class="title">[ <h1>banner ]
<div class="title">[ <h1>(text banner) ]
<div id="Sidelog">navig
<div id="Content">(transform main with b -> main2html b)
]
......@@ -105,7 +115,7 @@ let fun do_page((String,String) -> [])
let _ = print [ 'Loading ' !inf '... ' ] in
let page = match load_xml inf with
| Page & p -> p
| _ -> raise ("Invalid input document" @ inf) in
| _ -> raise ("Invalid input document: " @ inf) in
let _ = print [ 'Generating html ... ' ] in
let html : String =
[ '<?xml version="1.0" encoding="iso-8859-1"?>'
......
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<site>
<page input="index.xml" output="index.html"/>
<page input="memento.xml" output="memento.html"/>
<page input="team.xml" output="team.html"/>
</site>
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<page>
<title>CDuce team</title>
<banner> The CDuce team </banner>
<!-- ********* Left panel ********* -->
<navig>
<toc/>
<box>
<p>
This page briefly presents the syntax of the CDuce language.
</p>
<ul>
<li><a href="/cgi-bin/cduce">Online demo</a></li>
<li><a href="/">Home page</a></li>
</ul>
</box>
</navig>
<!-- ********* Main panel ********* -->
<main>
<box title="CDuce @ ENS (Paris)" link="ens">
<ul>
<li>
<a href="http://www.eleves.ens.fr/home/frisch/">
Alain Frisch
</a> (Ph.D. student at ENS)
</li>
<li>
<a href="http://www.di.ens.fr/~castagna/">
Giuseppe Castagna
</a> (CNRS researcher)
</li>
</ul>
</box>
<box title="CDuce @ LRI (Orsay)" link="lri">
<ul>
<li>
<a href="http://www.lri.fr/~benzaken/">
Vronique Benzaken
</a> (Prof. Univ. Paris 11)
</li>
<li>
<a href="http://www.lri.fr/~burelle/">
Marwan Burelle
</a> (Ph.D student)
</li>
<li>
Cdric Miachon (DEA student at LRI)
</li>
</ul>
</box>
<box title="Other contacts" link="contacts">
<p>
<b>To be written</b>
</p>
</box>
</main>
</page>
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