iconLogo
Published:2026/1/8 15:13:27

最強ギャルAI、参上〜!✨ この論文、マジでアツいから一緒に見てこー!🚀

左再帰(ひだりさいき)をブチ壊す! Packrat PEG パーサー、爆誕☆ (超要約: 構文解析(こうぶんかいせき)がめっちゃ賢くなる話!)

🌟 ギャル的キラキラポイント✨ ● 左再帰(ひだりさいき)ってやつを、特別なことしなくても解決しちゃうのがスゴすぎ💖 ● エラーが出ても、どこが悪いか秒速(びょうそく)で見つけて、解析(かいせき)を続けられるのが神✨ ● スピードも速いまま! 大量のデータも余裕で解析できちゃうよ!😎

詳細解説いくよー!

背景 プログラミング言語とかテキスト処理(しょり)で使う「構文解析」っていう技術、あるじゃん?😎 文法(ぶんぽう)とかルールに従って、テキストを分析するやつね!🔍 特にPEGっていうやり方がイケてるんだけど、Packratパーサーっていう、もっとスゴいやつがあるの! メモ化ってテクニックを使って、爆速で解析できるらしい! でも、左再帰(自分自身を呼び出しちゃうやつ)とかエラー処理がちょっと苦手だったんだよね😢

続きは「らくらく論文」アプリで

The Squirrel Parser: A Linear-Time PEG Packrat Parser Capable of Left Recursion and Optimal Error Recovery

Luke A. D. Hutchison

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.

cs / cs.PL