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

消除左递归而不使用ε

Eliminating Left Recursion without the Epsilon

James Smith

AI总结:

针对标准左递归消除算法导致规则丢失和指数膨胀的问题,提出改进算法:先消除直接左递归,再用图论方法消除间接左递归,并重写解析树以恢复原始结构,兼顾理论与实用性。

摘要:

消除间接左递归的标准算法采取预防性方法,重写文法规则,使得间接左递归不再可能发生,而不是仅在发生时消除它。这种方法导致许多规则丢失,使得生成的解析树往往缺乏巴科斯范式(BNF)原本旨在捕获的细节。此外,标准算法在重写巴科斯范式(BNF)时会导致指数级膨胀,使其在实践中完全不可行。为避免这些缺陷,我们修改了标准算法以消除直接左递归,然后采用图论方法消除间接左递归。我们还扩展了该算法,重写生成的解析树,以恢复如果最初不必消除左递归时本应得到的解析树。因此,除了一些注意事项外,我们的算法不仅在理论上可行,而且在实践中也有效。

英文摘要:

The standard algorithm to eliminate indirect left recursion takes a preventative approach, rewriting a grammar's rules so that indirect left recursion is no longer possible, rather than eliminating it only as and when it occurs. This approach results in many of the rules being lost, so that the parse trees that result are often devoid of the detail that the BNF was supposed to capture in the first place. Furthermore, the standard algorithm results in exponential blow-up as the BNF is rewritten, making it wholly unworkable in practice. To avoid these pitfalls, we revise the standard algorithm to eliminate direct left recursion and then take a graph-theoretic approach to eliminating indirect left recursion. We also extend the algorithm to rewrite the resultant parse trees in order to recover the parse trees that would have resulted if left recursion had not had to be eliminated in the first place. Therefore, aside from a couple of caveats, our algorithm works not just in theory but also in practice.

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

↑