~ubuntu-branches/ubuntu/karmic/ocaml-doc/karmic

« back to all changes in this revision

Viewing changes to ocaml.html/manual009.html

  • Committer: Bazaar Package Importer
  • Author(s): Vanicat Rémi
  • Date: 2002-02-05 10:51:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020205105143-a061tunf8tev07ne
Tags: 3.04-4
* New debian maintainer
* Split doc-base file
* Move to non-free
* Change the copyright file to the copyright of the documentation
* remove FAQs (their license prohibit their redistribution)
* corrected the examples

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
 
2
            "http://www.w3.org/TR/REC-html40/loose.dtd">
 
3
<HTML>
 
4
<HEAD>
 
5
 
 
6
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 
7
<META name="GENERATOR" content="hevea 1.06-7 of 2001-11-14">
 
8
<TITLE>
 
9
 Lexical conventions
 
10
</TITLE>
 
11
</HEAD>
 
12
<BODY TEXT=black BGCOLOR=white>
 
13
<A HREF="manual008.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
 
14
<A HREF="manual010.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
 
15
<HR>
 
16
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
 
17
<TR><TD BGCOLOR="#66ff66"><DIV ALIGN=center><TABLE>
 
18
<TR><TD><A NAME="htoc50"><B><FONT SIZE=5>6.1</FONT></B></A></TD>
 
19
<TD WIDTH="100%" ALIGN=center><B><FONT SIZE=5>Lexical conventions</FONT></B></TD>
 
20
</TR></TABLE></DIV></TD>
 
21
</TR></TABLE>
 
22
<BR>
 
23
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
 
24
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
 
25
<TR><TD><B>Blanks</B></TD>
 
26
</TR></TABLE></DIV></TD>
 
27
</TR></TABLE><BR>
 
28
The following characters are considered as blanks: space, newline,
 
29
horizontal tabulation, carriage return, line feed and form feed. Blanks are
 
30
ignored, but they separate adjacent identifiers, literals and
 
31
keywords that would otherwise be confused as one single identifier,
 
32
literal or keyword.<BR>
 
33
<BR>
 
34
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
 
35
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
 
36
<TR><TD><B>Comments</B></TD>
 
37
</TR></TABLE></DIV></TD>
 
38
</TR></TABLE><BR>
 
39
Comments are introduced by the two characters <TT>(*</TT>, with no
 
40
intervening blanks, and terminated by the characters <TT>*)</TT>, with
 
41
no intervening blanks. Comments are treated as blank characters.
 
42
Comments do not occur inside string or character literals. Nested
 
43
comments are handled correctly.<BR>
 
44
<BR>
 
45
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
 
46
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
 
47
<TR><TD><B>Identifiers</B></TD>
 
48
</TR></TABLE></DIV></TD>
 
49
</TR></TABLE><BR>
 
50
<DIV ALIGN=center><TABLE CELLSPACING=2 CELLPADDING=0>
 
51
<TR><TD ALIGN=right NOWRAP>
 
52
<TT><I><FONT COLOR=maroon>ident</FONT></I></TT></TD>
 
53
<TD ALIGN=right NOWRAP>::=</TD>
 
