normDDe (1158428), страница 5
Текст из файла (страница 5)
<HPF-comment>::=<sequence of token codes>
<DVM-comment>::=<sequence of token codes>
<label>::=<integer>
<name-index>::=<token code>
<b-value>::=<integer>
<e-value>::=<integer>
<step>::=<integer>
<logic-expression>::=<sequence of token codes>
<list-parameters>::=<sequence of token codes>
<name-subroutine>::=<token code>
<name-program>::=<token code>
<name-function>::=<token code>
<chan-number>::=<integer>
<read-list>::=<sequence of token codes>
<write-list>::=<sequence of token codes>
<format-list>::=<sequence of token codes>
<declaration-list>::=<sequence of token codes>
<external-list>::=<sequence of token codes>
<data-list>::=<sequence of token codes>
<operators>::=<fortran-statement> OR <operators><fortran-statement>
<type>::=’I’ OR ‘R’ OR ‘D’
<assignment>::=<sequence of token codes>
<CONTINUE>::=<token code>
<DO>::=<token code>
<IF>::=<token code>
<CALL>::=<token code>
<READ>::=<token code>
<WRITE>::=<token code>
<FORMAT>::=<token code>
<IFTHEN>::=<token code>
<IF_THEN_ELSE>::=<token code>
<declaration>::= <REAL> OR <INTEGER> OR <DOUBLE PRECISION>
<REAL>::=<token code>
<INTEGER>::=<token code>
<DOUBLE PRECISION>::=<token code>
<EXTERNAL>::=<token code>
<PROGRAM>::=<token code>
<SUBROUTINE>::=<token code>
<FUNCTION>::=<token code>
<DATA>::=<token code>
<RETURN>::=<token code>
<END>::=<token code>
<STOP>::=<token code>
3.23Input variables queue
Input variables queue is used for holding information about the order of input determined by the compiler for input-variable.
The element of Input variables queue has the form:
|
| name-variable | format | name-index | range | … | name-index | range |
<file number>::=<integer>
<name-variable>::=<identifier>
<format>::=<Norma language attribute format>
<name-index>::=<identifier>
<range>::=<integer><integer>
This information means that variable with name <name-variable> must be input from file with number <file-number> by format <format> for the values of indexes <name-index>=<range>, … , <name-index>=<range> (for scalar variable of field <name-index>there is no <range>).
4.Global initialisation
Translator's entry function - function norma initialises global counters of the translator and analyses translating options set in the command line.
General structure of unit Global initialisation control is given in the following scheme.
n
orma count0 zaparg face count
erroutall
4.1Initialisation of global counters (function count0)
glob=0 - counter of errors in Norma - program,
globw=0 - counter of warnings in Norma - program,
eof=0 - attribute denotes end of reading source file with Norma - program ,
bline=0 - initial value of the counter for filling in field<begin line number> in Statements-lines table,
eline=0 - initial value of the counter for filling in field <end line number> in Statements-lines table,
beginline=0 - initial value of counter of source file's lines. These lines have been processed in creating list of translation.
4.2Analysis of translation's options (function zaparg)
Command line has form norma <options> <source file>.
Source file is supposed to have extension .hop and must be set in the form <name>.hop.
Function zaparg:
1) sets values of the variables used in reading and writing of the files in the process of translation:
filein=<name>.hop - name of the source file, containing Norma-program,
fileft=<name>.for - name of the target file, containing text of FORTRAN DVM-program,
filelst=<name>.lst - name of file with listing of Norma - program translation.
2) sets value of the variable holding value of the current directory:
dir=<directory-name>
3) processes options of translation
Possible options of translation:
f-77 - translation into sequential Fortran-77,
dvm - translation into FORTRAN DVM,
length=<integer> - number of identificator's significant symbols ,
lst=1 - there is a text of Norma program and translator's messages in listing,
lst=2 - there is a text of FORTRAN DVM program and translator's messages in listing,
lst=3 - there is a text of Norma program, FORTRAN DVM program and translator's messages in the listing.
In processing options of translation the values of variables are set for holding translation options by default and redeclarated in case the options of translation have been given.
The variables of translation's options and their values by default:
f-out =3 - translation into FORTRAN DVM
lenid=6 - 6 significant symbols in identificator
lstng= 3 - mode lst=3.
4) opens files fileft, filelst, filein,
5) calls function face from unit Listing generator for output the messages about date, time, compiler's version, options of translation,
6) if in executing items 1)-5) the mistakes have been detected then function erroutall from unit Listing generator is called, in other case we call function count from unit Local initialisation.
In analysis of translation's options the following errors are fixed:
error code 408 'incorrect name of source file '<error context>
error code 271 'file '<error context>' is not found'
error code 413 'incorrect compilation option '<error context>
5.Norma part unit compilation
It is main unit of the compiler. It consists of units a)-j) mentioned in pragraph 1. Description of these units are given below.
5.1Local initialisation
Local counters used in translation of Norma part unit and Symbol table, Constant table are initialised. Then input function beginlex from unit Part unit scanner is called.
General structure of unit Local initialisation control is given in the following scheme.
c
ount tableid tablecon beginlex
5.1.1Initialisation of local counters (function count)
osh=0 - counter of errors in current part of Norma - program,
osh1=0 - counter of warnings in current part of Norma - program,
met=1 - counter for generating labels in FORTRAN-program,
formet=40000 - counter for generating marks of operators FORMAT in FORTRAN-program,
kba=0 - counter of statements' numbers <statement number> of Norma part unit,
itn=600 - counter of iterations' numbers <iteration number> of Norma part unit,
i=700 - counter for generating names of iterated (first result variable name, second result variable name),
seq=1 - attribute denoting absence of sequential computations' mode.
5.1.2Initialisation of Symbol table (function tableid)
Lines given below are put into Symbol table
| TAN | F | 185 |
| DTAN | F | 186 |
| DSIGN | F | 187 |
| SIGN | F | 188 |
| DATAN | F | 189 |
| DASIN | F | 190 |
| DCOS | F | 191 |
| DSIN | F | 192 |
| DEXP | F | 193 |
| DLOG10 | F | 194 |
| DLOG | F | 195 |
| DABS | F | 196 |
| DMIN1 | F | 197 |
| DMAX1 | F | 198 |
| DSQRT | F | 199 |
| EXP | F | 200 |
| SIN | F | 201 |
| COS | F | 202 |
| SQRT | F | 203 |
| ABS | F | 204 |
| ALOG | F | 205 |
| ALOG10 | F | 206 |
| ASIN | F | 207 |
5.1.3Initialisation of Constant table (function tablecon)
Lines given below are put into Таблицу констант (Constant table)
| 0 | I | 10000 |
| 1 | I | 10001 |
5.2Part unit scanner
General structure of Part unit scanner control is given in the following scheme.
b
eginlex
file number 














