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

Contents of /web/memento.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 554 - (hide annotations)
Tue Jul 10 17:44:15 2007 UTC (5 years, 10 months ago) by abate
File MIME type: text/xml
File size: 8119 byte(s)
[r2003-07-02 18:05:03 by cvscast] Update manual for namespaces and bug fix pretty printing p:* -- Alain

Original author: cvscast
Date: 2003-07-02 18:05:04+00:00
1 abate 254 <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
2 abate 341 <page name="memento">
3 abate 254
4 abate 388 <title>Memento</title>
5 abate 254
6 abate 341 <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 abate 254
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 abate 341 <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 abate 254 </ul>
32     </li>
33     <li>Unicode characters:
34     <ul>
35 abate 341 <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 abate 254 </ul>
39     </li>
40     <li>Symbolic atoms:
41     <ul>
42 abate 341 <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 abate 554 <li>CDuce also supports <local href="namespaces">XML Namespaces</local></li>
46 abate 254 </ul>
47     </li>
48     </ul>
49     </box>
50    
51     <box title="Operators" link="op">
52     <ul>
53     <li>Infix:
54 abate 388 <br/> <code>@</code> : concatenation of sequences
55 abate 341 <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 abate 254 </li>
59     <li>Prefix:
60 abate 341 <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 abate 254 </li>
67     </ul>
68     </box>
69    
70     <box title="Pairs" link="pair">
71     <ul>
72 abate 341 <li>Expressions: <code>(e1,e2)</code> </li>
73     <li>Types and patterns: <code>(t1,t2)</code> </li>
74 abate 254 <li>Note: tuples are right-associative pairs; e.g.:
75 abate 341 <code>(1,2,3)=(1,(2,3))</code> </li>
76 abate 254 <li>When a capture variable appears on both side of a pair pattern,
77     the two captured values are paired
78 abate 341 together (e.g. <code>match (1,2,3) with (x,(_,x)) -> x ==>
79     (1,3)</code>). </li>
80 abate 254 </ul>
81     </box>
82    
83     <box title="Sequences" link="seq">
84     <ul>
85 abate 341 <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 abate 254 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 abate 341 <li>Postfix repetition operators: <code>*,+,?</code>
95     and the ungreedy variants (for patterns) <code>*?, +?
96     ,??</code></li>
97 abate 254 <li>Concatenation of regexps</li>
98 abate 341 <li>For patterns, sequence capture variable <code>x::R</code> </li>
99 abate 254 </ul>
100     </li>
101     <li>It is possible to specify a tail, for expressions, types, and patterns;
102 abate 341 e.g.: <code>[ x::Int*; q ]</code> </li>
103     <li>Map: <code>map e with p1 -> e1 | ... | pn -> en</code>.
104 abate 254 Each element of e must be matched. </li>
105 abate 341 <li>Transform: <code>transform e with p1 -> e1 | ... | pn -> en</code>.
106 abate 254 Unmatched elements are discarded; each branch returns a sequence
107     and all the resulting sequences are concatenated together. </li>
108 abate 341 <li>Operators: concatenation <code>e1 @ e2 = [ !e1 !e2 ]</code>,
109     flattening <code>flatten e = transform e with x -> x</code>.
110 abate 254 </li>
111     </ul>
112     </box>
113    
114     <box title="Record" link="record">
115     <ul>
116 abate 341 <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 abate 254 (priority to the fields from the right argument) </li>
123 abate 341 <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 abate 554 <li>Labels are in fact Qualified Names (see <local href="namespaces"/>)</li>
128 abate 254 </ul>
129     </box>
130    
131     <box title="Strings" link="string">
132     <ul>
133     <li>Strings are actually sequences of characters.</li>
134 abate 341 <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 abate 254 </ul>
138     </box>
139    
140     <box title="XML elements" link="xml">
141     <ul>
142 abate 341 <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 abate 254 Similarly, parenthesis and curly braces may be omitted
146 abate 341 when attr is a record <code>l1=e1;...;ln=en</code>.
147     E.g: <code>&lt;a href="abc">[ 'abc' ]</code>.</li>
148 abate 254 <li>Types and patterns: same notations.</li>
149 abate 341 <li>Operators: <code>load_xml : String -> Any; print_xml : Any -> String</code>
150 abate 254 </li>
151     </ul>
152     </box>
153    
154     <box title="Functions" link="fun">
155     <ul>
156     <li>Expressions:
157     <ul>
158 abate 341 <li>General form: <code>fun f (t1->s1;...;tn->sn)
159     p1 -> e1 | ... | pn -> en</code> (<code>f</code> is optional) </li>
160     <li>Simple function: <code>fun f (p : t) : s = e</code>,
161     equivalent to <code>fun f (t -> s) p -> e</code> </li>
162     <li>Multiple arguments: <code>fun f (p1 : t1, p2 : t2,...) : s =
163     e</code>, equivalent to <code>fun f ((p1,p2,...):(t1,t2,...)) : s
164     = e</code> </li>
165 abate 254 </ul>
166     </li>
167 abate 341 <li>Types: <code>t -> s</code> </li>
168 abate 254 </ul>
169     </box>
170    
171     <box title="Pattern matching, exceptions, ..." link="match">
172     <ul>
173 abate 341 <li>Type restriction: <code>(e : t)</code> (forgets any more precise
174     type for <code>e</code>) </li>
175     <li>Pattern matching: <code>match e with p1 -> e1 | ... | pn ->
176     en</code></li>
177     <li>Local binding: <code>let p = e1 in e2</code>, equivalent to
178     <code>match e1 with p -> e2</code>;
179     <code>let p : t = e1 in e2</code> equivalent to
180     <code>let p = (e1 : t) in e2</code> </li>
181     <li>If-then-else: <code>if e1 then e2 else e3</code>, equivalent to
182     <code>match e1 with `true -> e2 | `false -> e3</code></li>
183 abate 254 <li>Exceptions: <ul>
184 abate 341 <li>Raise exception: <code>raise e</code></li>
185     <li>Handle exception: <code>try e with p1 -> e1 | ... | pn ->
186     en</code></li>
187 abate 254 </ul> </li>
188     </ul>
189     </box>
190    
191     <box title="More about types and patterns" link="type">
192     <ul>
193 abate 341 <li>Boolean connectives: <code>&amp;,|,\</code> (<code>|</code> is
194 abate 254 first-match). </li>
195 abate 341 <li>Empty and universal types: <code>Empty,Any</code> or
196     <code>_</code>.</li>
197     <li>Recursive types and patterns: <code>t where T1 = t2 and ... and
198     Tn = tn</code>.</li>
199     <li>Capture variable: <code>x</code>. </li>
200     <li>Default values: <code>(x := c)</code>. </li>
201 abate 254 </ul>
202     </box>
203 abate 282
204 abate 341 <box title="Toplevel statements" link="toplevel">
205 abate 282 <ul>
206 abate 554 <li>Global expression to evaluate.</li>
207     <li>Global let-binding.</li>
208     <li>Global function declaration.</li>
209 abate 341 <li>Type declarations: <code>type T = t</code>.</li>
210 abate 554 <li>Global <local href="namespaces">namespace</local>:
211     <code>namespace p = "..."</code>,
212     <code>namespace "..."</code>.</li>
213     <li>Source inclusion: <code>include %%filename_string%%</code>.</li>
214     <li>Debug directives: <code>debug %%directive argument%%</code> <br/>
215     where <code>%%directive%%</code> is one of the following: <code>accept</code>,
216     <code>subtype</code>, <code>compile</code>, <code>sample</code>, <code>filter</code>.
217 abate 282 </li>
218 abate 554 <li>Toplevel directives: <code>#env</code>, <code>#quit</code>,
219     <code>#reinit_ns</code>.</li>
220 abate 282 </ul>
221     </box>
222    
223 abate 254 </page>

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