normDDe (1158428), страница 14
Текст из файла (страница 14)
input-element { input-element }*
input-element :
name-scalar = arithm-constant;
name-variable-on-domain ( list-index-range ) = data ;
index-range :
name-index = int-constant .. int-constant
data :
list-data-element
data-element :
int-constant
body
int-constant ( data )
Source information for unit Input files analyser is Input variables queue and Table of input-output formats.
General structure of function isiofile control is given in the following scheme.
i
siofile trees files t1 prefmt gather
fls2 checktree shaketree in-fno
sntx
Function trees chooses next element from Input variables queue and passes it to function files.
Function files calls function fls2 with argument <file-number> for processing input file and after that it calls function t1 for processing input element.
Function fls2 reads data file file with number <file-number> into array of lines data (determining its name by the table of input files' fti) and calls function sntx for checking syntax correctness of this file's contents.
Function fixes errors:
error code 271 ' file'<error context>’ is not found’
Function sntx parsing array of lines data (contents of data file file) and if there is no errors it builds data structure heap used for holding input data in the order set in data file file (this order doesn't correspond to the order set by the queue of Input variables queue).
Element of data structure heap has the form:
| name-variable | name-index | range | … | name-index | range | data |
<name-variable>::=<identifier>
<name-index>::=<identifier>
<range>::=<integer><integer>
<data>::=<Norma language notion data>
This information means that values <data> (for scalar variable of field <name-index>there is no <range>)are set for variable with name<name-variable> and indexes <name-index>=<range>, … , <name-index>=<range> in the input file.
Function fixes errors:
error code 249 'incorrect data file: in line'<error context>’missed = or ('
error code 250 'incorrect data file: in line'<error context>’missed =’
error code 251 'incorrect data file: in line'<error context>’missed , or ; or (’
error code 252 'incorrect data file: in line'<error context>’missed , or )’
error code 253 'incorrect data file: in line'<error context>’missed identifier’
error code 254 'incorrect data file: in line'<error context>’missed number’
error code 255 'incorrect data file: in line'<error context>’missed integer’
Function t1 receives next element as an argument from Input variables queue. Field <format> of this element is passed to function prefmt, then structure tree is created, used for holding input data in the order determined by queue Input variables queue. Structure tree is determined in the following way:
<tree>::= (<vector>) OR <tree><tree>
<vector>::=<n>’undefined’
<n>::=<integer>
The number of structure tree elements is equal to the number of input variable elements. At start all the values of the elements of tree structure are values ’undefined’. Further processing is in transit of the values from heap structure to tree structure instead of corresponding ’undefined’.
Example. For the element of queue
|
| format | I | 1 | 10 | J | 1 | 15 | K | 1 | 2 |
structure tree is created
((10 ’undefined’)(15 ’undefined’)) ((10 ’undefined’)(15 ’undefined’))
Function prefmt processes field <format> and puts type of variable, number of digits in line and number of position for one digit into counters type, count, len correspondingly ( these counters will be used in the process of input file lines' creation in function shaketree).
Function gather concords structures heap and tree for the next element of queue Input variables queue. The values which correspond to the element of the queue and belong to heap are transmitted to corresponding positions in tree. Concordance of queue element and structures heap and tree is analysed and
function fixes errors:
error code 257 'incorrect data file: missed data for variable'<error context>
error code 258 'incorrect data file: repeatedly defined data for variable’<error context>
error code 259 'incorrect data file:there are less data for'<error context>’than defined in indexes’
error code 260 'incorrect data file: too much indexes for'<error context>
error code 261 'incorrect data file: not enough indexes for '<error context>
error code 274 'disaccordance of indexes'<error context>'and'<error context>'in variable declaration and in data file’'
error code 275 'disaccordance of indexes values of variable '<error context>' in INPUT and in data file'
Function checktree checks structure tree built before for certainty as there must be no elements with value ’undefined’ left. In other case,
function fixes error:
error code 262 'incorrect data file: there are undefined data for'<error context>
Function shaketree creates lines of the final reordered input file on the base of information from structure tree and counters type, count, len. Function checks correspondence of input data and input format represented by the values of these counters.
Function fixes errors:
error code 264 'incorrect data file:input'<error context>’for integer variable’
error code 265 'incorrect data file:'<error context>’is longer than attribute format'
Function in-fno receives text line as a parameter and puts it into the final input file. The name of this file is normain.in, and if the main part of Norma-program is compiled then - <part-name>.in.
5.9Listing generator
Listing generator contains the number of functions used for:
1) output of Norma source, Fortran DVM target program, time compilation messages into output file <listing-file>,
2) output of Fortran DVM target program into output file <target-file>,
3) output of Norma source, Fortran DVM target program, compile time messages onto a screen.
4) generation of texts of errors and warnings messages and linking them to corresponding lines of <listing-file> or screen.
Entry points of unit Listing generator are functions listing, erroutall, errpart, errprogr, info.
Function listing outputs text of Norma program and compilation messages. General structure of function listing control is given in the following scheme.
l
isting outrgm list-out outlstn errlst texterr
outrgm erroutall errpart
texterr
Function listing analyses output mode lst (lst=1 - there is Norma-program text and translator's messages in listing, lst=2 - text of Fortran DVM-program and translator's messages, lst=3 - text of Norma-program, Fortran DVM-program and translator's messages), outputs message about compilation options (calling function outrgm)and for lst=1,3 calls function of output of Norma-program's text , for lst=2 - function of output error messages erroutall.
Function list-out reads source file beginning with line with number beginline to line eline (at the end of work function sets beginline=eline+1 - new value of counter of source file lines processed in creation of translation listing). Next line is passed to function outlstn.
Then function outlstn is called , it outputs current read line on to the screen and into file filelst.
Then function errlst is called, it checks if there are errors corresponding to current line in List of errors and if there are some it calls function of generating error messages and warnings texterr. Processed information about errors is eliminated from List of errors.
Function texterr creates the text of message about establishing the pair <error code><error context> and outputs it onto the screen and into file filelst.
Function erroutall outputs messages about errors which belong to the whole part from List of errors onto the screen and into file filelst. It doesn't depend on the mode of output lst. Function texterr is called for generation of messages about errors and warnings.
Function errpart outputs final messages about results of part compilation ( time of part translation, values of errors counter osh in Norma part unit and counter of warnings osh1 in Norma part unit).
Function errprogr outputs final messages about results of Norma-program compilation ( time of part translation, values of errors counter glob in Norma program and counter of warnings globw in Norma- program).
Function info outputs text of current line of Fortran-DVM program into file fileft, onto the screen and into file filelst.
5.10Exit from part unit compilation
Exit part unit compilation’s functions are: generation compile time messages (time of part unit compilation, number of errors and warnings), cleaning data structure.
Entry point of unit Exit part unit compilation is function exit_part_compile.
General structure of function exit_part_compile control is given in the following scheme.
e
xit_part_compile diagn clears count
Function diagn computes total number of errors and warnings in program after compilation of the next part: glob=glob+osh; globw=globw+osh1.
Function clears clears all non-global data structures used in part compilation.
Function count is an entry point of unit Local initialisation. If it is called then next Norma-program part unit is to be compiled.
6.Exit from compilation
Exit from compilation’s functions are: to close files, to output some compiling time messages (time of compilation, number of errors and warnings).
Entry point of Exit part unit compilation is function stop.
Function stop calls function errprogr from Listing generator giving messages about results of translation.















