NORMA (1158464), страница 2
Текст из файла (страница 2)
apostrophe :
'
space :
Space has no graphical representation.
3.1.2. Commentaries
The line which begins from the sign “!” or the part of line which follows the sign “!” is a commentary.
3.1.3. Tokens
There are 5 classes of tokens: identificators, key-words, constants, operation signs, delimiters.
Spaces, LF, commentaries are considered tokens’ delimiters and have no influence on the program semantics.
3.1.4. Identificators
identificator :
letter { { digit, letter } }*
The letters of upper register differ from the ones of low register. Identificators can have any length. The number of the meaningful symbols is defined in the specification of the translator’s source language (usually first 6 symbols are meaningful).
3.1.5. Key words
These key-words are used in the language:
MAIN PART | VARIABLE | ITERATION |
PART | DEFINED ON | BOUNDARY |
FUNCTION | REAL | END BOUNDARY |
BEGIN | INTEGER | INITIAL |
END PART | DOUBLE | END INITIAL |
RESULT | DOMAIN PARAMETERS | EXIT WHEN |
EXTERNAL FUNCTION | INPUT | END ITERATION |
EXTERNAL PART | OUTPUT | FOR |
DISTRIBUTION INDEX | ON | ASSUME |
INDEX | COMPUTE |
3.1.6. Constants
constant :
arithm-constant
string
arithm-constant:
int-constant
real-constant
double-constant
int-constant :
{ digit }+
real-constant :
body [ E [ { +,- } ] power ]
double-constant :
body [ D [ { +,- } ] power ]
body :
int-constant . int-constant
power
int-constant
string
‘ { { symbol-not-apostrophe, ‘‘ } }+‘
symbol-not-apostrophe:
letter
digit
special- symbol-not-apostrophe
supplementary-symbol
The rules of writing constants are similar to the ones in the Fortran language.
The type and the value of the constant is defined by the way of its representation. These are examples of arithmetical constants :
101 999 0.1 1.0
10.5E-6 1.0E+7 1.0E7 0.1D-8 15.333D4
These records are not arithmetical constants:
.1 1. 1E-1 1.E5
These are examples of the strings :
'Hello, world!'
'Об ''ем тела = '
3.1.7. Signs of operations
operation :
{rel-operation, log-operation, arithm-operation }
rel-operation:
{ =,>,<,<=,>=,<>,>< }
rel-except-not-equal-operation :
{ =,>,<,>=,<= }
log-operation :
{ AND, OR, NOT }
arithm-operation :
{ +,-,*,/,** }
Symbols >= and <= are used for comparisons and
, <> and >< symbols - for
.
3.1.8. Delimiters
delimiter :
{ space,/,(,),[,],!,?,’,,,.,# }
3.2. Names
name :
identificator
list-name :
name { , name }*
Name is an identificator. It has a particular meaning and defines a particular program’s object (e.g. variable, domain, part of the program). There can’t be two definitions of the objects which have the same name.
The rule of name localization is true for every program element (part or function). The names declared in the program element are localized in it. There is no notion “global variable“ in this language. The names of the functions or the parts if they are actual or formal parameters of other parts or functions are indicated in the external names declaration EXTERNAL FUNCTION or EXTERNAL PART [see 5.16].
Half-underlined syntactical symbols e.g. name-set are syntactically equivalent to symbol name. Underlined part of the construction has additional semantic information.
Symbol list-name substitutes non-empty list of the names enumerated by comma.
3.3. Basic data types
There are basic data types specified in the language:
integer, real, double, logical, string
Value from the set of integers is assigned to the element of integer data type. There are arithmetical and comparison operations (rel-operation) for integer type elements.
Value from the set of real numbers is assigned to the element of real data type. There are arithmetical and comparison operations (rel-operation) for real type elements.
Value from the set of real numbers is assigned to the element of double data type and it allows to use double precious real numbers. There are arithmetical and comparison operations (rel-operation) for double type elements.
There are variables of integer, real and double type in the language.
Value “true” and “false” is assigned to the element of logical data type. It is used for definition of condition. There are logical operations for logical type elements. There are no variables of logical type in the language.
The element of string data type is a set of symbols from principal symbol set and supplementary symbol set. There are only constants but no variables and operations of this type.
3.4. Expressions
3.4.1. Arithmetical expressions
arithm-expression :
[ { +, - } ] term { arithm-operation term }*
term :
arihm-constant
call-function
name-index
name-domain-parameter
name-scalar
variable-on-domain
(arithm-expression)
variable-on-domain :
name-variable-on-domain [ [ list-index-expression ] ]
const-expression :
[ { +,- } ] const-expression-without-sign
const-expression-without-sign :
integer-term { arithm-operation integer-term }*
integer-term :
int-constant
name-domain-parameter
( const-expression )
index-expression :
name-index [ [ { +,- } ] const-expression-without-sign ]
name-index = const-expression-without-sign
name-index = name-index [ [ { +,- } ] const-expression-without-sign ]
The result of the index expression computation in a fixed point T of the domain (5.1.1.) is coordinates of the point T’. These coordinates can be defined according to the rules :
indexes are substituted to the constant expressions, values of T coordinates (taking into account index displacement if it is given) or values of the other given indexes in the point T.
For example, the list of index expressions [i-1,j,k=7,l=i+4] for the point T with i=9, j=15, k=3, l=37 gives us the value of the point T’ from index domain with i=8, j=15, k=7, l=13 coordinates.
The order of arithmetical expression computation is :
(1) index expressions computation;
(2) finding arguments (actual parameters) of the functions ( including determination of reduction functions operation domain [5.2.3];
(3) carrying-out in-brackets ( and ) operations: if there are several brackets of the one level, they are examined from the left to the right;
(4) carrying-out raising to the ** power operations: if there are several operations of the one level, they are examined from the right to the left;
(5) carrying-out of multiplication and division * and / operations; if there are several operations of the one level, they are examined from the left to the right;
(6) carrying-out of sum and difference + and - operations; if there are several operations of the one level, they are examined from the left to the right.
The type of arithmetical expression result is defined by the types of operation results. The type of operation result can be :
(1) integer, if both operands are integer ;
(2) double, if even one operand is double ;
(3) real in any other cases.
Constant expression is a particular case of arithmetical expression. The examples of arithmetical expressions :
AL12[J=2*M-1]+STEPLP*JJ
Q+1.0D5/((R[Q-1]-R)*(R[Q-1]-R[Q+1]))
CN*TRAP(STEP, 2*MV+1, MMR ON POLL)
3.4.2. Conditional expressions
log-expression :
[ NOT ] logic-term { log-operation logic-term }*
logic-term :
comparison
( log-expression )
comparison :
arithm-expression comp-operation arithm-expression
condition-on-domain :
log-expression
condition-on-index :
name-index rel-except-not-equal-operation
name-index [ { +,- } const-expression-without-sign ]
name-index rel-except-not-equal-operation const-expression-without-sign
The order of operations for logical expression computation :
(1) carrying out of arithmetical expressions computation;
(2) carrying out of in-brackets ( and ) operations; if there are several brackets of the one level, they are examined from the left to the right.
(3) carrying out of comparisons =,>,<,>=,<=,<>,>< ; if there are several operations of the one level, they are examined from the left to the right.
(4) carrying out of logical negation NOT operations; if there are several operations of the one level, they are examined from the left to the right.
(5) carrying out of logical multiplication AND operations; if there are several operations of the one level, they are examined from the left to the right.
(6) carrying out of logical sum OR operations; if there are several operations of the one level, they are examined from the left to the right.
There are examples of logical expressions:
ABS(MOD-X1+Y1)<=1.0D-20
NOT (II=(2*N+1)*(2*NV+1) AND NU=0)
I=J+1
4. Program structure
program :
{ part }+
part :
main-part
simple-part
part-function
main-part :
MAIN PART name-part . declaration-of-part
simple-part :
PART name-simple-part . declaration-of-part
part-function :
FUNCTION name-function [type-function] . declaration-of-function
declaration-of-part :
formal-parameters-of-part BEGIN body-of-part END PART
formal-parameters-of-part :
[ list-name ] [RESULT list-name]
declaration-of-function :
formal-parameters-of-function BEGIN body-of-part END PART
formal-parameters-of-function :
list-name
body-of-part :
{ element-of-part }*
element-of-part :