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

不要惊慌! LR解析器更好、更少、更少的错误

Don't Panic! Better, Fewer, Syntax Errors for LR Parsers

Lukas Diekmann, Laurence Tratt

摘要:

对于人类来说,编译错误通常很容易修复,但对于一般的解析器和LR解析器来说,这并不容易。传统的"恐慌模式"错误恢复,虽然易于实现和适用于任何语法,往往会导致级联链的错误,淹没了原来的。更高级的错误恢复技术受此问题的影响较小,但几乎没有实际用途,因为它们的典型性能被认为很差,最坏的情况是无限的,并且它们报告的修复是任意的。在本文中,我们介绍了CPCT+算法,该算法的实现,解决这些问题。首先,CPCT+报告给定位置的完整的最低成本修复序列集,允许程序员选择最适合他们意图的序列。其次,在20万个真实语法无效的Java程序的语料库中,CPCT+能够在0.5秒的超时内修复98.37%的文件。最后,CPCT+使用完整的最小成本修复序列集来减少级联错误问题,其中不正确的错误恢复会导致进一步的虚假语法错误被识别。在整个测试语料库中,CPCT+向用户报告了435,812个错误位置,相对于恐慌模式报告的981,628个错误位置,大大减少了级联错误问题。

英文摘要:

Syntax errors are generally easy to fix for humans, but not for parsers in general nor LR parsers in particular. Traditional 'panic mode' error recovery, though easy to implement and applicable to any grammar, often leads to a cascading chain of errors that drown out the original. More advanced error recovery techniques suffer less from this problem but have seen little practical use because their typical performance was seen as poor, their worst case unbounded, and the repairs they reported arbitrary. In this paper we introduce the CPCT+ algorithm, and an implementation of that algorithm, that address these issues. First, CPCT+ reports the complete set of minimum cost repair sequences for a given location, allowing programmers to select the one that best fits their intention. Second, on a corpus of 200,000 real-world syntactically invalid Java programs, CPCT+ is able to repair 98.37% of files within a timeout of 0.5s. Finally, CPCT+ uses the complete set of minimum cost repair sequences to reduce the cascading error problem, where incorrect error recovery causes further spurious syntax errors to be identified. Across the test corpus, CPCT+ reports 435,812 error locations to the user, reducing the cascading error problem substantially relative to the 981,628 error locations reported by panic mode.

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

↑