We present the squirrel parser, a PEG packrat parser that directly handles all forms of left recursion with optimal error recovery, while maintaining linear time complexity in the length of the input even in the presence of an arbitrary number of errors. Traditional approaches to handling left recursion in a recursive descent parser require grammar rewriting or complex algorithmic extensions. We derive a minimal algorithm from first principles: cycle detection via per-position state tracking and $O(1)$-per-LR-cycle communication from descendant to ancestor recursion frames, and fixed-point search via iterative expansion. For error recovery, we derived a set of four axioms and twelve constraints that must be imposed upon an optimal error recovery design to ensure completeness, correctness, optimality of performance, and intuitiveness of behavior. We utilized a constraint satisfaction mechanism to search the space of all possibilities, arriving at a provably optimal and robust error recovery strategy that maintains perfect performance linearity.


翻译:本文提出松鼠解析器,这是一种能够直接处理所有形式左递归并具备最优错误恢复能力的PEG记忆包解析器,即使在任意数量错误存在的情况下仍能保持输入长度级的线性时间复杂度。传统递归下降解析器处理左递归的方法需要语法重写或复杂的算法扩展。我们从基本原理推导出一个最小化算法:通过逐位置状态追踪进行环检测,建立后代递归帧到祖先递归帧的每左递归周期O(1)通信机制,并采用迭代展开的定点搜索策略。针对错误恢复问题,我们推导出包含四条公理与十二条约束的集合,这些约束必须施加于最优错误恢复设计,以确保其完备性、正确性、性能最优性及行为直观性。我们采用约束满足机制遍历所有可能性空间,最终得到可证明最优且鲁棒的错误恢复策略,该策略始终保持完美的线性性能表现。

0
下载
关闭预览

相关内容

专知会员服务
12+阅读 · 2021年6月20日
MonoGRNet:单目3D目标检测的通用框架(TPAMI2021)
专知会员服务
18+阅读 · 2021年5月3日
专知会员服务
29+阅读 · 2020年10月2日
误差反向传播——CNN
统计学习与视觉计算组
30+阅读 · 2018年7月12日
CosFace: Large Margin Cosine Loss for Deep Face Recognition论文笔记
统计学习与视觉计算组
44+阅读 · 2018年4月25日
语义分割中的深度学习方法全解:从FCN、SegNet到DeepLab
炼数成金订阅号
26+阅读 · 2017年7月10日
MNIST入门:贝叶斯方法
Python程序员
23+阅读 · 2017年7月3日
国家自然科学基金
46+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
6+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
相关资讯
误差反向传播——CNN
统计学习与视觉计算组
30+阅读 · 2018年7月12日
CosFace: Large Margin Cosine Loss for Deep Face Recognition论文笔记
统计学习与视觉计算组
44+阅读 · 2018年4月25日
语义分割中的深度学习方法全解:从FCN、SegNet到DeepLab
炼数成金订阅号
26+阅读 · 2017年7月10日
MNIST入门:贝叶斯方法
Python程序员
23+阅读 · 2017年7月3日
相关基金
国家自然科学基金
46+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
6+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员