/[svn]/web/memento.xml
ViewVC logotype

Contents of /web/memento.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 254 - (show annotations)
Tue Jul 10 17:19:36 2007 UTC (5 years, 10 months ago) by abate
File MIME type: text/xml
File size: 7524 byte(s)
[r2003-03-16 18:43:57 by cvscast] Empty log message

Original author: cvscast
Date: 2003-03-16 18:43:58+00:00
1 <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
2 <page>
3
4 <title>CDuce memento</title>
5 <banner> CDuce memento </banner>
6
7 <!-- ********* Left panel ********* -->
8 <navig>
9 <toc/>
10 <box>
11 <p>
12 This page briefly presents the syntax of the CDuce language.
13 </p>
14
15 <ul>
16 <li><a href="/cgi-bin/cduce">Online demo</a></li>
17 <li><a href="/">Home page</a></li>
18 </ul>
19 </box>
20 </navig>
21
22 <!-- ********* Main panel ********* -->
23
24 <main>
25
26 <box title="Identifiers" link="id">
27 <ul>
28 <li> Type and Pattern identifiers: words formed by of unicode letters and and
29 the underscore "_" character, starting by a capitalized letter. </li>
30
31 <li> value identifiers: words formed by of unicode letters and the underscore "
32 _" character, starting by a capitalized letter or underscore.</li>
33 </ul>
34 </box>
35
36 <box title="Scalars" link="scalars">
37 <ul>
38 <li>Large integers:
39 <ul>
40 <li>Values: <duce>0,1,2,3,...</duce> </li>
41 <li>Types: intervals <duce>-*--10, 20--30, 50--*, ...</duce>,
42 singletons <duce>0,1,2,3,...</duce> </li>
43 <li>Operators: <duce>+,-,/,*,div,mod, int_of</duce> </li>
44 </ul>
45 </li>
46 <li>Unicode characters:
47 <ul>
48 <li>Values: <duce>'a','b','c'...</duce> </li>
49 <li>Types: intervals <duce>'a'--'z', '0'--'9'</duce>,
50 singletons <duce>'a','b','c',...</duce> </li>
51 </ul>
52 </li>
53 <li>Symbolic atoms:
54 <ul>
55 <li>Values: <duce>`A, `B, `a, `b, `true, `false, ...</duce> </li>
56 <li>Types: singletons <duce>`A, `B, ...</duce> </li>
57 </ul>
58 </li>
59 </ul>
60 </box>
61
62 <box title="Operators" link="op">
63 <ul>
64 <li>Infix:
65 <br/> <duce>@</duce> : String,String -> String
66 <br/> <duce>+,*,-,div,mod</duce> : Integer,Integer -> Integer
67 <br/> <duce>=, &lt;&lt;, &lt;=, &gt;&gt;, &gt;= </duce> :
68 Integer,Integer -> Bool = <duce>`true | `false</duce>
69 </li>
70 <li>Prefix:
71 <br/><duce>load_xml,load_html, dump_to_file</duce> : String -> Any
72 <br/><duce>print_xml</duce> : Any -> String
73 <br/><duce>print</duce> : String -> []
74 <br/><duce>int_of</duce> : [('0'--'9')+] -> Integer
75 <br/><duce>string_of</duce> : Integer -> String
76 </li>
77 <li>Postfix:
78 <br/><duce>?,*,+,??,*?,+?</duce> : for regexp
79 </li>
80 </ul>
81 </box>
82
83 <box title="Pairs" link="pair">
84 <ul>
85 <li>Expressions: <duce>(e1,e2)</duce> </li>
86 <li>Types and patterns: <duce>(t1,t2)</duce> </li>
87 <li>Note: tuples are right-associative pairs; e.g.:
88 <duce>(1,2,3)=(1,(2,3))</duce> </li>
89 <li>When a capture variable appears on both side of a pair pattern,
90 the two captured values are paired
91 together (e.g. <duce>match (1,2,3) with (x,(_,x)) -> x ==>
92 (1,3)</duce>). </li>
93 </ul>
94 </box>
95
96 <box title="Sequences" link="seq">
97 <ul>
98 <li>Expressions: <duce>[ 1 2 3 ]</duce>,
99 which is syntactic sugar for <duce>(1,(2,(3,`nil)))</duce> </li>
100 <li>A sub-sequence can be escaped by !: <duce>[ 1 2 ![ 3 4 ] 5
101 ]</duce> is then equal to <duce>[ 1 2 3 4 5 ]</duce> . </li>
102 <li>Types and patterns : <duce>[ R ]</duce> where <duce>R</duce> is
103 a regular expression built on types and patterns:
104 <ul>
105 <li>A type or a pattern is a regexp by itself, matching a single
106 element of the sequence </li>
107 <li>Postfix repetition operators: <duce>*,+,?</duce>
108 and the ungreedy variants (for patterns) <duce>*?, +?
109 ,??</duce></li>
110 <li>Concatenation of regexps</li>
111 <li>For patterns, sequence capture variable <duce>x::R</duce> </li>
112 </ul>
113 </li>
114 <li>It is possible to specify a tail, for expressions, types, and patterns;
115 e.g.: <duce>[ x::Int*; q ]</duce> </li>
116 <li>Map: <duce>map e with p1 -> e1 | ... | pn -> en</duce>.
117 Each element of e must be matched. </li>
118 <li>Transform: <duce>transform e with p1 -> e1 | ... | pn -> en</duce>.
119 Unmatched elements are discarded; each branch returns a sequence
120 and all the resulting sequences are concatenated together. </li>
121 <li>Operators: concatenation <duce>e1 @ e2 = [ !e1 !e2 ]</duce>,
122 flattening <duce>flatten e = transform e with x -> x</duce>.
123 </li>
124 </ul>
125 </box>
126
127 <box title="Record" link="record">
128 <ul>
129 <li>Records litteral <duce>{ l1 = e1; ...; ln = en }</duce></li>
130 <li>Types: <duce>{| l1 = t1; ...; ln = tn |}</duce> (closed, no more
131 fields allowed), <duce>>{ l1 = t1; ...; ln = tn }</duce> (open,
132 any other field allowed). Optional fields: <duce>li =? ti</duce>
133 instead of <duce>li = ti</duce>.</li>
134 <li>Record concatenation: <duce>e1 + e2</duce>
135 (priority to the fields from the right argument) </li>
136 <li>Field removal: <duce>e1 \ l</duce> (does nothing if the
137 field <duce>l</duce> is not present)</li>
138 <li>Field access: <duce>e1 . l</duce></li>
139 <li>Record: <duce>{ l1 = p1; ...; ln = pn }</duce></li>
140 </ul>
141 </box>
142
143 <box title="Strings" link="string">
144 <ul>
145 <li>Strings are actually sequences of characters.</li>
146 <li>Expressions: <duce>"abc", [ 'abc' ], [ 'a' 'b' 'c' ]</duce>. </li>
147 <li>Operators: <duce>string_of, print, dump_to_file</duce></li>
148 <li><duce>PCDATA</duce> means <duce>Char*</duce> inside regular expressions</li>
149 </ul>
150 </box>
151
152 <box title="XML elements" link="xml">
153 <ul>
154 <li>Expressions: <duce> &lt;(tag) (attr)>content</duce> </li>
155 <li>If the tag is an atom <duce>`X</duce>, it can be written
156 <duce>X</duce> (without the <duce>(..)</duce>).
157 Similarly, parenthesis and curly braces may be omitted
158 when attr is a record <duce>l1=e1;...;ln=en</duce>.
159 E.g: <duce>&lt;a href="abc">[ 'abc' ]</duce>.</li>
160 <li>Types and patterns: same notations.</li>
161 <li>Operators: <duce>load_xml : String -> Any; print_xml : Any -> String</duce>
162 </li>
163 </ul>
164 </box>
165
166 <box title="Functions" link="fun">
167 <ul>
168 <li>Expressions:
169 <ul>
170 <li>General form: <duce>fun f (t1->s1;...;tn->sn)
171 p1 -> e1 | ... | pn -> en</duce> (<duce>f</duce> is optional) </li>
172 <li>Simple function: <duce>fun f (p : t) : s = e</duce>,
173 equivalent to <duce>fun f (t -> s) p -> e</duce> </li>
174 <li>Multiple arguments: <duce>fun f (p1 : t1, p2 : t2,...) : s =
175 e</duce>, equivalent to <duce>fun f ((p1,p2,...):(t1,t2,...)) : s
176 = e</duce> </li>
177 </ul>
178 </li>
179 <li>Types: <duce>t -> s</duce> </li>
180 </ul>
181 </box>
182
183 <box title="Pattern matching, exceptions, ..." link="match">
184 <ul>
185 <li>Type restriction: <duce>(e : t)</duce> (forgets any more precise
186 type for <duce>e</duce>) </li>
187 <li>Pattern matching: <duce>match e with p1 -> e1 | ... | pn ->
188 en</duce></li>
189 <li>Local binding: <duce>let p = e1 in e2</duce>, equivalent to
190 <duce>match e1 with p -> e2</duce>;
191 <duce>let p : t = e1 in e2</duce> equivalent to
192 <duce>let p = (e1 : t) in e2</duce> </li>
193 <li>If-then-else: <duce>if e1 then e2 else e3</duce>, equivalent to
194 <duce>match e1 with `true -> e2 | `false -> e3</duce></li>
195 <li>Exceptions: <ul>
196 <li>Raise exception: <duce>raise e</duce></li>
197 <li>Handle exception: <duce>try e with p1 -> e1 | ... | pn ->
198 en</duce></li>
199 </ul> </li>
200 </ul>
201 </box>
202
203 <box title="More about types and patterns" link="type">
204 <ul>
205 <li>Boolean connectives: <duce>&amp;,|,\</duce> (<duce>|</duce> is
206 first-match). </li>
207 <li>Empty and universal types: <duce>Empty,Any</duce> or
208 <duce>_</duce>.</li>
209 <li>Recursive types and patterns: <duce>t where T1 = t2 and ... and
210 Tn = tn</duce>.</li>
211 <li>Capture variable: <duce>x</duce>. </li>
212 <li>Default values: <duce>(x := c)</duce>. </li>
213 </ul>
214 </box>
215 <meta>
216 <p>
217 This page has been generated by a CDuce program.
218 </p>
219 <p>
220 <b>Todo</b>: toplevel phrases.
221 </p>
222 <p><a href="/">Home page</a> - <a href="mailto:Alain.Frisch@ens.fr">Webmaster</a>
223 </p>
224 </meta>
225
226 </main>
227 </page>

CVS Admin">CVS Admin
ViewVC Help
Powered by ViewVC 1.1.5