54
<TD ALIGN=left NOWRAP> (<TT><I><FONT COLOR=maroon>letter</FONT></I></TT>| <TT><FONT COLOR=blue>_</FONT></TT>) { <TT><I><FONT COLOR=maroon>letter</FONT></I></TT>| <TT><FONT COLOR=blue>0</FONT></TT>...<TT><FONT COLOR=blue>9</FONT></TT>| <TT><FONT COLOR=blue>_</FONT></TT>| <TT><FONT COLOR=blue>'</FONT></TT> }</TD>
 
55
</TR>
 
56
<TR><TD ALIGN=right NOWRAP>
 
57
<TT><I><FONT COLOR=maroon>letter</FONT></I></TT></TD>
 
58
<TD ALIGN=right NOWRAP>::=</TD>
 
59
<TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>A</FONT></TT> ... <TT><FONT COLOR=blue>Z</FONT></TT> |  <TT><FONT COLOR=blue>a</FONT></TT> ... <TT><FONT COLOR=blue>z</FONT></TT></TD>
 
60
</TR></TABLE></DIV><BR>
 
61
Identifiers are sequences of letters, digits, <TT>_</TT> (the underscore
 
62
character), and <TT>'</TT> (the single quote), starting with a
 
63
letter or an underscore.
 
64
Letters contain at least the 52 lowercase and uppercase
 
65
letters from the ASCII set. The current implementation (except on
 
66
MacOS) also recognizes as letters all accented characters from the ISO
 
67
8859-1 (``ISO Latin 1'') set. All characters in an identifier are
 
68
meaningful. The current implementation places no limits on the number
 
69
of characters of an identifier.<BR>
 
70
<BR>
 
71
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
 
72
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
 
73
<TR><TD><B>Integer literals</B></TD>
 
74
</TR></TABLE></DIV></TD>
 
75
</TR></TABLE><BR>
 
76
<DIV ALIGN=center><TABLE CELLSPACING=2 CELLPADDING=0>
 
77
<TR><TD ALIGN=right NOWRAP>
 
78
<TT><I><FONT COLOR=maroon>integer-literal</FONT></I></TT></TD>
 
79
<TD ALIGN=right NOWRAP>::=</TD>
 
80
<TD ALIGN=left NOWRAP>
 
81
 [<TT><FONT COLOR=blue>-</FONT></TT>] { <TT><FONT COLOR=blue>0</FONT></TT>...<TT><FONT COLOR=blue>9</FONT></TT> }<SUP><FONT SIZE=2>+</FONT></SUP></TD>
 
82
</TR>
 
83
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
 
84
<TD ALIGN=right NOWRAP>|</TD>
 
85
<TD ALIGN=left NOWRAP> [<TT><FONT COLOR=blue>-</FONT></TT>] (<TT><FONT COLOR=blue>0x</FONT></TT>| <TT><FONT COLOR=blue>0X</FONT></TT>) { <TT><FONT COLOR=blue>0</FONT></TT>...<TT><FONT COLOR=blue>9</FONT></TT>| <TT><FONT COLOR=blue>A</FONT></TT>...<TT><FONT COLOR=blue>F</FONT></TT>| <TT><FONT COLOR=blue>a</FONT></TT>...<TT><FONT COLOR=blue>f</FONT></TT> }<SUP><FONT SIZE=2>+</FONT></SUP></TD>
 
86
</TR>
 
87
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
 
88
<TD ALIGN=right NOWRAP>|</TD>
 
89
<TD ALIGN=left NOWRAP> [<TT><FONT COLOR=blue>-</FONT></TT>] (<TT><FONT COLOR=blue>0o</FONT></TT>| <TT><FONT COLOR=blue>0O</FONT></TT>) { <TT><FONT COLOR=blue>0</FONT></TT>...<TT><FONT COLOR=blue>7</FONT></TT> }<SUP><FONT SIZE=2>+</FONT></SUP></TD>
 
90
</TR>
 
91
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
 
92
<TD ALIGN=right NOWRAP>|</TD>
 
93
<TD ALIGN=left NOWRAP> [<TT><FONT COLOR=blue>-</FONT></TT>] (<TT><FONT COLOR=blue>0b</FONT></TT>| <TT><FONT COLOR=blue>0B</FONT></TT>) { <TT><FONT COLOR=blue>0</FONT></TT>...<TT><FONT COLOR=blue>1</FONT></TT> }<SUP><FONT SIZE=2>+</FONT></SUP></TD>
 
94
</TR></TABLE></DIV><BR>
 
95
An integer literal is a sequence of one or more digits, optionally
 
96
preceded by a minus sign. By default, integer literals are in decimal
 
97
(radix 10). The following prefixes select a different radix:
 
98
<BR>
 
99
<DIV ALIGN=center><TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH="80%">
 
100
<TR><TD ALIGN=center NOWRAP><B>Prefix</B></TD>
 
101
<TD ALIGN=center NOWRAP><B>Radix</B></TD>
 
102
</TR>
 
103
<TR><TD ALIGN=left NOWRAP>
 
104
<TT>0x</TT>, <TT>0X</TT></TD>
 
105
<TD ALIGN=left NOWRAP>hexadecimal (radix 16)</TD>
 
106
</TR>
 
107
<TR><TD ALIGN=left NOWRAP><TT>0o</TT>, <TT>0O</TT></TD>
 
108
<TD ALIGN=left NOWRAP>octal (radix 8)</TD>
 
109
</TR>
 
110
<TR><TD ALIGN=left NOWRAP><TT>0b</TT>, <TT>0B</TT></TD>
 
111
<TD ALIGN=left NOWRAP>binary (radix 2)</TD>
 
112
</TR></TABLE></DIV><BR>
 
113
 
 
114
(The initial <TT>0</TT> is the digit zero; the <TT>O</TT> for octal is the letter O.)
 
115
The interpretation of integer literals that fall outside the range of
 
116
representable integer values is undefined.<BR>
 
117
<BR>
 
118
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
 
119
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
 
120
<TR><TD><B>Floating-point literals</B></TD>
 
121
</TR></TABLE></DIV></TD>
 
122
</TR></TABLE><BR>
 
123
<DIV ALIGN=center><TABLE CELLSPACING=2 CELLPADDING=0>
 
124
<TR><TD ALIGN=right NOWRAP>
 
125
<TT><I><FONT COLOR=maroon>float-literal</FONT></I></TT></TD>
 
126
<TD ALIGN=right NOWRAP>::=</TD>
 
127
<TD ALIGN=left NOWRAP>
 
128
 [<TT><FONT COLOR=blue>-</FONT></TT>] { <TT><FONT COLOR=blue>0</FONT></TT>...<TT><FONT COLOR=blue>9</FONT></TT> }<SUP><FONT SIZE=2>+</FONT></SUP> [<TT><FONT COLOR=blue>.</FONT></TT> { <TT><FONT COLOR=blue>0</FONT></TT>...<TT><FONT COLOR=blue>9</FONT></TT> }]
 
129
 [(<TT><FONT COLOR=blue>e</FONT></TT>| <TT><FONT COLOR=blue>E</FONT></TT>) [<TT><FONT COLOR=blue>+</FONT></TT>| <TT><FONT COLOR=blue>-</FONT></TT>] { <TT><FONT COLOR=blue>0</FONT></TT>...<TT><FONT COLOR=blue>9</FONT></TT> }<SUP><FONT SIZE=2>+</FONT></SUP>]</TD>
 
130
</TR></TABLE></DIV><BR>
 
131
Floating-point decimals consist in an integer part, a decimal part and
 
132
an exponent part. The integer part is a sequence of one or more
 
133
digits, optionally preceded by a minus sign. The decimal part is a
 
134
decimal point followed by zero, one or more digits.
 
135
The exponent part is the character <TT>e</TT> or <TT>E</TT> followed by an
 
136
optional <TT>+</TT> or <TT>-</TT> sign, followed by one or more digits.
 
137
The decimal part or the exponent part can be omitted, but not both to
 
138
avoid ambiguity with integer literals.
 
139
The interpretation of floating-point literals that fall outside the
 
140
range of representable floating-point values is undefined.<BR>
 
141
<BR>
 
142
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
 
143
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
 
144
<TR><TD><B>Character literals</B></TD>
 
145
</TR></TABLE></DIV></TD>
 
146
</TR></TABLE>
 
147
<A NAME="s:characterliteral"></A><BR>
 
148
<DIV ALIGN=center><TABLE CELLSPACING=2 CELLPADDING=0>
 
149
<TR><TD ALIGN=right NOWRAP>
 
150
<TT><I><FONT COLOR=maroon>char-literal</FONT></I></TT></TD>
 
151
<TD ALIGN=right NOWRAP>::=</TD>
 
152
<TD ALIGN=left NOWRAP>
 
153
 <TT><FONT COLOR=blue>'</FONT></TT> <TT><I><FONT COLOR=maroon>regular-char</FONT></I></TT> <TT><FONT COLOR=blue>'</FONT></TT></TD>
 
154
</TR>
 
155
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
 
156
<TD ALIGN=right NOWRAP>|</TD>
 
157
<TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>'</FONT></TT> <TT><FONT COLOR=blue>\</FONT></TT> (<TT><FONT COLOR=blue>\</FONT></TT> |  <TT><FONT COLOR=blue>'</FONT></TT> |  <TT><FONT COLOR=blue>n</FONT></TT> |  <TT><FONT COLOR=blue>t</FONT></TT> |  <TT><FONT COLOR=blue>b</FONT></TT> |  <TT><FONT COLOR=blue>r</FONT></TT>) <TT><FONT COLOR=blue>'</FONT></TT></TD>
 
