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

Contents of /web/memento.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 329 - (show annotations)
Tue Jul 10 17:25:34 2007 UTC (5 years, 11 months ago) by abate
File MIME type: text/xml
File size: 7996 byte(s)
[r2003-05-11 09:30:40 by cvscast] atom_of

Original author: cvscast
Date: 2003-05-11 09:30:41+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 <li>Operators: <duce>atom_of</duce> : String -> Atom</li>
58 </ul>
59 </li>
60 </ul>
61 </box>
62
63 <box title="Operators" link="op">
64 <ul>
65 <li>Infix:
66 <br/> <duce>@</duce> : String,String -> String
67 <br/> <duce>+,*,-,div,mod</duce> : Integer,Integer -> Integer
68 <br/> <duce>=, &lt;&lt;, &lt;=, &gt;&gt;, &gt;= </duce> :
69 Integer,Integer -> Bool = <duce>`true | `false</duce>
70 </li>
71 <li>Prefix:
72 <br/><duce>load_xml,load_html</duce> : String -> Any,
73 <br/><duce>dump_to_file</duce> : String -> String -> Any,
74 <br/><duce>print_xml</duce> : Any -> String
75 <br/><duce>print</duce> : String -> []
76 <br/><duce>int_of</duce> : [('0'--'9')+] -> Integer
77 <br/><duce>string_of</duce> : Integer -> String
78 </li>
79 <li>Postfix:
80 <br/><duce>?,*,+,??,*?,+?</duce> : for regexp
81 </li>
82 </ul>
83 </box>
84
85 <box title="Pairs" link="pair">
86 <ul>
87 <li>Expressions: <duce>(e1,e2)</duce> </li>
88 <li>Types and patterns: <duce>(t1,t2)</duce> </li>
89 <li>Note: tuples are right-associative pairs; e.g.:
90 <duce>(1,2,3)=(1,(2,3))</duce> </li>
91 <li>When a capture variable appears on both side of a pair pattern,
92 the two captured values are paired
93 together (e.g. <duce>match (1,2,3) with (x,(_,x)) -> x ==>
94 (1,3)</duce>). </li>
95 </ul>
96 </box>
97
98 <box title="Sequences" link="seq">
99 <ul>
100 <li>Expressions: <duce>[ 1 2 3 ]</duce>,
101 which is syntactic sugar for <duce>(1,(2,(3,`nil)))</duce> </li>
102 <li>A sub-sequence can be escaped by !: <duce>[ 1 2 ![ 3 4 ] 5
103 ]</duce> is then equal to <duce>[ 1 2 3 4 5 ]</duce> . </li>
104 <li>Types and patterns : <duce>[ R ]</duce> where <duce>R</duce> is
105 a regular expression built on types and patterns:
106 <ul>
107 <li>A type or a pattern is a regexp by itself, matching a single
108 element of the sequence </li>
109 <li>Postfix repetition operators: <duce>*,+,?</duce>
110 and the ungreedy variants (for patterns) <duce>*?, +?
111 ,??</duce></li>
112 <li>Concatenation of regexps</li>
113 <li>For patterns, sequence capture variable <duce>x::R</duce> </li>
114 </ul>
115 </li>
116 <li>It is possible to specify a tail, for expressions, types, and patterns;
117 e.g.: <duce>[ x::Int*; q ]</duce> </li>
118 <li>Map: <duce>map e with p1 -> e1 | ... | pn -> en</duce>.
119 Each element of e must be matched. </li>
120 <li>Transform: <duce>transform e with p1 -> e1 | ... | pn -> en</duce>.
121 Unmatched elements are discarded; each branch returns a sequence
122 and all the resulting sequences are concatenated together. </li>
123 <li>Operators: concatenation <duce>e1 @ e2 = [ !e1 !e2 ]</duce>,
124 flattening <duce>flatten e = transform e with x -> x</duce>.
125 </li>
126 </ul>
127 </box>
128
129 <box title="Record" link="record">
130 <ul>
131 <li>Records litteral <duce>{ l1 = e1; ...; ln = en }</duce></li>
132 <li>Types: <duce>{| l1 = t1; ...; ln = tn |}</duce> (closed, no more
133 fields allowed), <duce>>{ l1 = t1; ...; ln = tn }</duce> (open,
134 any other field allowed). Optional fields: <duce>li =? ti</duce>
135 instead of <duce>li = ti</duce>.</li>
136 <li>Record concatenation: <duce>e1 + e2</duce>
137 (priority to the fields from the right argument) </li>
138 <li>Field removal: <duce>e1 \ l</duce> (does nothing if the
139 field <duce>l</duce> is not present)</li>
140 <li>Field access: <duce>e1 . l</duce></li>
141 <li>Record: <duce>{ l1 = p1; ...; ln = pn }</duce></li>
142 </ul>
143 </box>
144
145 <box title="Strings" link="string">
146 <ul>
147 <li>Strings are actually sequences of characters.</li>
148 <li>Expressions: <duce>"abc", [ 'abc' ], [ 'a' 'b' 'c' ]</duce>. </li>
149 <li>Operators: <duce>string_of, print, dump_to_file</duce></li>
150 <li><duce>PCDATA</duce> means <duce>Char*</duce> inside regular expressions</li>
151 </ul>
152 </box>
153
154 <box title="XML elements" link="xml">
155 <ul>
156 <li>Expressions: <duce> &lt;(tag) (attr)>content</duce> </li>
157 <li>If the tag is an atom <duce>`X</duce>, it can be written
158 <duce>X</duce> (without the <duce>(..)</duce>).
159 Similarly, parenthesis and curly braces may be omitted
160 when attr is a record <duce>l1=e1;...;ln=en</duce>.
161 E.g: <duce>&lt;a href="abc">[ 'abc' ]</duce>.</li>
162 <li>Types and patterns: same notations.</li>
163 <li>Operators: <duce>load_xml : String -> Any; print_xml : Any -> String</duce>
164 </li>
165 </ul>
166 </box>
167
168 <box title="Functions" link="fun">
169 <ul>
170 <li>Expressions:
171 <ul>
172 <li>General form: <duce>fun f (t1->s1;...;tn->sn)
173 p1 -> e1 | ... | pn -> en</duce> (<duce>f</duce> is optional) </li>
174 <li>Simple function: <duce>fun f (p : t) : s = e</duce>,
175 equivalent to <duce>fun f (t -> s) p -> e</duce> </li>
176 <li>Multiple arguments: <duce>fun f (p1 : t1, p2 : t2,...) : s =
177 e</duce>, equivalent to <duce>fun f ((p1,p2,...):(t1,t2,...)) : s
178 = e</duce> </li>
179 </ul>
180 </li>
181 <li>Types: <duce>t -> s</duce> </li>
182 </ul>
183 </box>
184
185 <box title="Pattern matching, exceptions, ..." link="match">
186 <ul>
187 <li>Type restriction: <duce>(e : t)</duce> (forgets any more precise
188 type for <duce>e</duce>) </li>
189 <li>Pattern matching: <duce>match e with p1 -> e1 | ... | pn ->
190 en</duce></li>
191 <li>Local binding: <duce>let p = e1 in e2</duce>, equivalent to
192 <duce>match e1 with p -> e2</duce>;
193 <duce>let p : t = e1 in e2</duce> equivalent to
194 <duce>let p = (e1 : t) in e2</duce> </li>
195 <li>If-then-else: <duce>if e1 then e2 else e3</duce>, equivalent to
196 <duce>match e1 with `true -> e2 | `false -> e3</duce></li>
197 <li>Exceptions: <ul>
198 <li>Raise exception: <duce>raise e</duce></li>
199 <li>Handle exception: <duce>try e with p1 -> e1 | ... | pn ->
200 en</duce></li>
201 </ul> </li>
202 </ul>
203 </box>
204
205 <box title="More about types and patterns" link="type">
206 <ul>
207 <li>Boolean connectives: <duce>&amp;,|,\</duce> (<duce>|</duce> is
208 first-match). </li>
209 <li>Empty and universal types: <duce>Empty,Any</duce> or
210 <duce>_</duce>.</li>
211 <li>Recursive types and patterns: <duce>t where T1 = t2 and ... and
212 Tn = tn</duce>.</li>
213 <li>Capture variable: <duce>x</duce>. </li>
214 <li>Default values: <duce>(x := c)</duce>. </li>
215 </ul>
216 </box>
217
218 <box title="Toplevel statements" link="type">
219 <ul>
220 <li>Type declarations: <duce>type T = t</duce>.</li>
221 <li>Source inclusion: <duce>include </duce> <i> filename_string</i></li>
222 <li>Debug directives: <duce>debug </duce> <i> directive argument</i> <br/>
223 where <i> directive</i> is one of the following: <duce>accept</duce>,
224 <duce>subtype</duce>, <duce>compile</duce>.
225 </li>
226 </ul>
227 </box>
228
229
230 <meta>
231 <p>
232 This page has been generated by a CDuce program.
233 </p>
234 <p><a href="/">Home page</a> - <a href="mailto:Alain.Frisch@ens.fr">Webmaster</a>
235 </p>
236 </meta>
237
238 </main>
239 </page>

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