跳到正文
EasyXiv 检索
投稿 关于 登录

按回车检索 · 直接输入编号(如 1706.03762)可跳转到论文

计算机科学 > 程序设计语言

arXiv:2005.06444 (cs)
[提交于 2020年5月13日 (v1),最后修订于 2020年5月31日 (此版本, v3)]

标题:Pika parsing: reformulating packrat parsing as a dynamic programming algorithm solves the left recursion and error recovery problems

作者:Luke A. D. Hutchison
查看论文《Pika parsing: reformulating packrat parsing as a dynamic programming algorithm solves the left recursion and error recovery problems》的 PDF
查看原文 PDF 中文 PDF (下批处理) EasyResearch 阅读
摘要:A recursive descent parser is built from a set of mutually-recursive functions, where each function directly implements one of the nonterminals of a grammar. A packrat parser uses memoization to reduce the time complexity for recursive descent parsing from exponential to linear in the length of the input. Recursive descent parsers are extremely simple to write, but suffer from two significant problems: (i) left-recursive grammars cause the parser to get stuck in infinite recursion, and (ii) it can be difficult or impossible to optimally recover the parse state and continue parsing after a syntax error. Both problems are solved by the pika parser, a novel reformulation of packrat parsing as a dynamic programming algorithm, which requires parsing the input in reverse: bottom-up and right to left, rather than top-down and left to right. This reversed parsing order enables pika parsers to handle grammars that use either direct or indirect left recursion to achieve left associativity, simplifying grammar writing, and also enables optimal recovery from syntax errors, which is a crucial property for IDEs and compilers. Pika parsing maintains the linear-time performance characteristics of packrat parsing as a function of input length. The pika parser was benchmarked against the widely-used Parboiled2 and ANTLR4 parsing libraries. The pika parser performed significantly better than the other parsers for an expression grammar, although for a complex grammar implementing the Java language specification, a large constant performance impact was incurred per input character. Therefore, if performance is important, pika parsing is best applied to simple to moderate-sized grammars, or to very large inputs, if other parsing alternatives do not scale linearly in the length of the input. Several new insights into precedence, associativity, and left recursion are presented.
评论: Submitted to ACM
主题: 程序设计语言 (cs.PL)
引用方式: arXiv:2005.06444 [cs.PL]
  (或者 arXiv:2005.06444v3 [cs.PL] 对于此版本)
  https://doi.org/10.48550/arXiv.2005.06444

提交历史

来自:Luke A. D. Hutchison
[v1] 2020年5月13日 星期三 17:38:47 UTC
[v2] 2020年5月20日 星期三 07:04:15 UTC
[v3] 2020年5月31日 星期日 07:47:44 UTC
全文链接:

访问论文:

  • 查看原文 PDF
  • 中文 PDF (下批处理)
  • EasyResearch 阅读
  • TeX 源文件
  • arXiv 原文页面
查看许可

当前浏览上下文:

cs
< 上一篇   |   下一篇 >
最新 | 近期 | 2020-05
切换浏览方式为:
cs.PL

参考文献与引用

  • Google Scholar
  • Semantic Scholar

BibTeX 格式的引用

EasyXiv 是独立运营的中文预印本站点,与 arXiv 及康奈尔大学无隶属关系。 论文元数据与原文来自 arXiv.org,感谢 arXiv 提供开放获取服务。
关于 · 帮助 · 投稿指南 · 版权 · arXiv 原站