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

用于岛屿解析的湖泊符号

Lake symbols for island parsing

Katsumi Okuda, Shigeru Chiba

摘要:

内容:岛解析器读取输入文本并仅构建文本中感兴趣的编程构造的解析(或抽象语法)树。这些构造称为岛,文本的其余部分称为水,解析器会忽略并跳过水。由于岛解析器不必解析输入的所有细节,因此它通常很容易开发,但对于许多软件工程工具来说仍然足够有用。当使用解析器生成器时,开发人员可以通过仅描述少量语法规则来实现岛解析器,例如,在解析表达式语法(PEG)中。咨询电话:但在实践中,语法规则往往很复杂,因为开发人员必须定义岛内的水;否则,岛屿解析不会减少语法规则的总数。当描述这种水的语法规则时,开发人员必须考虑其他规则并列举一组符号,我们称之为替代符号。由于这个困难,岛解析似乎没有被广泛使用的今天,尽管它在许多应用程序中的有用性。方法:本文提出了解决这个困难,在开发一个岛屿解析器的湖泊符号。它还对PEG进行了扩展,以支持湖泊符号。湖泊符号自动枚举岛屿内的水的替代符号。本文提出了一种将扩展PEG转换为普通PEG的算法,该算法可用于现有的基于PEG的语法分析器生成器。知识:用户可以使用湖泊符号来定义水,而无需指定每个替代符号。我们的算法可以计算一个湖符号的所有替代符号,根据湖符号在语法中的位置。基础:我们实现了一个接受我们扩展的PEG的解析器生成器,并为Java实现了36个岛解析器,为Python实现了20个岛解析器。我们的实验表明,湖符号平均减少了42%的Java语法规则和89%的Python规则,不包括岛屿是表达式的情况。重要性:这项工作简化了岛解析的使用。湖泊符号使用户能够比以前更简单地定义岛屿内的水。在岛内部定义水对于将岛解析应用于实际程序设计语言是必不可少的。

英文摘要:

Context: An island parser reads an input text and builds the parse (or abstract syntax) tree of only the programming constructs of interest in the text. These constructs are called islands and the rest of the text is called water, which the parser ignores and skips over. Since an island parser does not have to parse all the details of the input, it is often easy to develop but still useful enough for a number of software engineering tools. When a parser generator is used, the developer can implement an island parser by just describing a small number of grammar rules, for example, in Parsing Expression Grammar (PEG). Inquiry: In practice, however, the grammar rules are often complicated since the developer must define the water inside the island; otherwise, the island parsing will not reduce the total number of grammar rules. When describing the grammar rules for such water, the developer must consider other rules and enumerate a set of symbols, which we call alternative symbols. Due to this difficulty, island parsing seems to be not widely used today despite its usefulness in many applications. Approach: This paper proposes the lake symbols for addressing this difficulty in developing an island parser. It also presents an extension to PEG for supporting the lake symbols. The lake symbols automate the enumeration of the alternative symbols for the water inside an island. The paper proposes an algorithm for translating the extended PEG to the normal PEG, which can be given to an existing parser generator based on PEG. Knowledge: The user can use lake symbols to define water without specifying each alternative symbol. Our algorithms can calculate all alternative symbols for a lake symbol, based on where the lake symbol is used in the grammar. Grounding: We implemented a parser generator accepting our extended PEG and implemented 36 island parsers for Java and 20 island parsers for Python. Our experiments show that the lake symbols reduce 42 % of grammar rules for Java and 89 % of rules for Python on average, excluding the case where islands are expressions. Importance: This work eases the use of island parsing. Lake symbols enable the user to define the water inside the island simpler than before. Defining water inside the island is essential to apply island parsing for practical programming languages.

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

↑