NORMA_DD (1158356), страница 6
Текст из файла (страница 6)
b
egin_part
line pkd statement lexitex
kbaht
nextline EndLex count
StopCompile
5.2.1Begin scanning (function beginlex)
It is an entry point of Part unit scanner.
It increases counter bline=bline+1.
5.2.2Read source file (function nextline)
1) It reads next line of source file with Norma-program,
It increases counter eline=eline+1.
2) If this line begins with symbol ?, it reads the lines of the source file up to the line which contains symbol ? in the first position (executing operation eline=eline+1), after that it reads the next line of the source file (bline=eline),
3) If the line contains any comments then comment is erased,
4) If the end of file is detected, eof=1,
5)In other case it substitutes the group of space characters by one space character.
5.2.3Norma part unit head analyses (function begin_part)
-
If eof=1, it calls StopCompile,
-
If the line begins with key words MAIN PART, PART, FUNCTION, it passes it to function line,
-
In other case it detects error and calls beginlex.
Function fixes error:
error code 304 'incorrect head of part'
5.2.4Norma statement extraction (function line)
-
If eof=1, it calls EndLex and StopCompile one after another,
-
If statement begins with symbol # (attribute of sequential computations' mode), then seq= -seq; if seq>0, next line in Таблицы последовательных групп (Table of ordered groups) is set,
-
If delimiter '.' is detected, there analyses context of this delimiter (function point). If it is the end of Norma-statement, this Norma-statement is eliminated from the line and passed to function pkd,
-
In other case it calls function nextline, unites result-line of its work with current line and calls line by recursion .
Function fixes errors:
error code 305 'missed END PART.'
error code 111 'incorrect using #...#''
error code 402 'declaration or operator is not ended with .'
5.2.5Conversion in tokens (function pkd)
It translates initial Norma-statement into sequence of tokens, creating Symbol table and Constant table. Key words and delimiter are recognised by explicit extraction from the text.
Norma-statement in the form of sequence of tokens is passed to function statement.
Function fixes error:
error code 403 'forbidden symbol ' <error context>
5.2.6Type of statement detection (function statement)
If Norma-statement begins with tokens MAIN PART, PART, FUNCTION, it calls function head_of_part, if Norma-statement begins with token ITERATION -it calls function lexitex, if with token END PART - function EndLex, in other case it calls function kbant. Norma-statement in the form of sequence of tokens is passed to the corresponding function.
Function fixes error:
error code 302 'missed . before END PART'
5.2.7Part unit head processing(function head_of_part)
General structure of function's control is given in the following scheme.
h
ead_of_part nextline
infun line
If token BEGIN is detected in the sequence of tokens then all the tokens placed before it are passed to function infun, and all the tokens placed after - to function line.
If token BEGIN isn't detected in the sequence of tokens then function nextline is called and the result of its work is united with current sequence of tokens and passed to function head_of_part again.
Function infun constructs two optional structures: part parameters list and record-part type record, which contains information about the part type. These structures will be used in Fortran DVM code generator to generate head of Fortran DVM unit (PROGRAM, SUBROUTINE, FUNCTION and list of formal parameters). Besides information about the name of the part is put into Symbol table.
Structure of part parameters list
| i | out-parameters |
<in-parameters>::=<sequence of token codes>
<out-parameters>::=<sequence of token codes>
Structure of part type record
| part type | part name | info |
<part type>::=MAIN PART
PART
FUNCTION
<part name>::=<token code>
<info>::=
| R | - REAL FUNCTION |
| I | - INTEGER FUNCTION |
| D | - DOUBLE FUNCTION |
Function fixes errors:
error code 298 'program has two MAIN PART'
error code 300 'incorrect part name'
error code 301 'missed BEGIN part body'
error code 303 'incorrect list of part parameters'
5.2.8Norma iteration processing (function lexitex)
It does scan and partial parsing of ITERATION construction. Parsing is of top-down recursive kind. The result of function lexitex work is information about current iteration put into Список итераций (List of iterations).
It uses function nextline in reading the source file with Norma-program.
Function lexitex uses some additional data structures as follows :
1) Stack of iterations iter_stack. It is used for analysing the structure of embedded iterations.
| i | iteration number | iteration level 1 |
| i | iteration number | iteration level 2 |
| … | … |
2) List of iterations with errors err_kwit. It is used to lock passing iterations which contain errors into Part unit parser.
General structure of function lexitex control is given in the following scheme.
l
exitex lhead zagiter is-bound spuskgr what nino line
is-initial spuskgr what
spuskitordo
thisfor spuskend
Function lexitex initialises counter of errors in iteration fat=0; if any error is detected in analysis of iteration then operation fat=fat+1 is done.
Function fixes error:
error code 58 'missed iteration index in head of ITERATION ON'
Function lhead makes coumt itn=itn+1; puts record
| iteration index | itn |
into iter_stack and extracts head of ITERATION in the form of sequence of tokens and passes it to function zagiter.
Function zagiter writes in in field <iteration number> value itn and fills <hеad-of-iteration> from List of iterations for current iteration.
Function fixes error:
error code 53 'incorrect list element of iterated variables:'<error context>
error code 59 'iteration index is not identifier'<error context>
error code 60 'incorrect key word in head of ITERATION ON' <error context>
error code 405 'incorrect identifier'<error context>
Function is-bound checks if there is token BOUNDARY in the current sequence of tokens.
If this token is detected it sets an attribute denoting the end of searching for END BOUNDARY and calls function spuskgr, extracting operators included into construction BOUNDARY…END BOUNDARY.
If this token isn't detected, it sets attribute NOT BOUNDARY.
Function spuskgr extracts operators one after another (ASSUME, INPUT, OUTPUT, COMPUTE, scalar operator) and passes them for processing to function thisfor. If token coincides with an attribute denoting end of search is detected then extracting is cancelled and function calls function what. If an attribute denoting end of search NOT BOUNDARY or ERROR is set, function what is called by at once.
Function fixes errors:
error code 62 'incorrect operator or declaration in ITERATION ON''
error code 111 'incorrect using #...#''
error code 54 'missed <error context> in ITERATION ON '<error context>
Function what analyses attribute denoting the end of search.
If an attribute denoting the end of search is ERROR it calls function which performs termination of processing iteration nino.
If an attribute denoting the end of search is END BOUNDARY it determines structure <list of boundary operators> from List of iterations for current iteration and calls function is-initial.
If an attribute denoting the end of research is END INITIAL it determines structure <list of initial operators> from List of iterations for current iteration and calls function spuskitordo extracting operators included into the body of iteration.
Function is-initial checks if there is token INITIAL in the current sequence of tokens.
If this token is detected it sets an attribute denoting end of search END INITIAL and calls function spuskgr, extracting operators included into the construction INITIAL…END INITIAL.
If this token isn't detected, it sets attribute ERROR.
Function fixes errors:
error code 63 'iteration index <error context>' differs from index of '<error context>
error code 54 'missed <error context> in ITERATION ON '<error context>
n-parameters
teration index
teration index














