Опис імперативної мови програмування у Haskell

Loading...
Thumbnail Image
Date
2021-12-10
Authors
Проценко, Володимир
Journal Title
Journal ISSN
Volume Title
Publisher
Abstract
Розглянуто використання функціональної мови програмування Haskell як метамови. Наведено повну формальну специфікацію простої імперативної мови програмування з цілими даними, блочною структурою та операторами: присвоєння, введення, виведення, циклу і умовний. На основі специфікації побудовано інтерпретатор мови програмування.
When creating a programming language, it is necessary to determine its syntax and semantics. The main task of syntax is to describe all constructions that are elements of the language. For this purpose, a specific syntax highlights syntactically correct sequences of characters of the language alphabet. Most often it is a finite set of rules that generate an infinite set of all construction languages, such as the extended Backus-Naur (BNF) form. To describe the semantics of the language, the preference is given to the abstract syntax, which in real programming languages is shorter and more obvious than specific. The relationship between abstract syntax objects and the syntax of the program in compilers solves the parsing phase. Denotational semantics is used to describe semantics. Initially, it records the denotations of the simplest syntactic objects. Then, with each compound syntactic construction, a semantic function is associated, which by denotations of components of a design calculates its value – denotation. Since the program is a specific syntactic construction, its denotation is possible to determine using the appropriate semantic function. Note that the program itself is not executed when calculating its denotation. The denotative description of a programming language includes the abstract syntax of its constructions, denotations – the meanings of constructions and semantic functions that reflect elements of abstract syntax (language constructions) in their denotations (meanings). The use of the functional programming language Haskell as a metalanguage is considered. The Haskell type system is a good tool for constructing abstract syntax. The various possibilities for describing pure functions, which are often the denotations of programming language constructs, are the basis for the effective use of Haskell to describe denotational semantics. The paper provides a formal specification of a simple imperative programming language with integer data, block structure, and the traditional set of operators: assignment, input, output, loop and conditional. The ability of Haskell to effectively implement parsing, which solves the problem of linking a particular syntax with the abstract, allows to expand the formal specification of the language to its implementation: a pure function — the interpreter. The work contains all the functions and data types that make up the interpreter of a simple imperative programming language.
Description
Keywords
мова програмування, синтаксис, денотат, семантична функція, Haskell, синтаксичний аналіз, інтерпретатор, стаття, programming language, syntax, denotation, semantic function, Haskell, parsing, interpreter, article
Citation
Проценко В.С. Опис імперативної мови програмування у Haskell / Проценко В. С. // Наукові записки НаУКМА. Комп'ютерні науки. - 2021. - Т. 4. - С. 72-77. - https://doi.org/10.18523/2617-3808.2021.4.72-77
Collections