When a new programming language appears, the syntax and intended behaviour of its programs need to be specified. The behaviour of each language construct can be concisely specified by translating it to fundamental constructs (funcons), compositionally. In contrast to the informal explanations commonly found in reference manuals, such formal specifications of translations to funcons can be precise and complete. They are also easy to write and read, and to update when the language evolves. The PLanCompS project has developed a large collection of funcons. Each funcon is defined independently, using a modular variant of structural operational semantics. The definitions are available online, along with tools for generating funcon interpreters from them. This paper introduces and motivates funcons. It illustrates translation of language constructs to funcons, and funcon definition. It also relates funcons to the notation used in some previous language specification frameworks, including monadic semantics and action semantics.
翻译:当一种新的编程语言出现时,需要明确指定其语法和程序的预期行为。通过将每种语言构造组合式地翻译为基本构造(funcons),可以简洁地指定其行为。与参考手册中常见的非正式解释不同,这种将翻译过程形式化为基本构造的规范可以做到精确且完整。它们易于编写和阅读,并且在语言演进时易于更新。PLanCompS项目已开发了大量基本构造。每种基本构造均使用结构操作语义的模块化变体独立定义。这些定义可在线获取,并附带从定义生成基本构造解释器的工具。本文介绍并阐述了基本构造的动机,说明如何将语言构造翻译为基本构造,以及基本构造的定义方法。本文还将基本构造与以往若干语言规范框架(包括单子语义和动作语义)中的符号体系进行了关联。