过程程序设计语言规范

V. Protsenko
{"title":"过程程序设计语言规范","authors":"V. Protsenko","doi":"10.18523/2617-3808.2022.5.4-11","DOIUrl":null,"url":null,"abstract":"A simple procedural programming language is considered, each program of which can input integer values, process them and output new integer values as result. A program is a block with description of local integer variables and procedures and a list of statements. The language has data processing statements: assignment, input, output, conditional, loop, procedure call and block. Main purpose of the block is to enter local data (integer variables and procedures) that are used in the body of the block – a list of operators. The scope of the name of the local data described in the block is the text of the block except for nested blocks, where this name is redefined. A mechanism of automatic memory allocation for variables entered in the block is also associated with the block. Memory for local variables is allocated when entering a block, and freed when exiting a block. A block containing only a list of statements is valid. The procedure has a name, list of formal parameters, and a body – a statement (most often a block). Formal parameters are applied only in its body. A procedure is calculated by the procedure call statement, whose actual parameters are only variables. Parameters are passed by reference (pass-by-reference).A formal specification of a programming language is a description of its syntax and semantics. A concrete syntax, finite set of rules, singles out syntactically correct sequences of symbols of the alphabet of language. To describe the semantics of a language, as a rule, abstract syntax is used, adding contextual conditions to it. The task of semantics is to introduce the denotations (“meanings”) of the basic constructions of language and semantic functions that build the denotations of complex syntactic constructions based on the denotations of their components, including the program.The article provides a specification of a procedural programming language that uses the extended Backus-Naur form to describe a concrete syntax, and the tools of the functional language Haskell to describe other parts. Abstract syntax is defined by the types Program, Proc, Stmt, Expr and Op. Additional contextual conditions are predicates that use information about program data. Most of the context conditions are related to the correct use of data in the program. The leading predicate that checks the context conditions of the program pr is iswfProgram pr.The language denotations are based on the Work type. The value of this type – a tuple (inp, stg, out) models the environment in which the language program is executed: inp - input data, stg – memory containing variable values, out – resulting data. The semantics of main constructions procedure, statement and expression are functions of the type Work -> Work or Work -> Integer. The semantics of the program is a function of the type [Integer] -> [Integer]. Semantic functions build these denotations according to syntactic constructions, which are described by abstract syntax – Proc, Stmt, Expr, Program types. The semantics of the program (Program) pr is built by function iProgram pr.All functions: contextual conditions, denotations and semantic functions are pure functions. Using Haskell tools, a function called parsePLL is built, which connects concrete and abstract syntax. It is shown how by combining the functions parsePLL, iswfProgram and iProgram you can get a procedural language – a pure function with the name interpret.","PeriodicalId":433538,"journal":{"name":"NaUKMA Research Papers. Computer Science","volume":"1 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2023-02-24","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":"{\"title\":\"Specification of the Procedural Programming Language\",\"authors\":\"V. Protsenko\",\"doi\":\"10.18523/2617-3808.2022.5.4-11\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"A simple procedural programming language is considered, each program of which can input integer values, process them and output new integer values as result. A program is a block with description of local integer variables and procedures and a list of statements. The language has data processing statements: assignment, input, output, conditional, loop, procedure call and block. Main purpose of the block is to enter local data (integer variables and procedures) that are used in the body of the block – a list of operators. The scope of the name of the local data described in the block is the text of the block except for nested blocks, where this name is redefined. A mechanism of automatic memory allocation for variables entered in the block is also associated with the block. Memory for local variables is allocated when entering a block, and freed when exiting a block. A block containing only a list of statements is valid. The procedure has a name, list of formal parameters, and a body – a statement (most often a block). Formal parameters are applied only in its body. A procedure is calculated by the procedure call statement, whose actual parameters are only variables. Parameters are passed by reference (pass-by-reference).A formal specification of a programming language is a description of its syntax and semantics. A concrete syntax, finite set of rules, singles out syntactically correct sequences of symbols of the alphabet of language. To describe the semantics of a language, as a rule, abstract syntax is used, adding contextual conditions to it. The task of semantics is to introduce the denotations (“meanings”) of the basic constructions of language and semantic functions that build the denotations of complex syntactic constructions based on the denotations of their components, including the program.The article provides a specification of a procedural programming language that uses the extended Backus-Naur form to describe a concrete syntax, and the tools of the functional language Haskell to describe other parts. Abstract syntax is defined by the types Program, Proc, Stmt, Expr and Op. Additional contextual conditions are predicates that use information about program data. Most of the context conditions are related to the correct use of data in the program. The leading predicate that checks the context conditions of the program pr is iswfProgram pr.The language denotations are based on the Work type. The value of this type – a tuple (inp, stg, out) models the environment in which the language program is executed: inp - input data, stg – memory containing variable values, out – resulting data. The semantics of main constructions procedure, statement and expression are functions of the type Work -> Work or Work -> Integer. The semantics of the program is a function of the type [Integer] -> [Integer]. Semantic functions build these denotations according to syntactic constructions, which are described by abstract syntax – Proc, Stmt, Expr, Program types. The semantics of the program (Program) pr is built by function iProgram pr.All functions: contextual conditions, denotations and semantic functions are pure functions. Using Haskell tools, a function called parsePLL is built, which connects concrete and abstract syntax. It is shown how by combining the functions parsePLL, iswfProgram and iProgram you can get a procedural language – a pure function with the name interpret.\",\"PeriodicalId\":433538,\"journal\":{\"name\":\"NaUKMA Research Papers. Computer Science\",\"volume\":\"1 1\",\"pages\":\"0\"},\"PeriodicalIF\":0.0000,\"publicationDate\":\"2023-02-24\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"\",\"citationCount\":\"0\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"NaUKMA Research Papers. Computer Science\",\"FirstCategoryId\":\"1085\",\"ListUrlMain\":\"https://doi.org/10.18523/2617-3808.2022.5.4-11\",\"RegionNum\":0,\"RegionCategory\":null,\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"\",\"JCRName\":\"\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"NaUKMA Research Papers. Computer Science","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.18523/2617-3808.2022.5.4-11","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0

摘要

考虑了一种简单的过程式编程语言,该语言的每个程序都可以输入整数值,对其进行处理并输出新的整数值。程序是一个包含局部整数变量和过程描述以及语句列表的块。该语言有数据处理语句:赋值、输入、输出、条件、循环、过程调用和块。该块的主要目的是输入在块体中使用的局部数据(整数变量和过程)-操作符列表。块中描述的本地数据的名称范围是块的文本,嵌套块除外,其中该名称被重新定义。在块中输入变量的自动内存分配机制也与块相关联。局部变量的内存在进入块时分配,在退出块时释放。只包含语句列表的块是有效的。这个过程有一个名称、一个形式参数列表和一个主体——一个语句(通常是一个块)。形式参数仅应用于其主体。过程是由过程调用语句计算的,其实际参数只是变量。参数通过引用传递(逐个引用传递)。编程语言的正式规范是对其语法和语义的描述。一个具体的语法,一组有限的规则,从语言的字母表中挑出语法正确的符号序列。为了描述语言的语义,通常会使用抽象语法,并为其添加上下文条件。语义学的任务是引入语言基本结构的外延(“意义”)和语义功能,这些功能基于其组成部分(包括程序)的外延,构建复杂句法结构的外延。本文提供了一种过程编程语言的规范,该语言使用扩展的backus - aur形式来描述具体的语法,并提供了函数式语言Haskell的工具来描述其他部分。抽象语法由类型Program、Proc、Stmt、Expr和op定义。附加上下文条件是使用有关程序数据信息的谓词。大多数上下文条件都与程序中数据的正确使用有关。检查程序pr的上下文条件的前导谓词是iswfprogrampr。语言表示基于Work类型。这种类型的值-元组(inp, stg, out)模拟语言程序执行的环境:inp -输入数据,stg -包含变量值的内存,out -结果数据。主要结构、过程、语句和表达式的语义是Work -> Work或Work -> Integer类型的函数。程序的语义是一个类型为[Integer] -> [Integer]的函数。语义函数根据语法结构构建这些表示,这些语法结构由抽象语法(Proc、Stmt、Expr、Program类型)描述。程序(program) pr的语义由函数iProgram pr构建。所有函数:上下文条件、表示和语义函数都是纯函数。使用Haskell工具,构建了一个名为parsePLL的函数,它连接了具体语法和抽象语法。它展示了如何通过组合函数parsePLL、iswfProgram和iProgram,您可以获得一个过程性语言——一个名为explain的纯函数。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
Specification of the Procedural Programming Language
A simple procedural programming language is considered, each program of which can input integer values, process them and output new integer values as result. A program is a block with description of local integer variables and procedures and a list of statements. The language has data processing statements: assignment, input, output, conditional, loop, procedure call and block. Main purpose of the block is to enter local data (integer variables and procedures) that are used in the body of the block – a list of operators. The scope of the name of the local data described in the block is the text of the block except for nested blocks, where this name is redefined. A mechanism of automatic memory allocation for variables entered in the block is also associated with the block. Memory for local variables is allocated when entering a block, and freed when exiting a block. A block containing only a list of statements is valid. The procedure has a name, list of formal parameters, and a body – a statement (most often a block). Formal parameters are applied only in its body. A procedure is calculated by the procedure call statement, whose actual parameters are only variables. Parameters are passed by reference (pass-by-reference).A formal specification of a programming language is a description of its syntax and semantics. A concrete syntax, finite set of rules, singles out syntactically correct sequences of symbols of the alphabet of language. To describe the semantics of a language, as a rule, abstract syntax is used, adding contextual conditions to it. The task of semantics is to introduce the denotations (“meanings”) of the basic constructions of language and semantic functions that build the denotations of complex syntactic constructions based on the denotations of their components, including the program.The article provides a specification of a procedural programming language that uses the extended Backus-Naur form to describe a concrete syntax, and the tools of the functional language Haskell to describe other parts. Abstract syntax is defined by the types Program, Proc, Stmt, Expr and Op. Additional contextual conditions are predicates that use information about program data. Most of the context conditions are related to the correct use of data in the program. The leading predicate that checks the context conditions of the program pr is iswfProgram pr.The language denotations are based on the Work type. The value of this type – a tuple (inp, stg, out) models the environment in which the language program is executed: inp - input data, stg – memory containing variable values, out – resulting data. The semantics of main constructions procedure, statement and expression are functions of the type Work -> Work or Work -> Integer. The semantics of the program is a function of the type [Integer] -> [Integer]. Semantic functions build these denotations according to syntactic constructions, which are described by abstract syntax – Proc, Stmt, Expr, Program types. The semantics of the program (Program) pr is built by function iProgram pr.All functions: contextual conditions, denotations and semantic functions are pure functions. Using Haskell tools, a function called parsePLL is built, which connects concrete and abstract syntax. It is shown how by combining the functions parsePLL, iswfProgram and iProgram you can get a procedural language – a pure function with the name interpret.
求助全文
通过发布文献求助,成功后即可免费获取论文全文。 去求助
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术官方微信