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

Contents of /web/memento.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 322 - (hide annotations)
Tue Jul 10 17:25:07 2007 UTC (5 years, 11 months ago) by abate
File MIME type: text/xml
File size: 7933 byte(s)
[r2003-05-10 22:41:35 by cvscast] Empty log message

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

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