首页> 外文期刊>Science of Computer Programming >On the semantics of parsing actions
【24h】

On the semantics of parsing actions

机译:关于解析动作的语义

获取原文
获取原文并翻译 | 示例
       

摘要

Parsers, whether constructed by hand or automatically via a parser generator tool, typically need to compute some useful semantic information in addition to the purely syntactic analysis of their input. Semantic actions may be added to parsing code by hand, or the parser generator may have its own syntax for annotating grammar rules with semantic actions. In this paper, we take a functional programming view of such actions. We use concepts from the semantics of mostly functional programming languages and adapt them to give meaning to the actions of the parser. Specifically, the semantics is inspired by the categorical semantics of lambda calculi and the use of premonoidal categories for the semantics of effects in programming languages. This framework is then applied to our leading example, the transformation of grammars to eliminate left recursion. The syntactic transformation of left-recursion elimination leads to a corresponding semantic transformation of the actions for the grammar. We prove the semantic transformation correct and relate it to continuation passing style, a widely studied transformation in lambda calculi and functional programming. As an idealization of the input language of parser generators, we define a call-by-value calculus with first-order functions and a type-and-effect system where the effects are given by sequences of grammar symbols. The account of left-recursion elimination is then extended to this calculus.
机译:解析器,无论是手动构建还是通过解析器生成器工具自动构建,通常除了对其输入进行纯语法分析之外,还需要计算一些有用的语义信息。可以将语义动作手动添加到解析代码中,或者解析器生成器可以具有自己的语法,以使用语义动作来注释语法规则。在本文中,我们从功能编程的角度来看待此类行为。我们使用大多数功能性编程语言的语义中的概念,并对其进行修改以赋予解析器操作的含义。具体来说,语义是受lamcalca演算的类别语义以及编程语言中效果的语义使用premonoidal类别启发的。然后将此框架应用于我们的主要示例,即语法转换以消除左递归。左递归消除的句法转换导致语法动作的相应语义转换。我们证明了语义转换的正确性,并将其与延续传递样式,lambda计算和函数编程中经过广泛研究的转换联系起来。为了使解析器生成器的输入语言理想化,我们定义了具有一阶函数的按值调用演算以及类型和效果系统,其中效果由语法符号序列给出。然后,将左递归消除的原因扩展到该演算。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号