Grammar of programming languages
Grammar of programming languages consists of a description of their alphabets. The alphabet of any language consists of a fixed set of symbols that are uniquely interpreted. The alphabet of programming languages, as a rule, is connected with the letters of the keyboard of a typewriter. Keyboards of personal computers are close to them by the presence of letters.
Despite the significant differences between programming languages, a number of fundamental concepts of the grammar of programming languages in most of them are similar. Let us cite some of these concepts.
The operator is one of the leading concepts of all programming languages (theoretically, with the exception of purely declarative ones, but in reality they also use a related concept). Each operator is a complete phrase of the language and defines the uniquely interpretable stage of data processing. In accordance with the theory of algorithms, the main (basic) operators of the programming language are distinguished: assignments, conditional and unconditional jumps, an empty statement. To derivatives, not basic, include a compound operator, a selection operator, a loop operator, and an addition operator.
Operators are executed in the order they are in the text of the program. Only with the help of transition operators this natural order can be violated.
Most of the operators in the programming language grammar process the values. Values can be constant and variable. Values of constants do not change during program execution. The value is characterized by type, name and value. The most common types of values are numerical (integer and real), symbolic, logical. The type of the value is determined by its value. Another important classification of quantities is simple and structured. A simple value at each moment can have no more than one value. It corresponds to one memory location or its equivalent in the external memory of the computer. A structured value, with a single name, can have several meanings at once. These values are the elements (components) of the value. The most widely known example is an array in which the elements differ in indices (numbers).
All program objects in the programming language grammar are given individual names. The name of the program object is called the identifier. The most common identifier is any finite sequence of letters and numbers starting with a letter. Some identifiers are prescribed a certain meaning in advance and are called standard, for example, sin is the name of a known mathematical function.
Descriptions or declarations of program objects are linked in the grammar of programming languages with data processing rules. The data is different and it is necessary for each of them to determine its properties. For example, if the data is an array, you must specify its dimension, the boundaries of the indexes, and the type of elements in the array. The descriptive part of the programming language grammar is necessary both for system programmers who are developers of translators who must, in particular, perform syntactic and semantic diagnostics of programs, as well as for an "application" programmer, to whom program object declarations often facilitate the development and debugging of programs.
Variables play a crucial role in the grammar of programming languages. The notion of "variable" in programming languages differs from the generally accepted one in mathematics. A variable is a program object that can take on a certain value using an assignment operator. During execution of the program, the values of the variable can be changed several times. Each variable after its description is identified with a certain memory cell, the contents of which is its value.
The semantic meaning of a variable in the grammar of a programming language is to store a value that corresponds to its type (for example, an integer type variable can take the value of an arbitrary integer), and perform operations with it to send it to and retrieve from it.
Function is a program object that defines a computational procedure for determining a value that depends on some arguments. It is introduced into programming languages to specify the programmer's functional dependencies. In each high-level language, there is a library of standard functions: arithmetic, logical, character, file, etc.
The procedure is a program object representing some independent stage of data processing. In fact, the procedures were successors to the subroutines that were introduced to facilitate the development of programs at the earliest stages of the formation of algorithmic languages. The procedure has input and output parameters, called formal ones. When using the procedure, the formal parameters are replaced with the actual ones.
Module (Unit) is a special software unit designed to create libraries and separate large programs into logically connected blocks.
In fact, the module in the programming language grammar is a set of constants, data types, variables, procedures and functions. The module includes sections: header, interface, implementation, initialization.
