首页> 外文期刊>Journal of Functional Programming >Finally tagless observable recursion for an abstract grammar model
【24h】

Finally tagless observable recursion for an abstract grammar model

机译:最终针对抽象语法模型的无标签可观察递归

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

摘要

We define a finally tagless, shallow embedding of a typed grammar language. In order to avoid the limitations of traditional parser combinator libraries (no bottom-up parsing, no full grammar analysis or transformation), we require object-language recursion to be observable in the meta-language. Since existing proposals for recursive constructs are not fully satisfactory, we propose new finally tagless primitive recursive constructs to solve the problem. To do this in a well-typed way, we require considerable infrastructure, for which we reuse techniques from the multirec generic programming library. Our infrastructure allows a precise model of the complex interaction between a grammar, a parsing algorithm and a set of semantic actions. On the flip side, our approach requires the grammar author to provide a type- and value-level encoding of the grammar's domain and we can provide only a limited form of constructs like many. We demonstrate five meta-language grammar algorithms exploiting our model, including a grammar pretty-printer, a reachability analysis, a translation of quantified recursive constructs to the standard one and an implementation of the left-corner grammar transform. The work we present forms the basis of the grammar-combinators parsing library,1 which is the first to work with a precise, shallow model of abstract context-free grammars in a classical (not dependently typed) functional language and which supports a wide range of grammar manipulation primitives. From a more general point of view, our work shows a solution to the well-studied problem of observable sharing in shallowly embedded domain-specific languages and specifically in finally tagless domain-specific languages.
机译:我们定义了类型化语法语言的最终无标记,浅层嵌入。为了避免传统解析器组合器库的局限性(无自底向上的解析,无完整的语法分析或转换),我们要求对象语言递归在元语言中是可观察的。由于现有的递归构造建议并不完全令人满意,因此我们提出了新的最终无标签原始递归构造来解决该问题。为此,我们需要大量的基础架构,我们需要重用multirec通用编程库中的技术。我们的基础结构可以为语法,解析算法和一组语义动作之间的复杂交互提供精确的模型。另一方面,我们的方法要求语法作者提供语法域的类型和值级别编码,并且我们只能提供有限的构造形式,例如许多形式。我们演示了利用我们的模型的五种元语言语法算法,包括语法漂亮打印机,可及性分析,将量化的递归构造转换为标准语法,以及左角语法转换的实现。我们目前的工作构成了语法组合器解析库的基础,1这是第一个以经典(非依赖类型)功能语言使用精确的浅层抽象上下文无关语法的模型,并且支持广泛的语法分析库。语法操作原语。从更一般的角度来看,我们的工作为浅层嵌入的领域特定语言(尤其是最终无标签的领域特定语言)中的可观察共享问题提供了一个经过充分研究的解决方案。

著录项

相似文献

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

客服邮箱:kefu@zhangqiaokeyan.com

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

  • 服务号