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

解析表达式语法时的错误报告

Error Reporting in Parsing Expression Grammars

André Murbach Maidl, Sérgio Medeiros, Fabio Mascarenhas, Roberto Ierusalimschy

摘要:

解析表达式语法(PEG)描述了自顶向下的解析器。不幸的是,在传统的自顶向下解析器中使用的错误报告技术并不直接适用于基于解析表达式语法(PEG)的解析器,所以它们必须以某种方式进行模拟。虽然PEG形式主义没有考虑到语义动作,实际PEG实现添加它们,我们展示了如何通过这些语义动作模拟错误报告启发式。我们还提出了一个补充的错误报告策略,可能会导致更好的错误消息:标记失败。这种方法受到程序设计语言异常处理的启发,并让PEG定义不同类型的故障,每个有序选择操作符指定它捕获的类型。标记的失败给出了一种方法来注释语法以获得更好的错误报告,表达确定性解析器组合子使用的一些错误报告策略,并在PEG中编码预测性自顶向下解析。

英文摘要:

Parsing Expression Grammars (PEGs) describe top-down parsers. Unfortunately, the error-reporting techniques used in conventional top-down parsers do not directly apply to parsers based on Parsing Expression Grammars (PEGs), so they have to be somehow simulated. While the PEG formalism has no account of semantic actions, actual PEG implementations add them, and we show how to simulate an error-reporting heuristic through these semantic actions. We also propose a complementary error reporting strategy that may lead to better error messages: labeled failures. This approach is inspired by exception handling of programming languages, and lets a PEG define different kinds of failure, with each ordered choice operator specifying which kinds it catches. Labeled failures give a way to annotate grammars for better error reporting, to express some of the error reporting strategies used by deterministic parser combinators, and to encode predictive top-down parsing in a PEG.

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

↑