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

Contents of /web/memento.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 341 - (show annotations)
Tue Jul 10 17:26:43 2007 UTC (5 years, 10 months ago) by abate
File MIME type: text/xml
File size: 7705 byte(s)
[r2003-05-14 16:49:27 by cvscast] Web site is now a tree

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

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