a few more missing syntax rules; some rephrasing

git-svn-id: http://caml.inria.fr/svn/ocamldoc/trunk@13328 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Damien Doligez 2013-02-27 19:41:42 +00:00
parent df519248c9
commit e0494457eb
5 changed files with 26 additions and 28 deletions

View File

@ -31,7 +31,9 @@ class-body-type:
class-field-spec:
'inherit' class-body-type
| 'val' ['mutable'] ['virtual'] inst-var-name ':' typexpr
| 'val' 'virtual' 'mutable' inst-var-name ':' typexpr
| 'method' ['private'] ['virtual'] method-name ':' poly-typexpr
| 'method' 'virtual' 'private' method-name ':' poly-typexpr
| 'constraint' typexpr '=' typexpr
\end{syntax}
@ -180,9 +182,11 @@ class-field:
'inherit' class-expr ['as' value-name]
| 'val' ['mutable'] inst-var-name [':' typexpr] '=' expr
| 'val' ['mutable'] 'virtual' inst-var-name ':' typexpr
| 'val' 'virtual' 'mutable' inst-var-name ':' typexpr
| 'method' ['private'] method-name {parameter} [':' typexpr] '=' expr
| 'method' ['private'] method-name ':' poly-typexpr '=' expr
| 'method' ['private'] 'virtual' method-name ':' poly-typexpr
| 'method' 'virtual' 'private' method-name ':' poly-typexpr
| 'constraint' typexpr '=' typexpr
| 'initializer' expr
\end{syntax}
@ -381,10 +385,10 @@ been replaced by the values of the corresponding expressions @expr_1,
\ikwd{method\@\texttt{method}}
\ikwd{private\@\texttt{private}}
Method specification is written @'method' ['private'] 'virtual'
A method specification is written @'method' ['private'] 'virtual'
method-name ':' poly-typexpr@. It specifies whether the method is
public or private, and gives its type. If the method is intended to be
polymorphic, the type should be explicit.
polymorphic, the type must be explicitly polymorphic.
\subsubsection*{Constraints on type parameters}
@ -392,16 +396,16 @@ polymorphic, the type should be explicit.
The construct @'constraint' typexpr_1 '=' typexpr_2@ forces the two
type expressions to be equals. This is typically used to specify type
parameters: they can be that way be bound to a specified type
expression.
parameters: in that way they can be bound to specific type
expressions.
\subsubsection*{Initializers}
\ikwd{initializer\@\texttt{initializer}}
A class initializer @'initializer' expr@ specifies an expression that
will be evaluated when an object will be created from the class, once
all the instance variables have been initialized.
will be evaluated whenever an object is created from the class, once
all its instance variables have been initialized.
\subsection{Class definitions}
\label{s:classdef}

View File

@ -22,4 +22,4 @@ base types (integers, floating-point numbers, characters, character
strings), and constant constructors from both normal and polymorphic
variants, as well as the special constants @"false"@, @"true"@, @"("")"@,
@"[""]"@, and @"[|""|]"@, which behave like constant constructors, and
@"begin""end"@, which is equivalent to @'('')'@.
@"begin" "end"@, which is equivalent to @'('')'@.

View File

@ -60,7 +60,7 @@ expr:
| 'function' pattern-matching
| 'fun' multiple-matching
| 'try' expr 'with' pattern-matching
| 'let' ['rec'] let-binding { 'and' let-binding } 'in' expr
| 'let' ['rec'] let-binding { 'and' let-binding } 'in' expr
| 'new' class-path
| 'object' class-body 'end'
| expr '#' method-name

View File

@ -107,13 +107,6 @@ typeconstr:
field:
[ module-path '.' ] field-name
;
module-path:
{ module-name '.' } module-name
;
extended-module-path:
[ extended-module-path '.' ] module-name
| extended-module-path '(' extended-module-path ')'
;
modtype-path:
[ extended-module-path '.' ] modtype-name
;
@ -122,6 +115,15 @@ class-path:
;
classtype-path:
[ extended-module-path '.' ] class-name
;
module-path:
module-name { '.' module-name }
;
extended-module-path:
extended-module-name { '.' extended-module-name }
;
extended-module-name:
module-name { '(' extended-module-path ')' }
\end{syntax}
A named object can be referred to either by its name (following the
@ -130,9 +132,10 @@ where @prefix@ designates a module and @name@ is the name of an object
defined in that module. The first component of the path, @prefix@, is
either a simple module name or an access path @name_1 '.' name_2 \ldots@,
in case the defining module is itself nested inside other modules.
For referring to type constructors or module types, the @prefix@ can
For referring to type constructors, module types, or class types,
the @prefix@ can
also contain simple functor applications (as in the syntactic class
@extended-module-path@ above), in case the defining module is the
@extended-module-path@ above) in case the defining module is the
result of a functor application.
Label names, tag names, method names and instance variable names need

View File

@ -57,7 +57,7 @@ generalized when leaving
this scope. Anonymous variables have no such restriction.
In the following cases, the scope of named type variables is
restricted to the type expression where they appear: 1) for universal
(explicitly polymorphic) type variables; 2) for type variables that
(explicitly polymorphic) type variables; 2) for type variables that
only appear in public method specifications (as those variables will
be made universal, as described in section~\ref{sec-methspec});
3) for variables used as aliases, when the type they are aliased to
@ -131,18 +131,9 @@ polymorphic-variant-type:
| '[<' [ '|' ] tag-spec-full { '|' tag-spec-full } [ '>' {{ '`'tag-name }} ] ']'
;
%\end{syntax} \begin{syntax}
%tag-spec-list:
% [ '|' ] tag-spec {{ '|' tag-spec }}
% | [ '|' ] '`'tag-name [ 'of' typexpr ]
% | '|' typexpr
%;
%tag-spec-list:
% '`'tag-name [ 'of' typexpr ] { '|' tag-spec }
% | [typexpr] {{ '|' tag-spec }}
%;
tag-spec-first:
'`'tag-name [ 'of' typexpr ]
| [typexpr] '|' tag-spec
| [ typexpr ] '|' tag-spec
;
tag-spec:
'`'tag-name [ "of" typexpr ]