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

Contents of /web/memento.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 776 - (show annotations)
Tue Jul 10 18:02:21 2007 UTC (5 years, 11 months ago) by abate
File MIME type: text/xml
File size: 8968 byte(s)
[r2003-11-19 17:01:28 by beppe] typo

Original author: beppe
Date: 2003-11-19 17:01:28+00:00
1 <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
2 <page name="memento">
3
4 <title>Quick reference</title>
5
6 <left>
7 <p>This page briefly presents the syntax of the CDuce language.</p>
8 <boxes-toc/>
9 <p>See also:</p>
10 <local-links href="index,proto,manual,tutorial,papers"/>
11 </left>
12
13 <box title="Identifiers" link="id">
14 <ul>
15 <li> Type and Pattern identifiers: words formed by of unicode letters and and
16 the underscore "_" character, starting by a capitalized letter. </li>
17
18 <li> value identifiers: words formed by of unicode letters and the underscore "
19 _" character, starting by a capitalized letter or underscore.</li>
20 </ul>
21 </box>
22
23 <box title="Scalars" link="scalars">
24 <ul>
25 <li>Large integers:
26 <ul>
27 <li>Values: <code>0,1,2,3,...</code> </li>
28 <li>Types: intervals <code>-*--10, 20--30, 50--*, ...</code>,
29 singletons <code>0,1,2,3,...</code> </li>
30 <li>Operators: <code>+,-,/,*,div,mod, int_of</code> </li>
31 </ul>
32 </li>
33 <li>Unicode characters:
34 <ul>
35 <li>Values: <code>'a','b','c'...</code> </li>
36 <li>Types: intervals <code>'a'--'z', '0'--'9'</code>,
37 singletons <code>'a','b','c',...</code> </li>
38 </ul>
39 </li>
40 <li>Symbolic atoms:
41 <ul>
42 <li>Values: <code>`A, `B, `a, `b, `true, `false, ...</code> </li>
43 <li>Types: singletons <code>`A, `B, ...</code> </li>
44 <li>Operators: <code>atom_of</code> : String -> Atom</li>
45 <li>CDuce also supports <local href="namespaces">XML Namespaces</local></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> : concatenation of sequences
55 <br/> <code>+,*,-,div,mod</code> : Integer,Integer -> Integer
56 <br/> <code>=, &lt;&lt;, &lt;=, &gt;&gt;, &gt;= </code> :
57 <i>t</i>,<i>t</i> -> Bool = <code>`true | `false</code> (any non functional type <i>t</i>)
58 <br/> <code>||, &amp;&amp;</code> : Bool,Bool -> Bool
59 <br/> <code>not</code>: Bool -> Bool
60 </li>
61 <li>Prefix:
62 <br/><code>load_xml,load_html</code> : String -> Any,
63 <br/><code>dump_to_file</code> : String -> String -> Any,
64 <br/><code>print_xml</code> : Any -> String
65 <br/><code>print</code> : String -> []
66 <br/><code>int_of</code> : ['-'? ('0'--'9')+] -> Integer
67 <br/><code>string_of</code> : Any -> Latin1
68 </li>
69 </ul>
70 </box>
71
72 <box title="Pairs" link="pair">
73 <ul>
74 <li>Expressions: <code>(e1,e2)</code> </li>
75 <li>Types and patterns: <code>(t1,t2)</code> </li>
76 <li>Note: tuples are right-associative pairs; e.g.:
77 <code>(1,2,3)=(1,(2,3))</code> </li>
78 <li>When a capture variable appears on both side of a pair pattern,
79 the two captured values are paired
80 together (e.g. <code>match (1,2,3) with (x,(_,x)) -> x ==>
81 (1,3)</code>). </li>
82 </ul>
83 </box>
84
85 <box title="Sequences" link="seq">
86 <ul>
87 <li>Expressions: <code>[ 1 2 3 ]</code>,
88 which is syntactic sugar for <code>(1,(2,(3,`nil)))</code> </li>
89 <li>A sub-sequence can be escaped by !: <code>[ 1 2 ![ 3 4 ] 5
90 ]</code> is then equal to <code>[ 1 2 3 4 5 ]</code> . </li>
91 <li>Types and patterns : <code>[ R ]</code> where <code>R</code> is
92 a regular expression built on types and patterns:
93 <ul>
94 <li>A type or a pattern is a regexp by itself, matching a single
95 element of the sequence </li>
96 <li>Postfix repetition operators: <code>*,+,?</code>
97 and the ungreedy variants (for patterns) <code>*?, +?
98 ,??</code></li>
99 <li>Concatenation of regexps</li>
100 <li>For patterns, sequence capture variable <code>x::R</code> </li>
101 </ul>
102 </li>
103 <li>It is possible to specify a tail, for expressions, types, and patterns;
104 e.g.: <code>[ x::Int*; q ]</code> </li>
105 <li>Map: <code>map e with p1 -> e1 | ... | pn -> en</code>.
106 Each element of e must be matched. </li>
107 <li>Transform: <code>transform e with p1 -> e1 | ... | pn -> en</code>.
108 Unmatched elements are discarded; each branch returns a sequence
109 and all the resulting sequences are concatenated together. </li>
110 <li>Operators: concatenation <code>e1 @ e2 = [ !e1 !e2 ]</code>,
111 flattening <code>flatten e = transform e with x -> x</code>.
112 </li>
113 </ul>
114 </box>
115
116 <box title="Record" link="record">
117 <ul>
118 <li>Records litteral <code>{ l1 = e1; ...; ln = en }</code></li>
119 <li>Types: <code>{| l1 = t1; ...; ln = tn |}</code> (closed, no more
120 fields allowed), <code>>{ l1 = t1; ...; ln = tn }</code> (open,
121 any other field allowed). Optional fields: <code>li =? ti</code>
122 instead of <code>li = ti</code>.</li>
123 <li>Record concatenation: <code>e1 + e2</code>
124 (priority to the fields from the right argument) </li>
125 <li>Field removal: <code>e1 \ l</code> (does nothing if the
126 field <code>l</code> is not present)</li>
127 <li>Field access: <code>e1 . l</code></li>
128 <li>Record: <code>{ l1 = p1; ...; ln = pn }</code></li>
129 <li>Labels are in fact Qualified Names (see <local href="namespaces"/>)</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 (semicolon can also be omitted in this case).
150 E.g: <code>&lt;a href="abc">[ 'abc' ]</code>.</li>
151 <li>Types and patterns: same notations.</li>
152 <li>Tree transformation: <code>xtransform e with p1 -> e1 | ... | pn -> en</code>.
153 Applies to sequences of XML trees. Unmatched elements are left unchanged and the
154 transformation is recursively applied to the sequence of children of the unmatched
155 element; as for transform, each branch returns a sequence
156 and all the resulting sequences are concatenated together. </li>
157 <li>Operators: <code>load_xml : String -> Any; print_xml : Any -> String</code>
158 </li>
159 </ul>
160 </box>
161
162 <box title="Functions" link="fun">
163 <ul>
164 <li>Expressions:
165 <ul>
166 <li>General form: <code>fun f (t1->s1;...;tn->sn)
167 p1 -> e1 | ... | pn -> en</code> (<code>f</code> is optional) </li>
168 <li>Simple function: <code>fun f (p : t) : s = e</code>,
169 equivalent to <code>fun f (t -> s) p -> e</code> </li>
170 <li>Multiple arguments: <code>fun f (p1 : t1, p2 : t2,...) : s =
171 e</code>, equivalent to <code>fun f ((p1,p2,...):(t1,t2,...)) : s
172 = e</code> </li>
173 </ul>
174 </li>
175 <li>Types: <code>t -> s</code> </li>
176 </ul>
177 </box>
178
179 <box title="Pattern matching, exceptions, ..." link="match">
180 <ul>
181 <li>Type restriction: <code>(e : t)</code> (forgets any more precise
182 type for <code>e</code>) </li>
183 <li>Pattern matching: <code>match e with p1 -> e1 | ... | pn ->
184 en</code></li>
185 <li>Local binding: <code>let p = e1 in e2</code>, equivalent to
186 <code>match e1 with p -> e2</code>;
187 <code>let p : t = e1 in e2</code> equivalent to
188 <code>let p = (e1 : t) in e2</code> </li>
189 <li>If-then-else: <code>if e1 then e2 else e3</code>, equivalent to
190 <code>match e1 with `true -> e2 | `false -> e3</code></li>
191 <li>Exceptions: <ul>
192 <li>Raise exception: <code>raise e</code></li>
193 <li>Handle exception: <code>try e with p1 -> e1 | ... | pn ->
194 en</code></li>
195 </ul> </li>
196 </ul>
197 </box>
198
199 <box title="More about types and patterns" link="type">
200 <ul>
201 <li>Boolean connectives: <code>&amp;,|,\</code> (<code>|</code> is
202 first-match). </li>
203 <li>Empty and universal types: <code>Empty,Any</code> or
204 <code>_</code>.</li>
205 <li>Recursive types and patterns: <code>t where T1 = t2 and ... and
206 Tn = tn</code>.</li>
207 <li>Capture variable: <code>x</code>. </li>
208 <li>Default values: <code>(x := c)</code>. </li>
209 </ul>
210 </box>
211
212 <box title="References" link="ref">
213
214 <ul>
215 <li>Type: <code>ref %%T%%</code>.</li>
216 <li>Construction: <code>ref %%T%% %%e%%</code>.</li>
217 <li>Dereferencing: <code>!%%e1%%</code>.</li>
218 <li>Assignment: <code>%%e1%% := %%e2%%</code>.</li>
219 </ul>
220
221 </box>
222
223 <box title="Toplevel statements" link="toplevel">
224 <ul>
225 <li>Global expression to evaluate.</li>
226 <li>Global let-binding.</li>
227 <li>Global function declaration.</li>
228 <li>Type declarations: <code>type T = t</code>.</li>
229 <li>Global <local href="namespaces">namespace</local>:
230 <code>namespace p = "..."</code>,
231 <code>namespace "..."</code>.</li>
232 <li>Source inclusion: <code>include %%filename_string%%</code>.</li>
233 <li>Debug directives: <code>debug %%directive argument%%</code> <br/>
234 where <code>%%directive%%</code> is one of the following: <code>accept</code>,
235 <code>subtype</code>, <code>compile</code>, <code>sample</code>, <code>filter</code>.
236 </li>
237 <li>Toplevel directives: <code>#env</code>, <code>#quit</code>,
238 <code>#reinit_ns</code>.</li>
239 </ul>
240 </box>
241
242 </page>

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