158
</TR>
 
159
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
 
160
<TD ALIGN=right NOWRAP>|</TD>
 
161
<TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>'</FONT></TT> <TT><FONT COLOR=blue>\</FONT></TT> (<TT><FONT COLOR=blue>0</FONT></TT>...<TT><FONT COLOR=blue>9</FONT></TT>) (<TT><FONT COLOR=blue>0</FONT></TT>...<TT><FONT COLOR=blue>9</FONT></TT>) (<TT><FONT COLOR=blue>0</FONT></TT>...<TT><FONT COLOR=blue>9</FONT></TT>) <TT><FONT COLOR=blue>'</FONT></TT></TD>
 
162
</TR></TABLE></DIV><BR>
 
163
Character literals are delimited by <TT>'</TT> (single quote) characters.
 
164
The two single quotes enclose either one character different from
 
165
<TT>'</TT> and <TT>\</TT>, or one of the escape sequences below:
 
166
<BR>
 
167
<DIV ALIGN=center><TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH="80%">
 
168
<TR><TD ALIGN=center NOWRAP><B>Sequence</B></TD>
 
169
<TD ALIGN=center NOWRAP><B>Character denoted</B></TD>
 
170
</TR>
 
171
<TR><TD ALIGN=left NOWRAP>
 
172
<TT>\\</TT></TD>
 
