Денотаційна семантика одновимірних масивів

Loading...
Thumbnail Image
Date
2025
Authors
Проценко, Володимир
Journal Title
Journal ISSN
Volume Title
Publisher
Abstract
Розглянуто імперативну мову програмування, об’єктами якої є цілі змінні — скалярні та одновимірні масиви. Оператори мови — присвоєння, введення, виведення, умовний, циклу і блок. Призначення боку — введення локальних цілих змінних. Одновимірний масив a[k], де k>0 — ціле додатне число (розмірність масиву). Робота з масивами здійснюється поелементно. Доступ до окремого елементу масиву здійснює операція індексування a[e], e — цілий вираз. Значення e — число від 0 до k-1. Наведено повну формальну специфікацію мови. На основі специфікації побудовано інтерпретатор мови програмування.
Description
An imperative programming language is considered that has integer scalar data and one-dimensional arrays. Each variable a in this language is either an integer scalar variable a or an integer one-dimensional array a[k], where k>0 is a positive integer. Such an array has k elements, which are sequentially arranged and numbered as a[0], a[1], ..., a[k-1]. A program is a separate statement, usually a block with a description of local integer variables (scalar or arrays) and a list of statements – the body of the block. All expressions in the statements calculate a scalar integer value. Work with an array is carried out only element by element. If a[k] is an entire one-dimensional array, then access to an individual element of the array is performed by an indexing operation - a record of the form a[e]. The value of the integer expression e – must be an integer from 0 to k-1. In a program, one name can refer to different values (a variable description in the inner and outer blocks). In addition, one array name is associated with multiple values (elements with different indices). To associate variable names with their denotations (memory addresses where the current valu of the variable is stored), an environment is used – a value of type Env. type Env = [(String,(Maybe Int, Int))] If Int a is a scalar variable with the denotation (Nothing,3) associated with it in the environment, then 3 is the memory address containing the current value of a. If Int b[4] is an array with which the denotation (Just 4,7) is associated, then 7 is the memory address containing the current value of element b[0], 6 is the address where the value b[1] is found, 5 is the address of b[2], and 4 is the address of b[3], respectively. The functional language Haskell is used to describe this imperative language, which includes syntax and denotational semantics. All functions included in the description are pure. It is shown how to use these functions to build a pure function – a language interpreter.
Keywords
мова програмування, програма, оператор, вираз, змінні, одновимірні масиви, синтаксис, денотат, семантична функція, Haskell, синтаксичний аналіз, інтерпретатор, стаття, programming language, program, statement, expression, variable, one-dimensional array, syntax, denotation, semantic function, Haskell, interpreter
Citation
Проценко В. С. Денотаційна семантика одновимірних масивів / Проценко В. С. // Наукові записки НаУКМА. Комп'ютерні науки. - 2025. - Т. 8. - С. 149-157. - https://doi.org/10.18523/2617-3808.2025.8.149-157