Contents   Index   Search   Previous   Next

1.1.4 Method of Description and Syntax Notation

   The form of an Ada program is described by means of a context-free syntax together with context-dependent requirements expressed by narrative rules.
   The meaning of Ada programs is described by means of narrative rules defining both the effects of each construct and the composition rules for constructs.
   {syntax (notation)} {grammar (notation)} {context free grammar (notation)} {BNF (Backus-Naur Form) (notation)} {Backus-Naur Form (BNF) (notation)} The context-free syntax of the language is described using a simple variant of Backus-Naur Form. In particular:
return_statement ::= return [expression];
return_statement ::= return; | return expression;
term ::= factor {multiplying_operator factor}
term ::= factor | term multiplying_operator factor
constraint ::= scalar_constraint | composite_constraint
discrete_choice_list ::= discrete_choice {| discrete_choice}
Discussion: {LR(1)} {ambiguous grammar} {grammar (resolution of ambiguity)} {grammar (ambiguous)} The grammar given in the RM95 is not LR(1). In fact, it is ambiguous; the ambiguities are resolved by the overload resolution rules (see 8.6).
We often use ``if'' to mean ``if and only if'' in definitions. For example, if we define ``photogenic'' by saying, ``A type is photogenic if it has the following properties...,'' we mean that a type is photogenic if and only if it has those properties. It is usually clear from the context, and adding the ``and only if'' seems too cumbersome.
When we say, for example, ``a declarative_item of a declarative_part'', we are talking about a declarative_item immediately within that declarative_part. When we say ``a declarative_item in, or within, a declarative_part'', we are talking about a declarative_item anywhere in the declarative_part, possibly deeply nested within other declarative_parts. (This notation doesn't work very well for names, since the name ``of'' something also has another meaning.)
When we refer to the name of a language-defined entity (for example, Duration), we mean the language-defined entity even in programs where the declaration of the language-defined entity is hidden by another declaration. For example, when we say that the expected type for the expression of a delay_relative_statement is Duration, we mean the language-defined type Duration that is declared in Standard, not some type Duration the user might have declared.
    {syntactic category} A syntactic category is a nonterminal in the grammar defined in BNF under ``Syntax.'' Names of syntactic categories are set in a different font, like_this.
    {Construct} [Glossary Entry]A construct is a piece of text (explicit or implicit) that is an instance of a syntactic category defined under ``Syntax.''
Ramification: For example, an expression is a construct. A declaration is a construct, whereas the thing declared by a declaration is an ``entity.''
Discussion: ``Explicit'' and ``implicit'' don't mean exactly what you might think they mean: The text of an instance of a generic is considered explicit, even though it does not appear explicitly (in the non-technical sense) in the program text, and even though its meaning is not defined entirely in terms of that text.
    {constituent (of a construct)} A constituent of a construct is the construct itself, or any construct appearing within it.
    {arbitrary order} Whenever the run-time semantics defines certain actions to happen in an arbitrary order, this means that the implementation shall arrange for these actions to occur in a way that is equivalent to some sequential order, following the rules that result from that sequential order. When evaluations are defined to happen in an arbitrary order, with conversion of the results to some subtypes, or with some run-time checks, the evaluations, conversions, and checks may be arbitrarily interspersed, so long as each expression is evaluated before converting or checking its value. {type conversion (arbitrary order) [partial]} {conversion (arbitrary order) [partial]} [Note that the effect of a program can depend on the order chosen by the implementation. This can happen, for example, if two actual parameters of a given call have side effects.]
Discussion: Programs will be more portable if their external effect does not depend on the particular order chosen by an implementation.
Ramification: Additional reordering permissions are given in 11.6, ``Exceptions and Optimization''.
There is no requirement that the implementation always choose the same order in a given kind of situation. In fact, the implementation is allowed to choose a different order for two different executions of the same construct. However, we expect most implementations will behave in a relatively predictable manner in most situations.
Reason: The ``sequential order'' wording is intended to allow the programmer to rely on ``benign'' side effects. For example, if F is a function that returns a unique integer by incrementing some global and returning the result, a call such as P(F, F) is OK if the programmer cares only that the two results of F are unique; the two calls of F cannot be executed in parallel, unless the compiler can prove that parallel execution is equivalent to some sequential order.
3  The syntax rules describing structured constructs are presented in a form that corresponds to the recommended paragraphing. For example, an if_statement is defined as:
if_statement ::=
    if condition then
   {elsif condition then
    end if;
4  The line breaks and indentation in the syntax rules indicate the recommended line breaks and indentation in the corresponding constructs. The preferred places for other line breaks are after semicolons.

Contents   Index   Search   Previous   Next   Legal