~ubuntu-branches/ubuntu/hardy/ocaml-doc/hardy

« back to all changes in this revision

Viewing changes to ocaml.html/lex.html

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2007-09-08 01:49:22 UTC
  • mfrom: (0.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070908014922-lvihyehz0ndq7suu
Tags: 3.10-1
* New upstream release.
* Removed camlp4 documentation since it is not up-to-date.
* Updated to standards version 3.7.2, no changes needed.
* Updated my email address.

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.09">
 
8
<LINK rel="stylesheet" type="text/css" href="manual.css">
 
9
<TITLE>Lexical conventions</TITLE>
 
10
</HEAD>
 
11
<BODY >
 
12
<A HREF="manual008.html"><IMG SRC="contents_motif.gif" ALT="Up"></A>
 
13
<A HREF="manual010.html"><IMG SRC="next_motif.gif" ALT="Next"></A>
 
14
<HR>
 
15
<H2 CLASS="section"><A NAME="htoc52">6.1</A>��Lexical conventions</H2><H4 CLASS="subsubsection">Blanks</H4><P>The following characters are considered as blanks: space, newline,
 
16
horizontal tabulation, carriage return, line feed and form feed. Blanks are
 
17
ignored, but they separate adjacent identifiers, literals and
 
18
keywords that would otherwise be confused as one single identifier,
 
19
literal or keyword.</P><H4 CLASS="subsubsection">Comments</H4><P>Comments are introduced by the two characters <TT>(*</TT>, with no
 
20
intervening blanks, and terminated by the characters <TT>*)</TT>, with
 
21
no intervening blanks. Comments are treated as blank characters.
 
22
Comments do not occur inside string or character literals. Nested
 
23
comments are handled correctly.</P><H4 CLASS="subsubsection">Identifiers</H4><TABLE CLASS="display dcenter"><TR VALIGN="middle"><TD CLASS="dcell"><TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP>
 
24
<I><A NAME="ident"><FONT COLOR=maroon>ident</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>�(<I><A HREF="#letter"><FONT COLOR=maroon>letter</FONT></A></I>&#X2223;�<FONT COLOR=blue><TT>_</TT></FONT>)�{�<I><A HREF="#letter"><FONT COLOR=maroon>letter</FONT></A></I>&#X2223;�<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>9</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>_</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>'</TT></FONT>�}��</TD></TR>
 
25
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD></TR>
 
26
<TR><TD ALIGN=right NOWRAP>
 
27
<I><A NAME="letter"><FONT COLOR=maroon>letter</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>A</TT></FONT>�&#X2026;�<FONT COLOR=blue><TT>Z</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>a</TT></FONT>�&#X2026;�<FONT COLOR=blue><TT>z</TT></FONT></TD></TR>
 
28
</TABLE></TD></TR>
 
29
</TABLE><P>Identifiers are sequences of letters, digits, <TT>_</TT> (the underscore
 
30
character), and <TT>'</TT> (the single quote), starting with a
 
31
letter or an underscore.
 
32
Letters contain at least the 52 lowercase and uppercase
 
33
letters from the ASCII set. The current implementation
 
34
also recognizes as letters all accented characters from the ISO
 
35
8859-1 (&#X201C;ISO Latin 1&#X201D;) set. All characters in an identifier are
 
36
meaningful. The current implementation accepts identifiers up to
 
37
16000000 characters in length.</P><H4 CLASS="subsubsection">Integer literals</H4><TABLE CLASS="display dcenter"><TR VALIGN="middle"><TD CLASS="dcell"><TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP>
 
38
<I><A NAME="integer-literal"><FONT COLOR=maroon>integer-literal</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
 
39
[<FONT COLOR=blue><TT>-</TT></FONT>]�(<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>9</TT></FONT>)�{�<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>9</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>_</TT></FONT>�}
 
40
�</TD></TR>
 
41
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</TD><TD ALIGN=left NOWRAP>�[<FONT COLOR=blue><TT>-</TT></FONT>]�(<FONT COLOR=blue><TT>0x</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>0X</TT></FONT>)�(<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>9</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>A</TT></FONT>&#X2026;<FONT COLOR=blue><TT>F</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>a</TT></FONT>&#X2026;<FONT COLOR=blue><TT>f</TT></FONT>)
 
42
{�<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>9</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>A</TT></FONT>&#X2026;<FONT COLOR=blue><TT>F</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>a</TT></FONT>&#X2026;<FONT COLOR=blue><TT>f</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>_</TT></FONT>�}
 
43
�</TD></TR>
 
44
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</TD><TD ALIGN=left NOWRAP>�[<FONT COLOR=blue><TT>-</TT></FONT>]�(<FONT COLOR=blue><TT>0o</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>0O</TT></FONT>)�(<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>7</TT></FONT>)�{�<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>7</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>_</TT></FONT>�}
 
45
�</TD></TR>
 
46
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</TD><TD ALIGN=left NOWRAP>�[<FONT COLOR=blue><TT>-</TT></FONT>]�(<FONT COLOR=blue><TT>0b</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>0B</TT></FONT>)�(<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>1</TT></FONT>)�{�<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>1</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>_</TT></FONT>�}</TD></TR>
 
47
</TABLE></TD></TR>
 
48
</TABLE><P>An integer literal is a sequence of one or more digits, optionally
 
49
preceded by a minus sign. By default, integer literals are in decimal
 
50
(radix 10). The following prefixes select a different radix:
 
51
</P><DIV CLASS="center"><TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH="80%"><TR><TD ALIGN=center NOWRAP><B>Prefix</B></TD><TD ALIGN=center NOWRAP><B>Radix</B></TD></TR>
 
52
<TR><TD ALIGN=left NOWRAP>
 
53
<TT>0x</TT>, <TT>0X</TT></TD><TD ALIGN=left NOWRAP>hexadecimal (radix 16)</TD></TR>
 
54
<TR><TD ALIGN=left NOWRAP><TT>0o</TT>, <TT>0O</TT></TD><TD ALIGN=left NOWRAP>octal (radix 8)</TD></TR>
 
55
<TR><TD ALIGN=left NOWRAP><TT>0b</TT>, <TT>0B</TT></TD><TD ALIGN=left NOWRAP>binary (radix 2)</TD></TR>
 
56
</TABLE></DIV><P>
 
57
(The initial <TT>0</TT> is the digit zero; the <TT>O</TT> for octal is the letter O.)
 
58
The interpretation of integer literals that fall outside the range of
 
59
representable integer values is undefined.</P><P>For convenience and readability, underscore characters (<TT>_</TT>) are accepted
 
60
(and ignored) within integer literals.</P><H4 CLASS="subsubsection">Floating-point literals</H4><TABLE CLASS="display dcenter"><TR VALIGN="middle"><TD CLASS="dcell"><TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP>
 
61
<I><A NAME="float-literal"><FONT COLOR=maroon>float-literal</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
 
62
[<FONT COLOR=blue><TT>-</TT></FONT>]�(<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>9</TT></FONT>)�{�<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>9</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>_</TT></FONT>�}�[<FONT COLOR=blue><TT>.</TT></FONT>�{�<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>9</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>_</TT></FONT>�}]
 
63
[(<FONT COLOR=blue><TT>e</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>E</TT></FONT>)�[<FONT COLOR=blue><TT>+</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>-</TT></FONT>]�(<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>9</TT></FONT>)�{�<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>9</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>_</TT></FONT>�}]</TD></TR>
 
64
</TABLE></TD></TR>
 
65
</TABLE><P>Floating-point decimals consist in an integer part, a decimal part and
 
66
an exponent part. The integer part is a sequence of one or more
 
67
digits, optionally preceded by a minus sign. The decimal part is a
 
68
decimal point followed by zero, one or more digits.
 
69
The exponent part is the character <TT>e</TT> or <TT>E</TT> followed by an
 
70
optional <TT>+</TT> or <TT>-</TT> sign, followed by one or more digits.
 
71
The decimal part or the exponent part can be omitted, but not both to
 
72
avoid ambiguity with integer literals.
 
73
The interpretation of floating-point literals that fall outside the
 
74
range of representable floating-point values is undefined.</P><P>For convenience and readability, underscore characters (<TT>_</TT>) are accepted
 
75
(and ignored) within floating-point literals.</P><H4 CLASS="subsubsection">Character literals</H4><P>
 
76
<A NAME="s:characterliteral"></A></P><TABLE CLASS="display dcenter"><TR VALIGN="middle"><TD CLASS="dcell"><TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP>
 
77
<I><A NAME="char-literal"><FONT COLOR=maroon>char-literal</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
 
78
<FONT COLOR=blue><TT>'</TT></FONT>�<FONT COLOR=maroon><I>regular-char</I></FONT>�<FONT COLOR=blue><TT>'</TT></FONT>
 
79
�</TD></TR>
 
80
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>'</TT></FONT>�<I><A HREF="#escape-sequence"><FONT COLOR=maroon>escape-sequence</FONT></A></I>�<FONT COLOR=blue><TT>'</TT></FONT>
 
81
�</TD></TR>
 
82
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD></TR>
 
83
<TR><TD ALIGN=right NOWRAP>
 
84
<I><A NAME="escape-sequence"><FONT COLOR=maroon>escape-sequence</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
 
85
<FONT COLOR=blue><TT>\</TT></FONT>�(<FONT COLOR=blue><TT>\</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>"</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>'</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>n</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>t</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>b</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>r</TT></FONT>)
 
86
�</TD></TR>
 
87
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>\</TT></FONT>�(<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>9</TT></FONT>)�(<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>9</TT></FONT>)�(<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>9</TT></FONT>)
 
88
�</TD></TR>
 
89
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>\x</TT></FONT>�(<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>9</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>A</TT></FONT>&#X2026;<FONT COLOR=blue><TT>F</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>a</TT></FONT>&#X2026;<FONT COLOR=blue><TT>f</TT></FONT>)
 
90
(<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>9</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>A</TT></FONT>&#X2026;<FONT COLOR=blue><TT>F</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>a</TT></FONT>&#X2026;<FONT COLOR=blue><TT>f</TT></FONT>)</TD></TR>
 
91
</TABLE></TD></TR>
 
92
</TABLE><P>Character literals are delimited by <TT>'</TT> (single quote) characters.
 
93
The two single quotes enclose either one character different from
 
94
<TT>'</TT> and <TT>\</TT>, or one of the escape sequences below:
 
95
</P><DIV CLASS="center"><TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH="80%"><TR><TD ALIGN=center NOWRAP><B>Sequence</B></TD><TD ALIGN=center NOWRAP><B>Character denoted</B></TD></TR>
 
96
<TR><TD ALIGN=left NOWRAP>
 
97
<TT>\\</TT></TD><TD ALIGN=left NOWRAP>backslash (<TT>\</TT>)</TD></TR>
 
98
<TR><TD ALIGN=left NOWRAP><TT>\"</TT></TD><TD ALIGN=left NOWRAP>double quote (<TT>"</TT>)</TD></TR>
 
99
<TR><TD ALIGN=left NOWRAP><TT>\'</TT></TD><TD ALIGN=left NOWRAP>single quote (<TT>'</TT>)</TD></TR>
 
100
<TR><TD ALIGN=left NOWRAP><TT>\n</TT></TD><TD ALIGN=left NOWRAP>linefeed (LF)</TD></TR>
 
101
<TR><TD ALIGN=left NOWRAP><TT>\r</TT></TD><TD ALIGN=left NOWRAP>carriage return (CR)</TD></TR>
 
102
<TR><TD ALIGN=left NOWRAP><TT>\t</TT></TD><TD ALIGN=left NOWRAP>horizontal tabulation (TAB)</TD></TR>
 
103
<TR><TD ALIGN=left NOWRAP><TT>\b</TT></TD><TD ALIGN=left NOWRAP>backspace (BS)</TD></TR>
 
104
<TR><TD ALIGN=left NOWRAP><TT>\</TT><I>space</I></TD><TD ALIGN=left NOWRAP>space (SPC)</TD></TR>
 
105
<TR><TD ALIGN=left NOWRAP><TT>\</TT><I>ddd</I></TD><TD ALIGN=left NOWRAP>the character with ASCII code <I>ddd</I> in decimal</TD></TR>
 
106
<TR><TD ALIGN=left NOWRAP><TT>\x</TT><I>hh</I></TD><TD ALIGN=left NOWRAP>the character with ASCII code <I>hh</I> in hexadecimal</TD></TR>
 
107
</TABLE></DIV><H4 CLASS="subsubsection">String literals</H4><P>
 
108
<A NAME="s:stringliteral"></A></P><TABLE CLASS="display dcenter"><TR VALIGN="middle"><TD CLASS="dcell"><TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP>
 
109
<I><A NAME="string-literal"><FONT COLOR=maroon>string-literal</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
 
110
<FONT COLOR=blue><TT>"</TT></FONT>�{�<I><A HREF="#string-character"><FONT COLOR=maroon>string-character</FONT></A></I>�}�<FONT COLOR=blue><TT>"</TT></FONT>
 
111
�</TD></TR>
 
112
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD></TR>
 
113
<TR><TD ALIGN=right NOWRAP>
 
114
<I><A NAME="string-character"><FONT COLOR=maroon>string-character</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
 
115
<FONT COLOR=maroon><I>regular-char-str</I></FONT>
 
116
�</TD></TR>
 
117
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</TD><TD ALIGN=left NOWRAP>�<I><A HREF="#escape-sequence"><FONT COLOR=maroon>escape-sequence</FONT></A></I></TD></TR>
 
118
</TABLE></TD></TR>
 
119
</TABLE><P>String literals are delimited by <TT>"</TT> (double quote) characters.
 
120
The two double quotes enclose a sequence of either characters
 
121
different from <TT>"</TT> and <TT>\</TT>, or escape sequences from the
 
122
table given above for character literals.</P><P>To allow splitting long string literals across lines, the sequence
 
123
<TT>\</TT><I>newline</I>�<I>blanks</I> (a <TT>\</TT> at end-of-line followed by any
 
124
number of blanks at the beginning of the next line) is ignored inside
 
125
string literals.</P><P>The current implementation places practically no restrictions on the
 
126
length of string literals.</P><H4 CLASS="subsubsection">Naming labels</H4><P>To avoid ambiguities, naming labels cannot just be defined
 
127
syntactically as the sequence of the three tokens <TT>~</TT>, <I><A HREF="#ident"><FONT COLOR=maroon>ident</FONT></A></I> and
 
128
<TT>:</TT>, and have to be defined at the lexical level.</P><TABLE CLASS="display dcenter"><TR VALIGN="middle"><TD CLASS="dcell"><TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP>
 
129
<I><A NAME="label"><FONT COLOR=maroon>label</FONT></A></I>�</TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>~</TT></FONT>�(<FONT COLOR=blue><TT>a</TT></FONT>�&#X2026;�<FONT COLOR=blue><TT>z</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>_</TT></FONT>)�{�<I><A HREF="#letter"><FONT COLOR=maroon>letter</FONT></A></I>&#X2223;�<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>9</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>_</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>'</TT></FONT>�}�<FONT COLOR=blue><TT>:</TT></FONT>��</TD></TR>
 
130
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD></TR>
 
131
<TR><TD ALIGN=right NOWRAP>
 
132
<I><A NAME="optlabel"><FONT COLOR=maroon>optlabel</FONT></A></I>�</TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>?</TT></FONT>�(<FONT COLOR=blue><TT>a</TT></FONT>�&#X2026;�<FONT COLOR=blue><TT>z</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>_</TT></FONT>)�{�<I><A HREF="#letter"><FONT COLOR=maroon>letter</FONT></A></I>&#X2223;�<FONT COLOR=blue><TT>0</TT></FONT>&#X2026;<FONT COLOR=blue><TT>9</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>_</TT></FONT>&#X2223;�<FONT COLOR=blue><TT>'</TT></FONT>�}�<FONT COLOR=blue><TT>:</TT></FONT></TD></TR>
 
133
</TABLE></TD></TR>
 
134
</TABLE><P>Naming labels come in two flavours: <I><A HREF="#label"><FONT COLOR=maroon>label</FONT></A></I> for normal arguments and
 
135
<I><A HREF="#optlabel"><FONT COLOR=maroon>optlabel</FONT></A></I> for optional ones. They are simply distinguished by their
 
136
first character, either <TT>~</TT> or <TT>?</TT>.</P><H4 CLASS="subsubsection">Prefix and infix symbols</H4><TABLE CLASS="display dcenter"><TR VALIGN="middle"><TD CLASS="dcell"><TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP>
 
137
<I><A NAME="infix-symbol"><FONT COLOR=maroon>infix-symbol</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
 
138
(<FONT COLOR=blue><TT>=</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>&lt;</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>&gt;</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>@</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>^</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>|</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>&amp;</TT></FONT>�&#X2223;�
 
139
<FONT COLOR=blue><TT>+</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>-</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>*</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>/</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>$</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>%</TT></FONT>)�{�<I><A HREF="#operator-char"><FONT COLOR=maroon>operator-char</FONT></A></I>�}
 
140
�</TD></TR>
 
141
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD></TR>
 
142
<TR><TD ALIGN=right NOWRAP>
 
143
<I><A NAME="prefix-symbol"><FONT COLOR=maroon>prefix-symbol</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
 
144
(<FONT COLOR=blue><TT>!</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>?</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>~</TT></FONT>)�{�<I><A HREF="#operator-char"><FONT COLOR=maroon>operator-char</FONT></A></I>�}
 
145
�</TD></TR>
 
146
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD></TR>
 
147
<TR><TD ALIGN=right NOWRAP>
 
148
<I><A NAME="operator-char"><FONT COLOR=maroon>operator-char</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
 
149
<FONT COLOR=blue><TT>!</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>$</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>%</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>&amp;</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>*</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>+</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>-</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>.</TT></FONT>�&#X2223;�
 
150
<FONT COLOR=blue><TT>/</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>:</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>&lt;</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>=</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>&gt;</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>?</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>@</TT></FONT>�&#X2223;�
 
151
<FONT COLOR=blue><TT>^</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>|</TT></FONT>�&#X2223;��<FONT COLOR=blue><TT>~</TT></FONT>
 
152
�</TD></TR>
 
153
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD></TR>
 
154
</TABLE></TD></TR>
 
155
</TABLE><P>Sequences of &#X201C;operator characters&#X201D;, such as <TT>&lt;=&gt;</TT> or <TT>!!</TT>,
 
156
are read as a single token from the <I><A HREF="#infix-symbol"><FONT COLOR=maroon>infix-symbol</FONT></A></I> or <I><A HREF="#prefix-symbol"><FONT COLOR=maroon>prefix-symbol</FONT></A></I>
 
157
class. These symbols are parsed as prefix and infix operators inside
 
158
expressions, but otherwise behave much as identifiers.
 
159
</P><H4 CLASS="subsubsection">Keywords</H4><P>The identifiers below are reserved as keywords, and cannot be employed
 
160
otherwise:
 
161
</P><PRE CLASS="verbatim">      and         as          assert      asr         begin       class
 
162
      constraint  do          done        downto      else        end
 
163
      exception   external    false       for         fun         function
 
164
      functor     if          in          include     inherit     initializer
 
165
      land        lazy        let         lor         lsl         lsr
 
166
      lxor        match       method      mod         module      mutable
 
167
      new         object      of          open        or          private
 
168
      rec         sig         struct      then        to          true
 
169
      try         type        val         virtual     when        while
 
170
      with        
 
171
</PRE><P>The following character sequences are also keywords:
 
172
</P><PRE CLASS="verbatim">    !=    #     &amp;     &amp;&amp;    '     (     )     *     +     ,     -
 
173
    -.    -&gt;    .     ..    :     ::    :=    :&gt;    ;     ;;    &lt;
 
174
    &lt;-    =     &gt;     &gt;]    &gt;}    ?     ??    [     [&lt;    [&gt;    [|
 
175
    ]     _     `     {     {&lt;    |     |]    }     ~
 
176
</PRE><P>Note that the following identifiers are keywords of the Camlp4
 
177
extensions and should be avoided for compatibility reasons.
 
178
</P><PRE CLASS="verbatim">    parser    &lt;&lt;    &lt;:    &gt;&gt;    $     $$    $:
 
179
</PRE><H4 CLASS="subsubsection">Ambiguities</H4><P>Lexical ambiguities are resolved according to the &#X201C;longest match&#X201D;
 
180
rule: when a character sequence can be decomposed into two tokens in
 
181
several different ways, the decomposition retained is the one with the
 
182
longest first token.</P><H4 CLASS="subsubsection">Line number directives</H4><TABLE CLASS="display dcenter"><TR VALIGN="middle"><TD CLASS="dcell"><TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP>
 
183
<I><A NAME="linenum-directive"><FONT COLOR=maroon>linenum-directive</FONT></A></I></TD><TD ALIGN=center NOWRAP>::=</TD><TD ALIGN=left NOWRAP>
 
184
<FONT COLOR=blue><TT>#</TT></FONT>�{<FONT COLOR=blue><TT>0</TT></FONT>�&#X2026;�<FONT COLOR=blue><TT>9</TT></FONT>}<SUP>+</SUP>
 
185
�</TD></TR>
 
186
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD><TD ALIGN=center NOWRAP>&#X2223;</TD><TD ALIGN=left NOWRAP>�<FONT COLOR=blue><TT>#</TT></FONT>�{<FONT COLOR=blue><TT>0</TT></FONT>�&#X2026;�<FONT COLOR=blue><TT>9</TT></FONT>}<SUP>+</SUP>�<FONT COLOR=blue><TT>"</TT></FONT>�{�<I><A HREF="#string-character"><FONT COLOR=maroon>string-character</FONT></A></I>�}�<FONT COLOR=blue><TT>"</TT></FONT>
 
187
�</TD></TR>
 
188
<TR><TD ALIGN=right NOWRAP>&nbsp;</TD></TR>
 
189
</TABLE></TD></TR>
 
190
</TABLE><P>Preprocessors that generate Caml source code can insert line number
 
191
directives in their output so that error messages produced by the
 
192
compiler contain line numbers and file names referring to the source
 
193
file before preprocessing, instead of after preprocessing.
 
194
A line number directive is composed of a <TT>#</TT> (sharp sign), followed by
 
195
a positive integer (the source line number), optionally followed by a
 
196
character string (the source file name).
 
197
Line number directives are treated as blank characters during lexical
 
198
analysis.</P><HR>
 
199
<A HREF="manual008.html"><IMG SRC="contents_motif.gif" ALT="Up"></A>
 
200
<A HREF="manual010.html"><IMG SRC="next_motif.gif" ALT="Next"></A>
 
201
</BODY>
 
202
</HTML>