173
<TD ALIGN=left NOWRAP>backslash (<TT>\</TT>)</TD>
 
174
</TR>
 
175
<TR><TD ALIGN=left NOWRAP><TT>\'</TT></TD>
 
176
<TD ALIGN=left NOWRAP>single quote (<TT>'</TT>)</TD>
 
177
</TR>
 
178
<TR><TD ALIGN=left NOWRAP><TT>\n</TT></TD>
 
179
<TD ALIGN=left NOWRAP>linefeed (LF)</TD>
 
180
</TR>
 
181
<TR><TD ALIGN=left NOWRAP><TT>\r</TT></TD>
 
182
<TD ALIGN=left NOWRAP>return (CR)</TD>
 
183
</TR>
 
184
<TR><TD ALIGN=left NOWRAP><TT>\t</TT></TD>
 
185
<TD ALIGN=left NOWRAP>horizontal tabulation (TAB)</TD>
 
186
</TR>
 
187
<TR><TD ALIGN=left NOWRAP><TT>\b</TT></TD>
 
188
<TD ALIGN=left NOWRAP>backspace (BS)</TD>
 
189
</TR>
 
190
<TR><TD ALIGN=left NOWRAP><TT>\</TT><I>ddd</I></TD>
 
191
<TD ALIGN=left NOWRAP>the character with ASCII code <I>ddd</I> in decimal</TD>
 
192
</TR></TABLE></DIV><BR>
 
193
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
 
194
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
 
195
<TR><TD><B>String literals</B></TD>
 
196
</TR></TABLE></DIV></TD>
 
197
</TR></TABLE>
 
198
<A NAME="s:stringliteral"></A><BR>
 
199
<DIV ALIGN=center><TABLE CELLSPACING=2 CELLPADDING=0>
 
200
<TR><TD ALIGN=right NOWRAP>
 
201
<TT><I><FONT COLOR=maroon>string-literal</FONT></I></TT></TD>
 
202
<TD ALIGN=right NOWRAP>::=</TD>
 
203
<TD ALIGN=left NOWRAP>
 
204
 <TT><FONT COLOR=blue>"</FONT></TT> { <TT><I><FONT COLOR=maroon>string-character</FONT></I></TT> } <TT><FONT COLOR=blue>"</FONT></TT></TD>
 
205
</TR>
 
206
<TR><TD ALIGN=right NOWRAP>
 
207
<TT><I><FONT COLOR=maroon>string-character</FONT></I></TT></TD>
 
208
<TD ALIGN=right NOWRAP>::=</TD>
 
209
<TD ALIGN=left NOWRAP>
 
210
 <TT><I><FONT COLOR=maroon>regular-char</FONT></I></TT></TD>
 
211
</TR>
 
212
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
 
213
<TD ALIGN=right NOWRAP>|</TD>
 
214
<TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>\</FONT></TT> (<TT><FONT COLOR=blue>\</FONT></TT> |  <TT><FONT COLOR=blue>"</FONT></TT> |  <TT><FONT COLOR=blue>n</FONT></TT> |  <TT><FONT COLOR=blue>t</FONT></TT> |  <TT><FONT COLOR=blue>b</FONT></TT> |  <TT><FONT COLOR=blue>r</FONT></TT>)</TD>
 
215
</TR>
 
216
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
 
217
<TD ALIGN=right NOWRAP>|</TD>
 
218
<TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>\</FONT></TT> (<TT><FONT COLOR=blue>0</FONT></TT>...<TT><FONT COLOR=blue>9</FONT></TT>) (<TT><FONT COLOR=blue>0</FONT></TT>...<TT><FONT COLOR=blue>9</FONT></TT>) (<TT><FONT COLOR=blue>0</FONT></TT>...<TT><FONT COLOR=blue>9</FONT></TT>)</TD>
 
219
</TR></TABLE></DIV><BR>
 
220
String literals are delimited by <TT>"</TT> (double quote) characters.
 
221
The two double quotes enclose a sequence of either characters
 
222
different from <TT>"</TT> and <TT>\</TT>, or escape sequences from the
 
223
table below:
 
224
<BR>
 
225
<DIV ALIGN=center><TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH="80%">
 
226
<TR><TD ALIGN=center NOWRAP><B>Sequence</B></TD>
 
227
<TD ALIGN=center NOWRAP><B>Character denoted</B></TD>
 
228
</TR>
 
229
<TR><TD ALIGN=left NOWRAP>
 
230
<TT>\\</TT></TD>
 
231
<TD ALIGN=left NOWRAP>backslash (<TT>\</TT>)</TD>
 
232
</TR>
 
233
<TR><TD ALIGN=left NOWRAP><TT>\"</TT></TD>
 
234
<TD ALIGN=left NOWRAP>double quote (<TT>"</TT>)</TD>
 
235
</TR>
 
236
<TR><TD ALIGN=left NOWRAP><TT>\n</TT></TD>
 
237
<TD ALIGN=left NOWRAP>linefeed (LF)</TD>
 
238
</TR>
 
239
<TR><TD ALIGN=left NOWRAP><TT>\r</TT></TD>
 
240
<TD ALIGN=left NOWRAP>return (CR)</TD>
 
241
</TR>
 
242
<TR><TD ALIGN=left NOWRAP><TT>\t</TT></TD>
 
243
<TD ALIGN=left NOWRAP>horizontal tabulation (TAB)</TD>
 
244
</TR>
 
245
<TR><TD ALIGN=left NOWRAP><TT>\b</TT></TD>
 
246
<TD ALIGN=left NOWRAP>backspace (BS)</TD>
 
247
</TR>
 
248
<TR><TD ALIGN=left NOWRAP><TT>\</TT><I>ddd</I></TD>
 
249
<TD ALIGN=left NOWRAP>the character with ASCII code <I>ddd</I> in decimal</TD>
 
250
</TR></TABLE></DIV><BR>
 
251
 
 
252
To allow splitting long string literals across lines, the sequence
 
253
<TT>\</TT><I>newline</I>&nbsp;<I>blanks</I> (a <TT>\</TT> at end-of-line followed by any
 
254
number of blanks at the beginning of the next line) is ignored inside
 
255
string literals.<BR>
 
256
<BR>
 
257
The current implementation places no restrictions on the length of
 
258
string literals.<BR>
 
259
<BR>
 
260
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
 
261
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
 
262
<TR><TD><B>Naming labels</B></TD>
 
263
</TR></TABLE></DIV></TD>
 
264
</TR></TABLE><BR>
 
265
To avoid ambiguities, naming labels cannot just be defined
 
266
syntactically as the sequence of the three tokens <TT>~</TT>, <TT><I><FONT COLOR=maroon>ident</FONT></I></TT> and
 
267
<TT>:</TT>, and have to be defined at the lexical level.<BR>
 
268
<DIV ALIGN=center><TABLE CELLSPACING=2 CELLPADDING=0>
 
269
<TR><TD ALIGN=right NOWRAP>
 
270
<TT><I><FONT COLOR=maroon>label</FONT></I></TT> </TD>
 
271
<TD ALIGN=right NOWRAP>::=</TD>
 
272
<TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>~</FONT></TT> (<TT><FONT COLOR=blue>a</FONT></TT> ... <TT><FONT COLOR=blue>z</FONT></TT>) { <TT><I><FONT COLOR=maroon>letter</FONT></I></TT>| <TT><FONT COLOR=blue>0</FONT></TT>...<TT><FONT COLOR=blue>9</FONT></TT>| <TT><FONT COLOR=blue>_</FONT></TT>| <TT><FONT COLOR=blue>'</FONT></TT> } <TT><FONT COLOR=blue>:</FONT></TT></TD>
 
273
</TR>
 
274
<TR><TD ALIGN=right NOWRAP>
 
275
<TT><I><FONT COLOR=maroon>optlabel</FONT></I></TT> </TD>
 
276
<TD ALIGN=right NOWRAP>::=</TD>
 
277
<TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>?</FONT></TT> (<TT><FONT COLOR=blue>a</FONT></TT> ... <TT><FONT COLOR=blue>z</FONT></TT>) { <TT><I><FONT COLOR=maroon>letter</FONT></I></TT>| <TT><FONT COLOR=blue>0</FONT></TT>...<TT><FONT COLOR=blue>9</FONT></TT>| <TT><FONT COLOR=blue>_</FONT></TT>| <TT><FONT COLOR=blue>'</FONT></TT> } <TT><FONT COLOR=blue>:</FONT></TT></TD>
 
278
</TR></TABLE></DIV><BR>
 
279
Naming labels come in two flavours: <TT><I><FONT COLOR=maroon>label</FONT></I></TT> for normal arguments and
 
280
<TT><I><FONT COLOR=maroon>optlabel</FONT></I></TT> for optional ones. They are simply distinguished by their
 
281
first character, either <TT>~</TT> or <TT>?</TT>.<BR>
 
282
<BR>
 
283
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
 
284
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
 
285
<TR><TD><B>Prefix and infix symbols</B></TD>
 
286
</TR></TABLE></DIV></TD>
 
287
</TR></TABLE><BR>
 
288
<DIV ALIGN=center><TABLE CELLSPACING=2 CELLPADDING=0>
 
289
<TR><TD ALIGN=right NOWRAP>
 
290
<TT><I><FONT COLOR=maroon>infix-symbol</FONT></I></TT></TD>
 
291
<TD ALIGN=right NOWRAP>::=</TD>
 
292
<TD ALIGN=left NOWRAP>
 
293
 (<TT><FONT COLOR=blue>=</FONT></TT> |  <TT><FONT COLOR=blue>&lt;</FONT></TT> |  <TT><FONT COLOR=blue>&gt;</FONT></TT> |  <TT><FONT COLOR=blue>@</FONT></TT> |  <TT><FONT COLOR=blue>^</FONT></TT> |  <TT><FONT COLOR=blue>|</FONT></TT> |  <TT><FONT COLOR=blue>&amp;</FONT></TT> | 
 
294
 <TT><FONT COLOR=blue>+</FONT></TT> |  <TT><FONT COLOR=blue>-</FONT></TT> |  <TT><FONT COLOR=blue>*</FONT></TT> |  <TT><FONT COLOR=blue>/</FONT></TT> |  <TT><FONT COLOR=blue>$</FONT></TT> |  <TT><FONT COLOR=blue>%</FONT></TT>) { <TT><I><FONT COLOR=maroon>operator-char</FONT></I></TT> }</TD>
 
295
</TR>
 
296
<TR><TD ALIGN=right NOWRAP>
 
297
<TT><I><FONT COLOR=maroon>prefix-symbol</FONT></I></TT></TD>
 
298
<TD ALIGN=right NOWRAP>::=</TD>
 
299
<TD ALIGN=left NOWRAP>
 
300
 (<TT><FONT COLOR=blue>!</FONT></TT> |  <TT><FONT COLOR=blue>?</FONT></TT> |  <TT><FONT COLOR=blue>~</FONT></TT>) { <TT><I><FONT COLOR=maroon>operator-char</FONT></I></TT> }</TD>
 
301
</TR>
 
302
<TR><TD ALIGN=right NOWRAP>
 
303
<TT><I><FONT COLOR=maroon>operator-char</FONT></I></TT></TD>
 
304
<TD ALIGN=right NOWRAP>::=</TD>
 
305
<TD ALIGN=left NOWRAP>
 
306
 <TT><FONT COLOR=blue>!</FONT></TT> |  <TT><FONT COLOR=blue>$</FONT></TT> |  <TT><FONT COLOR=blue>%</FONT></TT> |  <TT><FONT COLOR=blue>&amp;</FONT></TT> |  <TT><FONT COLOR=blue>*</FONT></TT> |  <TT><FONT COLOR=blue>+</FONT></TT> |  <TT><FONT COLOR=blue>-</FONT></TT> |  <TT><FONT COLOR=blue>.</FONT></TT> | 
 
307
 <TT><FONT COLOR=blue>/</FONT></TT> |  <TT><FONT COLOR=blue>:</FONT></TT> |  <TT><FONT COLOR=blue>&lt;</FONT></TT> |  <TT><FONT COLOR=blue>=</FONT></TT> |  <TT><FONT COLOR=blue>&gt;</FONT></TT> |  <TT><FONT COLOR=blue>?</FONT></TT> |  <TT><FONT COLOR=blue>@</FONT></TT> | 
 
308
 <TT><FONT COLOR=blue>^</FONT></TT> |  <TT><FONT COLOR=blue>|</FONT></TT> |  <TT><FONT COLOR=blue>~</FONT></TT></TD>
 
309
</TR></TABLE></DIV><BR>
 
310
Sequences of ``operator characters'', such as <TT>&lt;=&gt;</TT> or <TT>!!</TT>,
 
311
are read as a single token from the <TT><I><FONT COLOR=maroon>infix-symbol</FONT></I></TT> or <TT><I><FONT COLOR=maroon>prefix-symbol</FONT></I></TT>
 
312
class. These symbols are parsed as prefix and infix operators inside
 
313
expressions, but otherwise behave much as identifiers.
 
314
<BR>
 
315
<BR>
 
316
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
 
317
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
 
318
<TR><TD><B>Keywords</B></TD>
 
319
</TR></TABLE></DIV></TD>
 
320
</TR></TABLE><BR>
 
321
The identifiers below are reserved as keywords, and cannot be employed
 
322
otherwise:
 
323
<PRE>
 
324
      and         as          assert      asr         begin       class
 
325
      closed      constraint  do          done        downto      else
 
326
      end         exception   external    false       for         fun
 
327
      function    functor     if          in          include     inherit
 
328
      land        lazy        let         lor         lsl         lsr
 
329
      lxor        match       method      mod         module      mutable
 
330
      new         of          open        or          parser      private
 
331
      rec         sig         struct      then        to          true
 
332
      try         type        val         virtual     when        while
 
333
      with        
 
334
</PRE>The following character sequences are also keywords:
 
335
<PRE>
 
336
    #     &amp;     '     (     )     *     ,     -&gt;    ?
 
337
    ??    .     ..    .(    .[    :     ::    :=    ;
 
338
    ;;    &lt;-    =     [     [|    [&lt;    {&lt;    ]     |]
 
339
    &gt;]    &gt;}    _     `     {     |     }     ~
 
340
</PRE>
 
341
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
 
342
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
 
343
<TR><TD><B>Ambiguities</B></TD>
 
344
</TR></TABLE></DIV></TD>
 
345
</TR></TABLE><BR>
 
346
Lexical ambiguities are resolved according to the ``longest match''
 
347
rule: when a character sequence can be decomposed into two tokens in
 
348
several different ways, the decomposition retained is the one with the
 
349
longest first token.<BR>
 
350
<BR>
 
351
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
 
352
<TR><TD BGCOLOR="#98ff98"><DIV ALIGN=center><TABLE>
 
353
<TR><TD><B>Line number directives</B></TD>
 
354
</TR></TABLE></DIV></TD>
 
355
</TR></TABLE><BR>
 
356
<DIV ALIGN=center><TABLE CELLSPACING=2 CELLPADDING=0>
 
357
<TR><TD ALIGN=right NOWRAP>
 
358
<TT><I><FONT COLOR=maroon>linenum-directive</FONT></I></TT></TD>
 
359
<TD ALIGN=right NOWRAP>::=</TD>
 
360
<TD ALIGN=left NOWRAP>
 
361
 <TT><FONT COLOR=blue>#</FONT></TT> {<TT><FONT COLOR=blue>0</FONT></TT> ... <TT><FONT COLOR=blue>9</FONT></TT>}<SUP><FONT SIZE=2>+</FONT></SUP></TD>
 
362
</TR>
 
363
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD>
 
364
<TD ALIGN=right NOWRAP>|</TD>
 
365
<TD ALIGN=left NOWRAP> <TT><FONT COLOR=blue>#</FONT></TT> {<TT><FONT COLOR=blue>0</FONT></TT> ... <TT><FONT COLOR=blue>9</FONT></TT>}<SUP><FONT SIZE=2>+</FONT></SUP> <TT><FONT COLOR=blue>"</FONT></TT> { <TT><I><FONT COLOR=maroon>string-character</FONT></I></TT> } <TT><FONT COLOR=blue>"</FONT></TT></TD>
 
366
</TR></TABLE></DIV><BR>
 
367
Preprocessors that generate Caml source code can insert line number
 
368
directives in their output so that error messages produced by the
 
369
compiler contain line numbers and file names referring to the source
 
370
file before preprocessing, instead of after preprocessing.
 
371
A line number directive is composed of a <TT>#</TT> (sharp sign), followed by
 
372
a positive integer (the source line number), optionally followed by a
 
373
character string (the source file name).
 
374
Line number directives are treated as blank characters during lexical
 
375
analysis.
 
376
 
 
377
<BR>
 
378
<BR>
 
379
<HR>
 
380
<A HREF="manual008.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
 
381
<A HREF="manual010.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
 
382
</BODY>
 
383
</HTML>