tiger language manual: misc: wrapping, styling

* source/reference_manual/tiger_language_reference_manual/lexical_specifications/lexical_specifications.rst,
* source/reference_manual/tiger_language_reference_manual/semantics/declarations/declarations.rst,
* source/reference_manual/tiger_language_reference_manual/semantics/declarations/declarations/import,
* source/reference_manual/tiger_language_reference_manual/semantics/declarations/function_declarations/function_declarations.rst,
* source/reference_manual/tiger_language_reference_manual/semantics/declarations/method_declarations/method_declarations.rst,
* source/reference_manual/tiger_language_reference_manual/semantics/declarations/type_declarations/classes3,
* source/reference_manual/tiger_language_reference_manual/semantics/declarations/type_declarations/type_declarations.rst,
* source/reference_manual/tiger_language_reference_manual/semantics/declarations/variable_declarations/variable_declarations.rst,
* source/reference_manual/tiger_language_reference_manual/semantics/expressions/expressions.rst: Here.
parent 0a2fc082
Pipeline #18122 passed with stage
in 1 minute and 22 seconds
...@@ -35,7 +35,7 @@ Strings ...@@ -35,7 +35,7 @@ Strings
following escapes: following escapes:
``\a``, ``\b``, ``\f``, ``\n``, ``\r``, ``\t``, ``\v`` ``\a``, ``\b``, ``\f``, ``\n``, ``\r``, ``\t``, ``\v``
control characters. Control characters.
``\num`` ``\num``
The character which code is ``num`` in octal. Valid character codes belong The character which code is ``num`` in octal. Valid character codes belong
......
...@@ -4,13 +4,15 @@ Declarations ...@@ -4,13 +4,15 @@ Declarations
------------ ------------
import :code:`import`
An import clause denote the same expression where it was (recursively) An :code:`import` clause denote the same expression where it was
replaced by the set of declarations its corresponding import-file contains. (recursively) replaced by the set of declarations its corresponding
import-file contains.
An import-file has the following syntax An import-file has the following syntax
(see :ref:`Syntactic Specifications` for the definition of the symbols): (see :ref:`Syntactic Specifications` for the definition of the symbols):
.. literalinclude:: declarations/import .. literalinclude:: declarations/import
:language: ebnf
Because the syntax is different, it is convenient to use another extension. Because the syntax is different, it is convenient to use another extension.
We use ``*.tih`` for files to import, for instance: We use ``*.tih`` for files to import, for instance:
...@@ -45,7 +47,7 @@ import ...@@ -45,7 +47,7 @@ import
in the current directory, then in all the directories of the include path, in the current directory, then in all the directories of the include path,
in order. in order.
name spaces Name spaces
There are three name spaces: types, variables and functions. The original There are three name spaces: types, variables and functions. The original
language definition features two: variables and functions share the same language definition features two: variables and functions share the same
name space. The motivation, as noted by Sébastien Carlier, is that in name space. The motivation, as noted by Sébastien Carlier, is that in
......
...@@ -4,7 +4,7 @@ Function Declarations ...@@ -4,7 +4,7 @@ Function Declarations
===================== =====================
functions Functions
To declare a function, provide its return value type: To declare a function, provide its return value type:
.. literalinclude:: function.tig .. literalinclude:: function.tig
...@@ -15,24 +15,24 @@ functions ...@@ -15,24 +15,24 @@ functions
.. literalinclude:: procedure.tig .. literalinclude:: procedure.tig
:language: tiger :language: tiger
Functions can be recursive, but mutually recursive functions must be in the Functions can be recursive, but mutually recursive functions must be
same sequence of function declarations (no other declaration should be in the same sequence of function declarations (no other declaration
placed between them). should be placed between them).
See the semantics of function calls for the argument passing policy See the semantics of function calls for the argument passing policy
(see :ref:`Expressions`). (see :ref:`Expressions`).
primitive Primitives
A primitive is a built-in function, i.e. a function which body is provided A primitive is a built-in function, i.e. a function which body is
by the runtime system. provided by the runtime system.
See :ref:`Predefined Functions` for the list of standard primitives. See :ref:`Predefined Functions` for the list of standard primitives.
Aside from the lack of body, and henceforth the absence of translation, Aside from the lack of body, and henceforth the absence of translation,
primitive declarations behave as function declarations. They share the same primitive declarations behave as function declarations. They share the
name space, and obey the same duplicate-name rule. For instance: same name space, and obey the same duplicate-name rule. For instance:
.. literalinclude:: primitive.tig .. literalinclude:: primitive.tig
:language: tiger :language: tiger
is invalid, and must be rejected with exit status set to 4. is invalid and must be rejected with the exit status set to 4.
...@@ -5,28 +5,29 @@ Method Declarations ...@@ -5,28 +5,29 @@ Method Declarations
Overriding methods Overriding methods
When a method in a class overrides a method of a super class, the overridden When a method in a class overrides a method of a super class, the
method (in the super class) is no longer accessible. Dynamic dispatch is overridden method in the super class is no longer accessible.
performed, using the exact type of the object (known at run time) to select Dynamic dispatch is performed, using the exact type of the object
the method according to this exact type. (known at runtime) to select the method according to this exact type.
However, the interface of the accessible attributes and callable methods However, the interface of the accessible attributes and callable
remains restricted to the static interface methods remains restricted to the static interface (i.e. the one
(i.e. the one of the static type of the object). of the static type of the object).
.. literalinclude:: overriding.tig .. literalinclude:: overriding.tig
:language: tiger :language: tiger
Method invariance Method invariance
Methods are invariant in Tiger: each redefinition of a method in a subclass Methods are invariant in Tiger: each redefinition of a method in
shall have the exact same signature as the original (overridden) method. a subclass shall have the exact same signature as the original
overridden method.
This invariance applies to: This invariance applies to:
1. the number of arguments. 1. the number of arguments.
2. the types of the arguments. 2. the types of the arguments.
3. the type of the return value (2). 3. the type of the return value [#]_.
.. literalinclude:: invariance.tig .. literalinclude:: invariance.tig
:language: tiger :language: tiger
*(2) Which is not the case in C++, where methods have covariant return values.* .. [#] Which is not the case in C++, where methods have covariant return values.
class Name [ extends Super ] { Classfields } class name [ extends super ] { classfields }
=> type Name = class [ extends Super ] { Classfields } => type name = class [ extends super ] { classfields }
...@@ -4,19 +4,19 @@ Variable Declarations ...@@ -4,19 +4,19 @@ Variable Declarations
===================== =====================
variables Variables
There are two forms of variable declarations in Tiger: There are two forms of variable declarations in Tiger:
the short one and the long one. the short one and the long one.
In the short form, only the name of the variable and the initial value of In the short form, only the name of the variable and the initial
the variable are specified, the variable type is “inferred”. value of the variable are specified, the variable type is *inferred*.
.. literalinclude:: variables.tig .. literalinclude:: variables.tig
:language: tiger :language: tiger
In the long form, the type of the variable is specified. In the long form, the type of the variable is specified.
Since one cannot infer a record type for nil, the long form is mandated Since one cannot infer a record type for :code:`nil`, the long form
when declaring a variable initialized to nil. is mandated when declaring a variable initialized to :code:`nil`.
.. literalinclude:: variables2.tig .. literalinclude:: variables2.tig
:language: tiger :language: tiger
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment