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

Contents of /web/memento.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 630 - (show annotations)
Tue Jul 10 17:49:23 2007 UTC (5 years, 11 months ago) by abate
File MIME type: text/xml
File size: 8417 byte(s)
[r2003-07-27 15:12:12 by cvscast] Doc references

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

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