arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1803.10215cs.PL
收藏

深度优先级冲突的零开销消歧

Towards Zero-Overhead Disambiguation of Deep Priority Conflicts

Luís Eduardo de Souza Amorim, Michael J. Steindorfer, Eelco Visser

摘要:

** 上下文 ** 上下文无关文法广泛用于语言原型和实现。它们允许以简洁和声明的方式形式化特定于域或通用程序设计语言的语法。然而,自然和简洁的方式编写一个上下文无关文法往往是模棱两可的。因此,语法形式主义支持以 * 声明性消歧规则 * 形式的扩展,以指定操作符先后次序和结合性,解决由对应于表达式的语法子集引起的歧义。** 查询 ** 在解析器中实现对声明性消歧的支持通常会带来以下一个或多个限制:缺乏解析性能,或缺乏模块化(即,不允许合成潜在不同语言的语法片段)。后一个主题通常由无扫描器的通用解析器来解决。我们的目标是装备无扫描器的广义解析器与新颖的消歧方法,是固有的性能,而不损害模块化和语言组成的关注。** 方法 ** 在本文中,我们提出了一种新的低开销实现技术,用于消除具有轻量级数据依赖的无扫描器广义解析器中的深层关联性和优先级冲突。** 知识 ** 关于操作符先后次序和结合性的歧义来自于组合语言的各种操作符。虽然 * 浅层冲突 * 可以通过一级树模式有效地解决,但 * 深层冲突 * 需要更精细的技术,因为它们可以在树中任意嵌套。当前解决深度优先级冲突的最先进方法带来了严重的性能开销。** 接地 ** 我们评估了我们的新方法对国家的最先进的声明性消歧机制。通过解析用Java和OCaml编写的流行开源存储库的语料库,我们发现,当解析具有深度优先级冲突的程序时,我们的方法比语法重写技术的速度提高了1.73倍-当解析没有深度冲突的程序时,开销为1- 2%。** 重要性 ** 最近的一项实证研究表明,深度优先级冲突确实在现实世界的程序中广泛存在。研究表明,在Github上一个流行的OCaml项目语料库中,高达17%的源文件包含深度优先级冲突。然而,在文献中没有解决方案,解决了有效的消除歧义的深层优先级冲突,支持模块化和组合语法定义。

英文摘要:

**Context** Context-free grammars are widely used for language prototyping and implementation. They allow formalizing the syntax of domain-specific or general-purpose programming languages concisely and declaratively. However, the natural and concise way of writing a context-free grammar is often ambiguous. Therefore, grammar formalisms support extensions in the form of *declarative disambiguation rules* to specify operator precedence and associativity, solving ambiguities that are caused by the subset of the grammar that corresponds to expressions. **Inquiry** Implementing support for declarative disambiguation within a parser typically comes with one or more of the following limitations in practice: a lack of parsing performance, or a lack of modularity (i.e., disallowing the composition of grammar fragments of potentially different languages). The latter subject is generally addressed by scannerless generalized parsers. We aim to equip scannerless generalized parsers with novel disambiguation methods that are inherently performant, without compromising the concerns of modularity and language composition. **Approach** In this paper, we present a novel low-overhead implementation technique for disambiguating deep associativity and priority conflicts in scannerless generalized parsers with lightweight data-dependency. **Knowledge** Ambiguities with respect to operator precedence and associativity arise from combining the various operators of a language. While *shallow conflicts* can be resolved efficiently by one-level tree patterns, *deep conflicts* require more elaborate techniques, because they can occur arbitrarily nested in a tree. Current state-of-the-art approaches to solving deep priority conflicts come with a severe performance overhead. **Grounding** We evaluated our new approach against state-of-the-art declarative disambiguation mechanisms. By parsing a corpus of popular open-source repositories written in Java and OCaml, we found that our approach yields speedups of up to 1.73x over a grammar rewriting technique when parsing programs with deep priority conflicts--with a modest overhead of 1-2 % when parsing programs without deep conflicts. **Importance** A recent empirical study shows that deep priority conflicts are indeed wide-spread in real-world programs. The study shows that in a corpus of popular OCaml projects on Github, up to 17 % of the source files contain deep priority conflicts. However, there is no solution in the literature that addresses efficient disambiguation of deep priority conflicts, with support for modular and composable syntax definitions.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