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

解析表达式文法的计算模型

Computational Model for Parsing Expression Grammars

Alexander Rubtsov, Nikita Chudinov

AI总结:

本文为解析表达式文法(PEG)提出一种升级版确定性下推自动机计算模型,证明解析表达式语言包含 DCFLs 正则闭包的布尔闭包并对左拼接封闭,同时给出 2-way 版本的线性时间模拟算法。

摘要:

我们提出了一个用于解析表达式文法(PEGs)的计算模型。PEGs 的前身——自顶向下解析语言(TDPLs)由 A. Birman 和 J. Ullman 在 20 世纪 60 年代发现,B. Ford 在 2004 年证明了这两种形式体系识别同一类语言,即解析表达式语言(PELs)。A. Birman 和 J. Ullman 建立了诸如 TDPLs 能生成任意 DCFL 以及一些非上下文无关语言(如 $a^nb^nc^n$)等重要性质,同时也构造了一个线性时间解析算法。但由于该解析算法在 60 年代不实用,TDPLs 被放弃,随后由 B. Ford 升级为 PEGs,因此解析算法也(从实用角度)得到了改进。如今 PEGs 被积极用于编译器(例如,Python 用 PEG 解析器取代了 LL(1) 解析器)以及文本处理。在本文中,我们提出了 PEG 的计算模型,获得了 PELs 的结构性质,即证明了 PELs 包含 DCFLs 的正则闭包的布尔闭包,并且 PELs 在与 DCFLs 的正则闭包进行左拼接运算下封闭。我们基于计算模型的扩展提出了 PELs 类的扩展。我们的模型是对确定性下推自动机(DPDA)的升级,使得在弹出符号期间允许将读头返回到压入该符号时的位置。我们为该模型的 2-way 版本提供了一个线性时间模拟算法,该算法类似于著名的 S. Cook 的 2-way DPDA 线性时间模拟算法。

英文摘要:

We present a computational model for Parsing Expression Grammars (PEGs). The predecessor of PEGs top-down parsing languages (TDPLs) were discovered by A. Birman and J. Ullman in the 1960-s, B. Ford showed in 2004 that both formalisms recognize the same class named Parsing Expression Languages (PELs). A. Birman and J. Ullman established such important properties like TDPLs generate any DCFL and some non-context-free languages like $a^nb^nc^n$, a linear-time parsing algorithm was constructed as well. But since this parsing algorithm was impractical in the 60-s TDPLs were abandoned and then upgraded by B. Ford to PEGs, so the parsing algorithm was improved (from the practical point of view) as well. Now PEGs are actively used in compilers (eg., Python replaced LL(1)-parser with a PEG one) so as for text processing as well. In this paper, we present a computational model for PEG, obtain structural properties of PELs, namely proof that PELs contain Boolean closure of regular closure of DCFLs and PELs are closed over left concatenation with regular closure of DCFLs. We present an extension of the PELs class based on the extension of our computational model. Our model is an upgrade of deterministic pushdown automata (DPDA) such that during the pop of a symbol it is allowed to return the head to the position of the push of the symbol. We provide a linear-time simulation algorithm for the 2-way version of this model, which is similar to the famous S. Cook linear-time simulation algorithm of 2-way DPDA.

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

↑